PCBA wants all parts in the POS file not just SMD

How does one achieve this?

I noticed that @mondalaci mentioned an option

The current SMD vs PTH vs virtual properties seem entirely sufficient given that the “include PTH components to .POS file” option is in place.

over on launchpad:

Allow to export the positions of through-hole components

However, I cannot find this option in 4.0.7 nor in the most recent nightly Windows build (as of March 19, 2017).

There is no option, the user meant IF there was an option on export (which is his proposed fix), then it would be sufficient. It seems like a reasonable proposal, but when a developer doesn’t want to do something they make up excuses :slight_smile:

I would suggest a script, there may be one already.

There is a workaround

In the footprint properties window, under placement type select surfface mount for all your throug-hole components.
Then generate the .pos file

Drawback: the .pos file will have all the components, th and smd, mixed ordered by reference.

Oops. I missed the fact that it was his proposal. Thanks for setting me straight.

I do have some experience with scripting Kicad but what did you have in mind here? Iterating through board.GetModules() and generating the POS file myself?

Yes, I think it should be straightforward.

You can simply produce the SMD POS file and then the the POS file forcing INSERT for all footprint (export menu option).
Then just compare the two files… the diff are the TH POS :wink:
(EDIT you may also find the virtual in the diff)

Here is a script that seems to reproduce the KiCad pos export

import sys
import pcbnew
import datetime

"""
execfile ("c:/python_progs/test_pcb/get_pos.py")
"""

def pcbfunc(Filename = None):
    if Filename: 
        my_board = pcbnew.LoadBoard (Filename)
    else:
        my_board = pcbnew.GetBoard()

    print ("### Module positions - created on %s ###" % datetime.datetime.now().strftime("%Y-%m-%d %H:%M"))
    print ("### Printed by get_pos v1")
    print ("## Unit = mm, Angle = deg.")
    print ("## Side : All")
    print ("# Ref     Val        Package                PosX       PosY       Rot  Side")

    for module in my_board.GetModules():
        print ("%s \"%s\" %s %1.3f %1.3f %1.3f %s" % ( module.GetReference(), 
                                    module.GetValue(),
                                    module.GetFPID().GetFootprintName(),
                                    pcbnew.ToMM(module.GetPosition().x),
                                    pcbnew.ToMM(module.GetPosition().y),
                                    module.GetOrientation(),
                                    "top" if module.GetLayer() == 0 else "bottom"
                                    ))

    print ("## End")

# pcbfunc("C:\\git_bobc\\bobc_hardware_live\\Smart_RGB_LED_AT85\\rgb_led.kicad_pcb")
pcbfunc()

Sample output

execfile ("c:/python_progs/test_pcb/get_pos.py")
### Module positions - created on 2018-03-20 09:20 ###
### Printed by get_pos v1
## Unit = mm, Angle = deg.
## Side : All
# Ref     Val        Package                PosX       PosY       Rot  Side
J1 "CONN_01X01" Pin_Header_Angled_1x01_Pitch1.27mm 130.000 125.000 0.000 top
J2 "CONN_01X01" Pin_Header_Angled_1x01_Pitch1.27mm 130.000 115.000 0.000 top
J3 "External supply" Pin_Header_Angled_1x02_Pitch2.54mm 130.000 90.000 0.000 top
J4 "CONN_01X01" Pin_Header_Angled_1x01_Pitch2.54mm 130.000 105.000 0.000 top
J5 "CONN_01X01" Pin_Header_Angled_1x01_Pitch2.54mm 130.000 80.000 0.000 top
J6 "External regulated power" Pin_Header_Straight_1x02_Pitch2.54mm 70.000 90.000 0.000 top
U4 "7805" SOT-23 97.500 80.000 0.000 top
U5 "74AHC1G04" SOT-223 75.000 115.000 0.000 top
U6 "74AHC1G04" SOT-223 113.000 105.000 0.000 top
U7 "74AHC1G04" SOT-223 85.000 132.321 3300.000 top
U8 "74AHC1G04" SOT-223 112.000 80.500 0.000 top
U9 "74AHC1G04" SOT-223 113.000 93.000 0.000 top
U10 "74AHC1G04" SOT-223 97.500 93.000 0.000 top
## End

Writing to a file is standard Python, so exercise left to reader :slight_smile:

My POS file generation dialog looks like this:

There is no “forcing INSERT for all footprint” option AFAIK?

Thank you very much! This is perfect.

use the one selected

I must be misunderstanding something in your suggestion because this will not include the TH components?

try it and compare the files

I did :wink: but there was no difference. Both files include only SMD parts and are exactly the same.

you are right, I remember once it did the trick on nightly, but now it doesn’t anymore

Darn! I guess that means at some point the developers did consider making the change but then put it back.

No, it has never been an option, that code hasn’t changed much for years. The option for “Force INSERT” was a workaround for a lot of SMD library footprints that did not have Insert attribute set, but were actually SMD footprints.

Btw, module.GetAtttributes() returns an int which gives the type, PTH=0, SMD=1, virtual = 2.

it seems that

module.GetFPID().GetFootprintName()

doesn’t work anymore on nightlies

Yes, it’s changed to GetLibItemName() instead of GetFootprintName().

This is useful to know. Thanks!

you may find also useful this

print ("Board Aux Origin: " + str(my_board.GetAuxOrigin()))