[STEP] Export multiple items under one product

Hello,

I'm trying to export multiple elements (points, curves, surfaces) with a single product in the file, but I'm having trouble to achieve it.
This type of hierarchy is possible since I have a sample file, saved by 3DExperience, that has this specific structure.
I can read the target file and re-export it with the desired structure, so OCC can handle this type of configuration because the file can be rewritten with the target structure from a TDocStd_Document created when reading the target step file.

However, I can't create this structure from scratch then populate it with elements since I always get more than one product according to the STEP File Analyzer and Viewer. Do you have any ideas on how to do this ?
I'm using version 7.6 in C++ or 7.7 via Python binding.

Attachments in the step_files.7z
current_structure: as many products as elements => KO
target_structure.stp: a product under which all the elements are located => OK

Thanks for your help,
Magnum

Attachments: 
Le Pharaon's picture

Yeah, that’s a known quirk in OpenCascade — by default, it creates one product per shape unless you explicitly manage the assembly hierarchy. To get a single product grouping all your points, curves, and surfaces: 1. Create one root product via XCAFDoc_DocumentTool ShapeTool. 2. Add all your shapes under that root with AddComponent. 3. Export using the same TDocStd_Document through STEPCAFControl_Writer Transfer and writer.Write. Example: cpp Handle TDocStd_Document)doc Handle XCAFDoc_ShapeTool shapeTool  XCAFDoc_DocumentTool ShapeTool doc->Main TDF_Label root = shapeTool->NewShape // single root product for auto shape : shapes shapeTool->AddComponent root, shape STEPCAFControl_Writer writer; writer.Transfer(doc, STEPControl_AsIs); writer.Write("combined.stp"); That’ll give you a single product in the STEP hierarchy — like the 3DExperience file you mentioned. https://dev.opencascade.org/doc/occt-7.7.0/refman/html/class_s_t_e_p_c_a...,

gkv311 n's picture

Le Pharaon wrote:

here’s the same short Reddit-style reply

This forum supports Markdown and BBCode syntax - please use them (make sure to pick formatter in message editor).