Fixing Eagle refs that do not work with KiCad
KiCad has stricter requirements for what consititutes an annotated
symbol. This checks for and corrects annotations that begin with '#',
do not begin with a non-numeric character or do not end with a number
(cherry picked from commit 78620347c8
)
Fixes https://gitlab.com/kicad/code/kicad/issues/10760
This commit is contained in:
parent
b17eb3a584
commit
ab835937a7
|
@ -1352,11 +1352,20 @@ void SCH_EAGLE_PLUGIN::loadInstance( wxXmlNode* aInstanceNode )
|
|||
// with a hash character to mute netlist updater complaints
|
||||
wxString reference = package.IsEmpty() ? '#' + einstance.part : einstance.part;
|
||||
|
||||
// reference must end with a number but EAGLE does not enforce this
|
||||
if( reference.find_last_not_of( "0123456789" ) == (reference.Length()-1) )
|
||||
reference.Append( "0" );
|
||||
|
||||
// EAGLE allows references to be single digits. This breaks KiCad netlisting, which requires
|
||||
// parts to have non-digit + digit annotation. If the reference begins with a number,
|
||||
// we prepend 'UNK' (unknown) for the symbol designator
|
||||
if( reference.find_first_not_of( wxT( "0123456789" ) ) == wxString::npos )
|
||||
reference.Prepend( wxT( "UNK" ) );
|
||||
if( reference.find_first_not_of( "0123456789" ) != 0 )
|
||||
reference.Prepend( "UNK" );
|
||||
|
||||
// EAGLE allows designator to start with # but that is used in KiCad
|
||||
// for symbols which do not have a footprint
|
||||
if( einstance.part.find_first_not_of( "#" ) != 0 )
|
||||
reference.Prepend( "UNK" );
|
||||
|
||||
SCH_SHEET_PATH sheetpath;
|
||||
m_rootSheet->LocatePathOfScreen( screen, &sheetpath );
|
||||
|
|
|
@ -1202,7 +1202,25 @@ void EAGLE_PLUGIN::loadElements( wxXmlNode* aElements )
|
|||
valueNamePresetInPackageLayout = false;
|
||||
}
|
||||
|
||||
footprint->SetReference( FROM_UTF8( e.name.c_str() ) );
|
||||
wxString reference = e.name;
|
||||
|
||||
// EAGLE allows references to be single digits. This breaks KiCad
|
||||
// netlisting, which requires parts to have non-digit + digit
|
||||
// annotation. If the reference begins with a number, we prepend
|
||||
// 'UNK' (unknown) for the symbol designator.
|
||||
if( reference.find_first_not_of( "0123456789" ) != 0 )
|
||||
reference.Prepend( "UNK" );
|
||||
|
||||
// EAGLE allows designator to start with # but that is used in KiCad
|
||||
// for symbols which do not have a footprint
|
||||
if( reference.find_first_not_of( "#" ) != 0 )
|
||||
reference.Prepend( "UNK" );
|
||||
|
||||
// reference must end with a number but EAGLE does not enforce this
|
||||
if( reference.find_last_not_of( "0123456789" ) == (reference.Length()-1) )
|
||||
reference.Append( "0" );
|
||||
|
||||
footprint->SetReference( reference );
|
||||
footprint->SetValue( FROM_UTF8( e.value.c_str() ) );
|
||||
|
||||
if( !e.smashed )
|
||||
|
@ -1256,17 +1274,7 @@ void EAGLE_PLUGIN::loadElements( wxXmlNode* aElements )
|
|||
{
|
||||
case EATTR::VALUE :
|
||||
{
|
||||
wxString reference = e.name;
|
||||
|
||||
// EAGLE allows references to be single digits. This breaks KiCad
|
||||
// netlisting, which requires parts to have non-digit + digit
|
||||
// annotation. If the reference begins with a number, we prepend
|
||||
// 'UNK' (unknown) for the symbol designator.
|
||||
if( reference.find_first_not_of( "0123456789" ) == wxString::npos )
|
||||
reference.Prepend( wxT( "UNK" ) );
|
||||
|
||||
nameAttr->name = reference;
|
||||
footprint->SetReference( reference );
|
||||
|
||||
if( refanceNamePresetInPackageLayout )
|
||||
footprint->Reference().SetVisible( true );
|
||||
|
|
Loading…
Reference in New Issue