LTspice import: don't try loading .asc files for non-subsheets.
Subsheets don't have "Prefix" attribute, components do.
This commit is contained in:
parent
ab4535f01b
commit
a5ba9ccce2
|
@ -75,6 +75,16 @@ void LTSPICE_SCHEMATIC::Load( SCHEMATIC* aSchematic, SCH_SHEET* aRootSheet,
|
|||
} );
|
||||
|
||||
for( LTSPICE_FILE& newSubSchematicElement : newSubSchematicElements )
|
||||
{
|
||||
wxString asyName = newSubSchematicElement.ElementName;
|
||||
auto it = mapOfAsyFiles.find( asyName );
|
||||
|
||||
if( it == mapOfAsyFiles.end() )
|
||||
continue;
|
||||
|
||||
wxString asyBuffer = SafeReadFile( it->second, "r" );
|
||||
|
||||
if( IsAsySubsheet( asyBuffer ) )
|
||||
{
|
||||
newSubSchematicElement.ParentIndex = parentSheetIndex;
|
||||
newSubSchematicElement.Screen = screen;
|
||||
|
@ -83,6 +93,7 @@ void LTSPICE_SCHEMATIC::Load( SCHEMATIC* aSchematic, SCH_SHEET* aRootSheet,
|
|||
ascFileQueue.push( newSubSchematicElement.ElementName );
|
||||
ascFiles.push_back( newSubSchematicElement );
|
||||
}
|
||||
}
|
||||
|
||||
ascFileQueue.pop();
|
||||
|
||||
|
@ -264,6 +275,25 @@ std::vector<LTSPICE_FILE> LTSPICE_SCHEMATIC::GetSchematicElements( const wxStrin
|
|||
}
|
||||
|
||||
|
||||
bool LTSPICE_SCHEMATIC::IsAsySubsheet( const wxString& aAsyFile )
|
||||
{
|
||||
wxStringTokenizer lines( aAsyFile, "\n" );
|
||||
|
||||
while( lines.HasMoreTokens() )
|
||||
{
|
||||
wxStringTokenizer parts( lines.GetNextToken(), " " );
|
||||
|
||||
if( parts.GetNextToken().IsSameAs( wxS( "SYMATTR" ), false )
|
||||
&& parts.GetNextToken().IsSameAs( wxS( "Prefix" ), false ) )
|
||||
{
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
int LTSPICE_SCHEMATIC::integerCheck( const wxString& aToken, int aLineNumber,
|
||||
const wxString& aFileName )
|
||||
{
|
||||
|
|
|
@ -314,6 +314,13 @@ public:
|
|||
*/
|
||||
std::vector<LTSPICE_FILE> GetSchematicElements( const wxString& aAscFile );
|
||||
|
||||
/**
|
||||
* Check if the asy file content indicates that we need to load subsheet.
|
||||
*
|
||||
* @param aAsyFile contents of .asy file.
|
||||
*/
|
||||
bool IsAsySubsheet( const wxString& aAsyFile );
|
||||
|
||||
/**
|
||||
* The function returns a map. This map has all the asy files in form of string. For asy files
|
||||
* the key will be symbol name.
|
||||
|
|
Loading…
Reference in New Issue