Open
Description
Hello everyone
Following code block create a simple step file with simple compound object. If entities will be added to document item by item layer information can be obtain on the step file like following.
However, after adding them into a compound object layers are not exported. Is this feature is not supported for compound objects?
import OCC.Core.STEPCAFControl as OCC_STEP_XCAF_Control
import OCC.Core.STEPControl as OCC_STEP_Control
import OCC.Core.TDocStd as OCC_Doc_STD
import OCC.Core.TCollection as OCC_Type_Collections
import OCC.Core.XCAFDoc as OCC_XCaf_Doc
import OCC.Core.BRepPrimAPI as OCC_Brep_Prim_API
import OCC.Extend.DataExchange as OCC_Extend_Data_Exchange
import OCC.Core.TDF as OCC_TDF
import OCC.Core.TopoDS as OCC_TopoDS
doc = OCC_Doc_STD.TDocStd_Document(OCC_Type_Collections.TCollection_ExtendedString("pythonocc-doc"))
box_1 = OCC_Brep_Prim_API.BRepPrimAPI_MakeBox(20., 40., 60.).Shape()
box_2 = OCC_Brep_Prim_API.BRepPrimAPI_MakeBox(40., 80., 120.).Shape()
block = OCC_TopoDS.TopoDS_Compound()
shape_handler = OCC_TopoDS.TopoDS_Builder()
shape_handler.MakeCompound(block)
shape_handler.Add(block, box_1)
shape_handler.Add(block, box_2)
shape_tool = OCC_XCaf_Doc.XCAFDoc_DocumentTool_ShapeTool(doc.Main())
layer_tool = OCC_XCaf_Doc.XCAFDoc_DocumentTool_LayerTool(doc.Main())
main_assembly_label = shape_tool.AddShape(block)
layer_name = layer_tool.AddLayer(OCC_Type_Collections.TCollection_ExtendedString("test_layer"))
layer_tool.SetLayer(main_assembly_label, layer_name)
step_writer = OCC_STEP_XCAF_Control.STEPCAFControl_Writer()
step_writer.SetLayerMode(True)
status = step_writer.Transfer(doc, OCC_STEP_Control.STEPControl_AsIs)
if status != OCC_Extend_Data_Exchange.IFSelect_RetDone:
raise AssertionError("load failed")
status = step_writer.Write("test.stp")
if status != OCC_Extend_Data_Exchange.IFSelect_RetDone:
raise Exception('Something bad happened')