diff --git a/common/plugins/altium/altium_parser.cpp b/common/plugins/altium/altium_parser.cpp index 1986efffb3..a6bc4f7568 100644 --- a/common/plugins/altium/altium_parser.cpp +++ b/common/plugins/altium/altium_parser.cpp @@ -113,9 +113,8 @@ std::map ALTIUM_PARSER::ReadProperties() if( !hasNullByte ) { - wxLogError( _( "For Altium import, we assumes a null byte at the end of a list of " - "properties. Because this is missing, imported data might be malformed or " - "missing." ) ); + wxLogError( _( "Missing null byte at end of property list. Imported data might be " + "malformed or missing." ) ); } // we use std::string because std::string can handle NULL-bytes diff --git a/eeschema/files-io.cpp b/eeschema/files-io.cpp index 8a22092f54..7ffbc3986c 100644 --- a/eeschema/files-io.cpp +++ b/eeschema/files-io.cpp @@ -251,7 +251,7 @@ bool SCH_EDIT_FRAME::OpenProjectFiles( const std::vector& aFileSet, in // implement the pseudo code from KIWAY_PLAYER.h: wxString msg; - auto cfg = dynamic_cast( Kiface().KifaceSettings() ); + EESCHEMA_SETTINGS* cfg = dynamic_cast( Kiface().KifaceSettings() ); // This is for python: if( aFileSet.size() != 1 ) diff --git a/pcbnew/plugins/altium/altium_pcb.cpp b/pcbnew/plugins/altium/altium_pcb.cpp index a9a05f7d27..e855ea0cab 100644 --- a/pcbnew/plugins/altium/altium_pcb.cpp +++ b/pcbnew/plugins/altium/altium_pcb.cpp @@ -1258,9 +1258,7 @@ void ALTIUM_PCB::ParseModelsData( const CFB::CompoundFileReader& aReader, ALTIUM_PARSER reader( aReader, aEntry ); if( reader.GetRemainingBytes() == 0 ) - { - return; // fast path: no 3d-models present which need to be imported -> no directory needs to be created - } + return; wxString projectPath = wxPathOnly( m_board->GetFileName() ); // TODO: set KIPRJMOD always after import (not only when loading project)? @@ -1271,6 +1269,7 @@ void ALTIUM_PCB::ParseModelsData( const CFB::CompoundFileReader& aReader, wxFileName altiumModelsPath = wxFileName::DirName( projectPath ); wxString kicadModelPrefix = "${KIPRJMOD}/" + altiumModelDir + "/"; + if( !altiumModelsPath.AppendDir( altiumModelDir ) ) { THROW_IO_ERROR( "Cannot construct directory path for step models" ); @@ -1281,21 +1280,28 @@ void ALTIUM_PCB::ParseModelsData( const CFB::CompoundFileReader& aReader, { if( !altiumModelsPath.Mkdir() ) { - wxLogError( _( "Failed to create folder '%s'." ) + _( "No 3D-models will be imported." ), + wxLogError( _( "Failed to create folder '%s'." ) + wxS( " " ) + + _( "No 3D-models will be imported." ), altiumModelsPath.GetFullPath() ); return; } } int idx = 0; + while( reader.GetRemainingBytes() >= 4 /* TODO: use Header section of file */ ) { checkpoint(); AMODEL elem( reader ); - wxString stepPath = aRootDir + std::to_string( idx++ ); + wxString stepPath = wxString::Format( aRootDir + "%d", idx ); + wxString storageName = elem.name.IsEmpty() ? wxString::Format( "%d", idx ) : elem.name; + wxFileName storagePath( altiumModelsPath.GetPath(), storageName ); + + idx++; const CFB::COMPOUND_FILE_ENTRY* stepEntry = FindStream( aReader, stepPath.c_str() ); + if( stepEntry == nullptr ) { wxLogError( _( "File not found: '%s'. 3D-model not imported." ), stepPath ); @@ -1308,8 +1314,6 @@ void ALTIUM_PCB::ParseModelsData( const CFB::CompoundFileReader& aReader, // read file into buffer aReader.ReadFile( stepEntry, 0, stepContent.get(), stepSize ); - wxFileName storagePath( altiumModelsPath.GetPath(), elem.name ); - if( !storagePath.IsDirWritable() ) { wxLogError( _( "Insufficient permissions to save file '%s'." ),