KiCad 6 dimensions and Python bindings

On KiCad 6 when you create a dimension it uses a units mode 3, which is DIM_UNITS_MODE_AUTOMATIC.

Now: when you plot a gerber from Python … what’s the automatic? I’m getting inches for a project that used millimeters.

What API function configures the default units?

1 Like

Is the unit set to mm in the board settings? If so, is the editor currently set to mm as well (with the mm button in the lwft toolbar)? If both are set to mm it doesn’t seem correct that KiCad would plot the dimension in inches. I don’t know of a setting in the python api to change the unit of the plot.

You can change the unit of the dimension from automatic to mm in the properties of the dimension. At least that should give you the desired output.

“Automatic” means “follow the user’s UI setting” which is not related to any setting stored in the board/project. So, it doesn’t much make sense in the Python context. We could add an API in the future to allow Python scripts to specify the “UI units” but until/unless that happens, your best bet is to use a different units mode.

Thanks for clarifying it. I’ll advice users to force the desired mode until we have a mechanism.

I’m currently solving this problem in the following way:

  1. The user can define the units in KiBot config.
  2. When we load a PCB all dimensions with automatic units are changed to the units selected by the user. I scan all drawings looking for PCB_DIM_* objects.

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