diff --git a/eeschema/sch_symbol.cpp b/eeschema/sch_symbol.cpp index 3f10486e06..4f49755329 100644 --- a/eeschema/sch_symbol.cpp +++ b/eeschema/sch_symbol.cpp @@ -1154,6 +1154,10 @@ void SCH_SYMBOL::GetContextualTextVars( wxArrayString* aVars ) const aVars->push_back( wxT( "EXCLUDE_FROM_BOM" ) ); aVars->push_back( wxT( "EXCLUDE_FROM_BOARD" ) ); aVars->push_back( wxT( "DNP" ) ); + aVars->push_back( wxT( "SHORT_NET_NAME()" ) ); + aVars->push_back( wxT( "NET_NAME()" ) ); + aVars->push_back( wxT( "NET_CLASS()" ) ); + aVars->push_back( wxT( "PIN_NAME()" ) ); } @@ -1275,6 +1279,39 @@ bool SCH_SYMBOL::ResolveTextVar( wxString* token, int aDepth, const SCH_SHEET_PA *token = this->GetDNP() ? _( "DNP" ) : wxT( "" ); return true; } + else if( token->StartsWith( wxT( "SHORT_NET_NAME(" ) ) + || token->StartsWith( wxT( "NET_NAME(" ) ) + || token->StartsWith( wxT( "NET_CLASS(" ) ) + || token->StartsWith( wxT( "PIN_NAME(" ) ) ) + { + wxString pinNumber = token->AfterFirst( '(' ); + pinNumber = pinNumber.BeforeLast( ')' ); + + for( SCH_PIN* pin : GetPins( aPath ) ) + { + if( pin->GetNumber() == pinNumber ) + { + if( token->StartsWith( wxT( "PIN_NAME" ) ) ) + { + *token = pin->GetAlt().IsEmpty() ? pin->GetName() : pin->GetAlt(); + return true; + } + + SCH_CONNECTION* conn = pin->Connection( aPath ); + + if( !conn ) + *token = wxEmptyString; + else if( token->StartsWith( wxT( "SHORT_NET_NAME" ) ) ) + *token = conn->LocalName(); + else if( token->StartsWith( wxT( "NET_NAME" ) ) ) + *token = conn->Name(); + else if( token->StartsWith( wxT( "NET_CLASS" ) ) ) + *token = pin->GetEffectiveNetClass( aPath )->GetName(); + + return true; + } + } + } // See if parent can resolve it (this will recurse to ancestors) diff --git a/pcbnew/footprint.cpp b/pcbnew/footprint.cpp index e65f0530dc..d75ae7cc50 100644 --- a/pcbnew/footprint.cpp +++ b/pcbnew/footprint.cpp @@ -525,7 +525,7 @@ bool FOOTPRINT::ResolveTextVar( wxString* token, int aDepth ) const else if( token->StartsWith( wxT( "SHORT_NET_NAME(" ) ) || token->StartsWith( wxT( "NET_NAME(" ) ) || token->StartsWith( wxT( "NET_CLASS(" ) ) - || token->StartsWith( wxT( "PIN_NAME(" ) ) ) + || token->StartsWith( wxT( "PIN_NAME(" ) ) ) { wxString padNumber = token->AfterFirst( '(' ); padNumber = padNumber.BeforeLast( ')' );