mirror of
https://gitlab.com/kicad/code/kicad.git
synced 2025-04-21 18:33:45 +00:00
Support component class in footprint custom rules
This commit is contained in:
parent
4b1b0982a3
commit
683ce4c904
@ -4,18 +4,29 @@ _HKI( "### Expression functions\n"
|
||||
"All function parameters support simple wildcards (`*` and `?`).\n"
|
||||
"<br><br>\n"
|
||||
"\n"
|
||||
" A.intersectsCourtyard('<footprint_refdes>')\n"
|
||||
" A.intersectsCourtyard('<footprint_identifier>')\n"
|
||||
"True if any part of `A` lies within the given footprint's principal courtyard.\n"
|
||||
"<br><br>\n"
|
||||
"\n"
|
||||
" A.intersectsFrontCourtyard('<footprint_refdes>')\n"
|
||||
" A.intersectsFrontCourtyard('<footprint_identifier>')\n"
|
||||
"True if any part of `A` lies within the given footprint's front courtyard.\n"
|
||||
"<br><br>\n"
|
||||
"\n"
|
||||
" A.intersectsBackCourtyard('<footprint_refdes>')\n"
|
||||
" A.intersectsBackCourtyard('<footprint_identifier>')\n"
|
||||
"True if any part of `A` lies within the given footprint's back courtyard.\n"
|
||||
"<br><br>\n"
|
||||
"\n"
|
||||
"The `footprint_identifier` listed above can be one of the following:\n"
|
||||
"\n"
|
||||
"1. A reference designator, possibly containing wildcards `*` and `?`\n"
|
||||
"2. A footprint library identifier such as `LibName:FootprintName`. In this case,\n"
|
||||
" the library identifier must contain the `:` character to separate the library\n"
|
||||
" name from the footprint name, and either name may contain wildcards.\n"
|
||||
"3. A component class, in the form `${Class:ClassName}`. The keyword `Class` is not\n"
|
||||
" case-sensitive, but component class names are case-sensitive.\n"
|
||||
"\n"
|
||||
"<br>\n"
|
||||
"\n"
|
||||
" A.intersectsArea('<zone_name>')\n"
|
||||
"True if any part of `A` lies within the given zone's outline.\n"
|
||||
"<br><br>\n"
|
||||
@ -51,11 +62,9 @@ _HKI( "### Expression functions\n"
|
||||
"Includes nested membership.\n"
|
||||
"<br><br>\n"
|
||||
"\n"
|
||||
" A.memberOfFootprint('<footprint_reference>|<footprint_id>')\n"
|
||||
"True if `A` is a member of a footprint matching the given reference designator or footprint\n"
|
||||
"ID. The parameter can contain wildcards.\n"
|
||||
"\n"
|
||||
"NB: If matching against a footprint ID is desired, the parameter must contain a ':'.\n"
|
||||
" A.memberOfFootprint('<footprint_identifier>')\n"
|
||||
"True if `A` is a member of a given footprint (for example, a pad or graphic shape defined\n"
|
||||
"inside that footprint). The various ways of specifying `footprint_identifier` are described above.\n"
|
||||
"<br><br>\n"
|
||||
"\n"
|
||||
" A.memberOfSheet('<sheet_path>')\n"
|
||||
|
@ -3,18 +3,29 @@
|
||||
All function parameters support simple wildcards (`*` and `?`).
|
||||
<br><br>
|
||||
|
||||
A.intersectsCourtyard('<footprint_refdes>')
|
||||
A.intersectsCourtyard('<footprint_identifier>')
|
||||
True if any part of `A` lies within the given footprint's principal courtyard.
|
||||
<br><br>
|
||||
|
||||
A.intersectsFrontCourtyard('<footprint_refdes>')
|
||||
A.intersectsFrontCourtyard('<footprint_identifier>')
|
||||
True if any part of `A` lies within the given footprint's front courtyard.
|
||||
<br><br>
|
||||
|
||||
A.intersectsBackCourtyard('<footprint_refdes>')
|
||||
A.intersectsBackCourtyard('<footprint_identifier>')
|
||||
True if any part of `A` lies within the given footprint's back courtyard.
|
||||
<br><br>
|
||||
|
||||
The `footprint_identifier` listed above can be one of the following:
|
||||
|
||||
1. A reference designator, possibly containing wildcards `*` and `?`
|
||||
2. A footprint library identifier such as `LibName:FootprintName`. In this case,
|
||||
the library identifier must contain the `:` character to separate the library
|
||||
name from the footprint name, and either name may contain wildcards.
|
||||
3. A component class, in the form `${Class:ClassName}`. The keyword `Class` is not
|
||||
case-sensitive, but component class names are case-sensitive.
|
||||
|
||||
<br>
|
||||
|
||||
A.intersectsArea('<zone_name>')
|
||||
True if any part of `A` lies within the given zone's outline.
|
||||
<br><br>
|
||||
@ -50,11 +61,9 @@ True if `A` is a member of the given group. The name can contain wildcards.
|
||||
Includes nested membership.
|
||||
<br><br>
|
||||
|
||||
A.memberOfFootprint('<footprint_reference>|<footprint_id>')
|
||||
True if `A` is a member of a footprint matching the given reference designator or footprint
|
||||
ID. The parameter can contain wildcards.
|
||||
|
||||
NB: If matching against a footprint ID is desired, the parameter must contain a ':'.
|
||||
A.memberOfFootprint('<footprint_identifier>')
|
||||
True if `A` is a member of a given footprint (for example, a pad or graphic shape defined
|
||||
inside that footprint). The various ways of specifying `footprint_identifier` are described above.
|
||||
<br><br>
|
||||
|
||||
A.memberOfSheet('<sheet_path>')
|
||||
|
@ -228,7 +228,22 @@ static bool searchFootprints( BOARD* aBoard, const wxString& aArg, PCBEXPR_CONTE
|
||||
}
|
||||
else for( FOOTPRINT* fp : aBoard->Footprints() )
|
||||
{
|
||||
if( fp->GetReference().Matches( aArg ) )
|
||||
// NOTE: This code may want to be somewhat more generalized, but for now it's implemented
|
||||
// here to support functions like insersectsCourtyard where we want multiple ways to search
|
||||
// for the footprints in question.
|
||||
// If support for text variable replacement is added, it should happen before any other
|
||||
// logic here, so that people can use text variables to contain references or LIBIDs.
|
||||
// (see: https://gitlab.com/kicad/code/kicad/-/issues/11231)
|
||||
|
||||
// First check if we have a known directive
|
||||
if( aArg.Upper().StartsWith( wxT( "${CLASS:" ) ) && aArg.EndsWith( '}' ) )
|
||||
{
|
||||
wxString name = aArg.Mid( 8, aArg.Length() - 9 );
|
||||
|
||||
if( fp->GetComponentClass()->ContainsClassName( name ) && aFunc( fp ) )
|
||||
return true;
|
||||
}
|
||||
else if( fp->GetReference().Matches( aArg ) )
|
||||
{
|
||||
if( aFunc( fp ) )
|
||||
return true;
|
||||
|
Loading…
Reference in New Issue
Block a user