Some questions about Custom Rules for footprints

These questions are for those who know the custom rules system, maybe @JeffYoung.

1. Is it possible to apply a rule to instances of certain footprint, so that for example all MyLib:0402resistor are affected? I wonder if there could be for example a property “Footprint” for all items inside footprints, and then “LibraryLink” for the Footprint which can be reached from the inner items.

2. Should a custom rule for pad clearance override Clearances → Pad clearance in Pad properties? I have a rule:

(version 1)
(rule "padclearanceinsidesamefootprint"
(condition "A.Type == 'Pad' && B.Type == 'Pad' && A.Parent == B.Parent")
(constraint clearance(min 0.15mm))
)

which, as far as I can see, should affect the pad clearance inside any footprint. But it doesn’t, and Clearance Resolution doesn’t apply the custom rule:

Layer F.Cu
Pad 1 [<no net>] of REF** on F.Cu [netclass Default]
Pad 2 [<no net>] of REF** on F.Cu [netclass Default]
Local override on Pad 1 [<no net>] of REF** on F.Cu; clearance: 1,0000 mm.
Local override on Pad 2 [<no net>] of REF** on F.Cu; clearance: 1,0000 mm.
Resolved clearance: 1 mm.

(BTW, “Parent” should be documented better. The current documentation says “Returns the unique identifier of the parent object of this object”. What is “parent object”? I found out that the footprint is the parent of the pad, though.)

If I remove the customized pad clearance in the pad Properties, the rule works. So I wonder if the rule applying order is this on purpose or an oversight.

Local overrides (ie: those set in Footprint Properties or Pad Properties) have precedence over custom rules.

For a particular footprint type you’re probably out of luck. I see this in the code:

        // TODO zone connection, FPID?

(The FPID is library:footprint_name.)

OK. It would be good to document that, too.

Hmm, would it be worth creating a wishlist issue… There are some workarounds, namely creating a named rule area or a named group inside the footprint. Group is especially good because footprint’s items won’t be selected individually anyway on the board and it prevents rule matching accidentally. But it’s not as clean as targeting a specific footprint name, and requires a custom footprint.

Yes, all properties should be exposed eventually, but without an issue we’ll probably forget

I added Footprint.Library_ID, Footprint.Description and Footprint.Keywords. Library_ID is library_nickname:footprint_name.

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