# Finding location for mirrored plots with python API

Hello, i am trying to make python scrip that would add additional information on SVG plot.
Got front layer working.
How do i calculate component coordinates for mirrored Back layer with python API.
Maybe someone could point me in right direction on finding PCB center or whole solution for finding mirrored coordinates

Youâ€™ll have to be more specific about what you want or what your trying to do. â€śPCB Centerâ€ť doesnâ€™t really have meaning for an arbitrarily shaped PCB. And â€śwhole solutionâ€ť isnâ€™t very specific: whole solution for what?

Look through the pcbnew python documentation and look for the various attributes and methods for BOARD and MODULE. They include things like GetBoundimgBox() and GetPositionâ€¦

getBoundingBox() is working great for me on top layer. But if I use result from getBoundingBox() on mirrored bottom layer it is offset.
I am trying to figure out how to translate result from getBoundingBox() to match it with mirrored plot.
By full solution i meant ideas for coordinate translation.

I donâ€™t have a solution for you but here is how I would go about it.

1. Read kicad code, answer should be here or in callsites to this class https://gitlab.com/kicad/code/kicad/blob/master/common/plotters/SVG_plotter.cpp
2. Figure it out through few trials and some math. Since coordinate transformation is simple linear function just getting 2 data points should be enough. Create a super simple board with just edge cuts and plot it. Then move it 10 mm right (if mirror is vertical) and plot again. Note how that affects svg coordinates. Then apply math.
1 Like

Thank you for pointing me in the right direction.
I found solution in https://gitlab.com/kicad/code/kicad/-/blob/master/common/plotters/plotter.cpp

if( m_mirrorIsHorizontal )
x = ( paperSize.x - pos.x * plotScale );

And in my code it was

x = paperSizeX - x - width

And from this drawing rectangle bounding box

This topic was automatically closed 90 days after the last reply. New replies are no longer allowed.