How to draw a line in python scripting console in KiCad v7?

I am trying to draw a line segment in python scripting console using pcbnew. pcbnew.DRAWSEGMENT but get this error:
image

Any idea how to draw line segments in newer versions of kicad python?

Drawsegment is called PCB_SHAPE (or FP_SHAPE for footprints) in kicad 7

https://docs.kicad.org/doxygen-python-7.0/classpcbnew_1_1PCB__SHAPE.html

1 Like

Thanks!! I am trying to draw a line. How should I use PCB_SHAPE to draw a line?

Check out the link I gave you. That class inherits various methods of EDA_SHAPE and BOARD_ITEM.
Use SetStart() SetEnd() to set coordinates of the line segment, SetWidth() and SetLayer() are self explanatory.
Keep in mind that coordinates are in nanometers so either use FromMM() utilities in pcbnew module or multiply everything by a million if your original coordinates are in mm.

Last but not least, look at existing plugin code that generates graphics or moves thing around on the pcb, there are many things you can learn from code of plugins in the plugin manager.

1 Like

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