kicad2step: provide a basic default product name

It would be ideal if it would use the s-expr
kicad_pcb.general.title_block.title by default, and then fall back to
something based on the output step file, but even just the output step
file is a far better default than the "open cascade step translator
version..." text it uses at the moment.

Similar improvements using the title_block would be future work.

Signed-off-by: Karl Palsson <karlp@etactica.com>
This commit is contained in:
Karl Palsson 2021-03-03 14:26:20 +00:00 committed by jean-pierre charras
parent d18afa42cd
commit 658bc2f4b2
1 changed files with 11 additions and 1 deletions

View File

@ -914,16 +914,26 @@ bool PCBMODEL::WriteSTEP( const wxString& aFileName )
ReportMessage( wxString::Format( "No valid PCB assembly; cannot create output file %s\n", aFileName ) );
return false;
}
wxFileName fn( aFileName );
STEPCAFControl_Writer writer;
writer.SetColorMode( Standard_True );
writer.SetNameMode( Standard_True );
// This must be set before we "transfer" the document.
// Should default to kicad_pcb.general.title_block.title,
// but in the meantime, defaulting to the basename of the output
// target is still better than "open cascade step translter v..."
// UTF8 should be ok from ISO 10303-21:2016, but... older stuff? use boring ascii
if( !Interface_Static::SetCVal("write.step.product.name", fn.GetName().ToAscii()) ) {
wxString s("Failed to set step product name, but will attempt to continue");
ReportMessage(s);
}
if( Standard_False == writer.Transfer( m_doc, STEPControl_AsIs ) )
return false;
APIHeaderSection_MakeHeader hdr( writer.ChangeWriter().Model() );
wxFileName fn( aFileName );
// Note: use only Ascii7 chars, non Ascii7 chars (therefore UFT8 chars)
// are creating issues in the step file
hdr.SetName( new TCollection_HAsciiString( fn.GetFullName().ToAscii() ) );