XDE / XCAF document header data

How do I set the document metadata attributes (author, organisation etc.) for STEP export of an XDE / XCAF document? (I know about APIHeaderSection for simple STEP export, but I can't see how to use this with a STEPCAFController).

Volker's picture

STEPControl_StepModelType mode = STEPControl_AsIs;
STEPCAFControl_Writer writer;

Interface_Static::SetCVal("write.step.schema", "AP214IS");
Interface_Static::SetCVal("write.step.product.name", "productInfo" );

// configure STEP interface
writer.SetColorMode(Standard_True);
writer.SetLayerMode(Standard_True);
writer.SetNameMode (Standard_True);

// Translating document (conversion) to STEP
if ( !writer.Transfer ( aDoc, mode ) ) {
cerr << "The document cannot be translated or gives no result" << endl;
return Standard_False;
}

// edit STEP header
APIHeaderSection_MakeHeader makeHeader(writer.Writer().Model());

Handle(TCollection_HAsciiString) headerFileName = new TCollection_HAsciiString("filename");
Handle(TCollection_HAsciiString) headerAuthor = new TCollection_HAsciiString("Volker");
Handle(TCollection_HAsciiString) headerOrganization = new TCollection_HAsciiString("myCompanyName");
Handle(TCollection_HAsciiString) headerOriginatingSystem = new TCollection_HAsciiString("myApplicationName");
Handle(TCollection_HAsciiString) fileDescription = new TCollection_HAsciiString("myApplication Model");

makeHeader.SetName(headerFileName);
makeHeader.SetAuthorValue (1, headerAuthor);
makeHeader.SetOrganizationValue (1, headerOrganization);
makeHeader.SetOriginatingSystem(headerOriginatingSystem);
makeHeader.SetDescriptionValue(1, fileDescription);

// Writing the File
IFSelect_ReturnStatus stat = writer.Write(fname);
if (stat!=IFSelect_RetDone) ok = Standard_False;

bryancole's picture

Wow! Thanks for the explicit example.

The key thing I had missed was the 'writer.Writer()' method.