Give the board boards unique names in STEP exports

This commit is contained in:
Marek Roszko 2021-09-12 17:41:18 -04:00
parent 558ba855a2
commit 4f861e084d
5 changed files with 32 additions and 6 deletions

View File

@ -160,7 +160,7 @@ int PANEL_KICAD2STEP::RunConverter()
}
wxString outfile = out_fname.GetFullPath();
KICADPCB pcb;
KICADPCB pcb( fname.GetName() );
pcb.SetOrigin( m_params.m_xOrigin, m_params.m_yOrigin );
pcb.SetMinDistance( m_params.m_minDistance );

View File

@ -42,7 +42,7 @@
KICADPCB::KICADPCB()
KICADPCB::KICADPCB( const wxString& aPcbName )
{
m_resolver.Set3DConfigDir( "" );
m_thickness = 1.6;
@ -52,6 +52,7 @@ KICADPCB::KICADPCB()
m_useDrillOrigin = false;
m_hasGridOrigin = false;
m_hasDrillOrigin = false;
m_pcbName = aPcbName;
}
@ -477,7 +478,7 @@ bool KICADPCB::ComposePCB( bool aComposeVirtual, bool aSubstituteModels )
origin = m_origin;
}
m_pcb_model = new PCBMODEL();
m_pcb_model = new PCBMODEL( m_pcbName );
m_pcb_model->SetPCBThickness( m_thickness );
m_pcb_model->SetMinDistance( m_minDistance );

View File

@ -54,7 +54,7 @@ class PCBMODEL;
class KICADPCB
{
public:
KICADPCB();
KICADPCB( const wxString& aPcbName );
virtual ~KICADPCB();
int GetLayerId( std::string& aLayerName );
@ -121,6 +121,7 @@ private:
double m_thickness;
std::vector<KICADFOOTPRINT*> m_footprints;
std::vector<KICADCURVE*> m_curves;
wxString m_pcbName;
};

View File

@ -52,9 +52,11 @@
#include <Standard_Version.hxx>
#include <TCollection_ExtendedString.hxx>
#include <TDataStd_Name.hxx>
#include <TDataStd_TreeNode.hxx>
#include <TDF_LabelSequence.hxx>
#include <TDF_ChildIterator.hxx>
#include <TopExp_Explorer.hxx>
#include <XCAFDoc.hxx>
#include <XCAFDoc_DocumentTool.hxx>
#include <XCAFDoc_ColorTool.hxx>
@ -240,7 +242,7 @@ FormatType fileType( const char* aFileName )
}
PCBMODEL::PCBMODEL()
PCBMODEL::PCBMODEL( const wxString& aPcbName )
{
m_app = XCAFApp_Application::GetApplication();
m_app->NewDocument( "MDTV-XCAF", m_doc );
@ -254,6 +256,7 @@ PCBMODEL::PCBMODEL()
m_minDistance2 = MIN_LENGTH2;
m_minx = 1.0e10; // absurdly large number; any valid PCB X value will be smaller
m_mincurve = m_curves.end();
m_pcbName = aPcbName;
BRepBuilderAPI::Precision( MIN_DISTANCE );
}
@ -862,6 +865,26 @@ bool PCBMODEL::CreatePCB()
if( m_pcb_label.IsNull() )
return false;
// AddComponent adds a label that has a reference (not a parent/child relation) to the real label
// We need to extract that real label to name it for the STEP output cleanly
// Why are we trying to name the bare board? Because CAD tools like SolidWorks do fun things
// like "deduplicate" imported STEPs by swapping STEP assembly components with already identically named assemblies
// So we want to avoid having the PCB be generally defaulted to "Component" or "Assembly".
Handle( TDataStd_TreeNode ) Node;
if( m_pcb_label.FindAttribute( XCAFDoc::ShapeRefGUID(), Node ) )
{
TDF_Label label = Node->Father()->Label();
if( !label.IsNull() )
{
wxString pcbName = wxString::Format( "%s PCB", m_pcbName );
std::string pcbNameStdString( pcbName.ToUTF8() );
TCollection_ExtendedString partname( pcbNameStdString.c_str() );
TDataStd_Name::Set( label, partname );
}
}
// color the PCB
Handle( XCAFDoc_ColorTool ) color = XCAFDoc_DocumentTool::ColorTool( m_doc->Main () );
Quantity_Color pcb_green( 0.06, 0.4, 0.06, Quantity_TOC_RGB );

View File

@ -86,7 +86,7 @@ private:
class PCBMODEL
{
public:
PCBMODEL();
PCBMODEL( const wxString& aPcbName );
virtual ~PCBMODEL();
// add an outline segment (must be in final position)
@ -165,6 +165,7 @@ private:
std::list<KICADCURVE> m_curves;
std::vector<TopoDS_Shape> m_cutouts;
wxString m_pcbName; // name of the PCB, which will most likely be the file name of the path
};
#endif // OCE_VIS_OCE_UTILS_H