Adding Height to the *.pos file

Awesome… It works… :slight_smile:

Thank you very much…
Just some minor customization to add headers for columns…

OK, I am analyzing the coordinates, and I am not understanding why it seems to not use my “Drill and Place Origin” and/or my “Grid Origin” (co-located on bottom left hand corner of PCB). for calculating PosX and PosY offsets.
I just figure out that it is using the upper left hand corner of my drawing as my origin not my .“Drill and Place Origin” and/or my “Grid Origin” placement .

Preferences > PCB Editor > Origins and Axes

Nope, no change for this custom scripting python.
Yes, on the regular *.pos (x/y only file)

Yeah, you get the internal representation of kicad in python* if you want another origin just calculate it. Here is the the outline on how to change things:

  • Get the origin with:
    origin = pcb.GetDesignSettings().GetAuxOrigin()
    Place this in the code somewhere before the for loop but after the line pcb = pcbnew.GetBoard()
  • Change the line (PosX, PosY) = ToMM(fp.GetPosition()) to:
    (PosX, PosY) = ToMM( fp.GetPosition() - origin)

That should do it

PS: if you want user origin instead of drill origin use GetGridOrigin() instead of GetAuxOrigin()

* This is typical to programming interfaces. Its considered a good thing to be able to see what is under the hood in reality.

ok, that solved the issue of origin offset. :slight_smile:
How do I get the Headers labeled automatically?
I currently have to manually add them to the *.csv file.
After that I would call this a good external plugin…
Thank you for your help…
PS I have both the grid origin and drill origin the same place for now.

One other item: Nice have…
How would I change the code so it pulls the PosZ from the schematic library “Height” parameter vs the footprint “Height” parameter.
The reason for this is because I could have the same footprint but different parts with different heights, eg capacitors in my case.

 writer.writerow(["Ref", "Val", "Package", "PosX", "PosY", "Rot", "Height", "Side"])

I dont think you currently can. (i mean you can but its not part of the commands of the tool youd need to implement a bit more reading)

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