Python scripting pcbnew isonlayer(): solder versus mounting side

I get the footprints from board, then walk through the footprints list and if the footprint reference matches the footprint reference I want I call the function to get the information: IsOnLayer.

For some components , mostly it seems the through hole connectors , when a part is on the front side, this function returns isonlayer = fp.IsOnLayer(pcbnew.B_Cu) as True

So it seems, the function IsOnlayer() layer seems to be True NOT for the where the component is mounted but where the soldering takes place.

1.How to get the information on which side the part is placed ?
2. Which definition of layer use board fabs ? The side for soldering or for placement ? I thought the placement side.

What I want to to tell the fab is,

[1] which side the part is mounted on (some are even halfway in the board with pad on top and bottom)
[2] If its an SMD or TH or hybrid part.

HasThroughHolePads() tells me it has TH pad, but does not tell me it could also have SMD pads to be soldered. Some hybrid parts can be mounted by P&P reflow but also may need non-reflow soldering on the other side, either automated or manually.

That seem incorrect. I read an LED that is mounted on the Front of PCB (thus, F_Cu) and that’s what is listed at the start of the file reading.
Near the end of the file, there’s a statement showing the two Pads are on B_Cu.

That is correct as I had set the footprint that way. It was done in previous Kicad version wherin there was a selection choice. Now, the panel has changed with v7 and the F/B selection menu has changed. But, the file still shows footprint is placed on F_Cu. However, the Pads are now listed as just ‘Cu’ (no longer B/F_Cu), regardless of how the Pad connections are set. See last screenshot…

Screen Shot 2024-01-16 at 12.59.21

“mostly it seems the through hole connectors , when a part is on the front side, this function returns isonlayer = fp.IsOnLayer(pcbnew.B_Cu) as True”

Yes, I believe that is incorrect. I checked many projects and boards and consistently the bottom B.Cu is returns a True in this function. No matter for what type of component as long its TH and side if “Front” in the footprint.

For example, In the PCB file the part it is listed as
(fp_text reference “SW302” (at 0.78 -5.55) (layer “F.SilkS”)
So I changed it to fp.IsOnLayer(pcbnew.F_SilkS) it’s now correct.

Not sure why it uses F.SilkS in the PCB file instead of F.Cu

Thus assume that B.Cu/F.Cu can be used to find the side for soldering and F.SilkS/B.SilkS as were the parts is placed. Note that this works when NOT using the silk screen of the reference designator on the side where the solder is for TH components

Well, still not out of the woods with this, I have a TH footprint with “J1” silkscreen on the front layer, but it has also some silkscreen (not the refdes) on the bottom and as a TH it has copper on the bottom and front layer. Isonlayer() returns True for F.SilkS/B.Silks/B.Cu and F.Cu. So now , how to figure out where the component placed ? In general TH components on the B side are few, so the logic becomes TH = front side.

I would have expected the function to return FALSE for for the Refdes SilkS when the refdes is not NOT on the specific silkscreen layer, but it returns True when the footprint has ANY kind of silkscreen on a side no matter where the REFDES is located. if that could be changed, the the IsOnLayer() would be useful to identify where a TH component is placed.

The python api is a automatic export generated by SWIG that exposes our C++ internals directly. We aren’t going to change our internal C++ functions just because of misunderstandings in the python domain.

In C++ land, GetLayer is equivalent to that “Side” dropdown you see in footprint properties.

    m_BoardSideCtrl->SetSelection( (m_footprint->GetLayer() == B_Cu) ? 1 : 0 );

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