Custom rule question

I’m just starting to play with the “Custom rules” in pcbnew 5.99 and am wondering if there is a better way to write this custom rule:

(rule Lx_Ly
	(constraint clearance (min 12mm))
	(condition "(A.NetClass == 'L1' || A.NetClass == 'L2' || A.NetClass == 'L3') && (B.NetClass == 'L1' || B.NetClass == 'L2' || B.NetClass == 'L3') && A.NetClass != B.NetClass"))

The intent here is to enforce a clearance of 12mm between traces of different phases L1-L3.

I was hoping I could extract the first character of the NetClass name to simplify the condition to:

(condition "A.NetClass[0] == 'L' && B.NetClass[0] == 'L' && A.NetClass != B.NetClass"))

but the left bracket is rejected as invalid syntax. Is there a way to extract a portion of a string?

Thanks in advance for any suggestions!

No, the “language” is very simple and limited to the necessary. It lacks all features of a generic programming language. Maybe the == syntax shouldn’t even be though of as comparing strings but verifying identity, even though in the implementation it of course handles strings.

Maybe the syntax will be enhanced in the future versions after v6. An alternative syntax could be something like

A.NetClass in ('L1' 'L2')

which would make some things easier and shorter but might be easier to implement and clearer than string syntax and array syntax.

1 Like

OK, cool, thanks for the quick reply!

Yeah, I actually tried A.NetClass in [‘L1’, ‘L2’, ‘L3’] since I was thinking Python might be supported within the condition string.

No problem though - I’m just glad that we can define custom rules now. That should come in very handy, so thanks!

1 Like


(condition "A.NetClass == 'L*' && B.NetClass == 'L*' && A.NetClass != B.NetClass")

What would be handy from an enhancement perspective is multiple conditions

(rule “line-line”
(constraint clearance (min 12mm))
(condition "A.NetClass == ‘L1’ && "B.NetClass == ‘L2’)
(condition "A.NetClass == ‘L2’ && "B.NetClass == ‘L3’)
(condition "A.NetClass == ‘L3’ && "B.NetClass == ‘L1’)

Wildcards work - thanks for the suggestion!

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