Write STEP file

Hello,

I wrote a STEP file using STEPCAFControl_Writer. I organized the structure in assemblies and component and gave a name for each (using TDataStd_Name on TDF_Label of added component for example). My problem is that Catia seems recognize this name as a comment and not as identifiant. It is visible in the file for each NEXT_ASSEMBLY_USAGE_OCCURENCE where the first argument the identifiant and the second is the name. In the STEP format, theses 2 arguments are strings. When I wrote the file, I found the given name in the secong argument but I found an number in the first one. I would like to give the name in this first argument.

How can I do that ? I read doc that makes me think that I must use SHUO API but I didn't understand how to use and there is nothing about that on the forum. It is the right way to modify the identifiant and how can I use this API ?

Thanh in advance

Bruno

bh's picture

Hello,

I found a way to replace identifiant but I need to make a second loop in the model once the data transfered. Here is my code :

STEPCAFControl_Writer m_writer;
Handle(XCAFDoc_ShapeTool) m_shapeTool;
Handle(TDocStd_Document) m_ExportedDoc;

Handle(AppStd_Application) app;
app->NewDocument("XmlOcaf", m_ExportedDoc);
m_shapeTool = XCAFDoc_DocumentTool::ShapeTool(m_ExportedDoc->Main());
m_writer.Init(m_writer.Writer().WS(),Standard_False);

m_shapeTool = XCAFDoc_DocumentTool::ShapeTool(m_ExportedDoc->Main());
m_writer.Init(m_writer.Writer().WS(),Standard_False);
m_writer.SetNameMode(true);

m_writer.Transfer(m_ExportedDoc, STEPControl_AsIs);
STEPControl_Writer sw = m_writer.Writer();
Handle(StepData_StepModel) stpDataModel = sw.Model();

for (int i=1; i<=stpDataModel->NbEntities(); i++)
{
Handle(Standard_Transient) e = stpDataModel->Entity(i);
if (strcmp ((e->DynamicType())->Name(),"StepRepr_NextAssemblyUsageOccurrence") == 0)
{
Handle(StepRepr_NextAssemblyUsageOccurrence) nauo = Handle(StepRepr_NextAssemblyUsageOccurrence)::DownCast(e);
Handle(TCollection_HAsciiString) newid = new TCollection_HAsciiString(nauo->Name());
nauo->SetId(newid);
}
}