def test_read_step_file(self): ''' Reads the previous step file ''' # create an handle to a document doc = TDocStd_Document(TCollection_ExtendedString("pythonocc-doc")) # Get root assembly shape_tool = XCAFDoc_DocumentTool_ShapeTool(doc.Main()) l_colors = XCAFDoc_DocumentTool_ColorTool(doc.Main()) step_reader = STEPCAFControl_Reader() step_reader.SetColorMode(True) step_reader.SetLayerMode(True) step_reader.SetNameMode(True) step_reader.SetMatMode(True) status = step_reader.ReadFile("./test_io/test_ocaf.stp") if status == IFSelect_RetDone: step_reader.Transfer(doc) labels = TDF_LabelSequence() color_labels = TDF_LabelSequence() shape_tool.GetFreeShapes(labels) self.assertEqual(labels.Length(), 1) sub_shapes_labels = TDF_LabelSequence() self.assertFalse(shape_tool.IsAssembly(labels.Value(1))) shape_tool.GetSubShapes(labels.Value(1), sub_shapes_labels) self.assertEqual(sub_shapes_labels.Length(), 0) l_colors.GetColors(color_labels) self.assertEqual(color_labels.Length(), 1) label_shp = labels.Value(1) a_shape = shape_tool.GetShape(label_shp) self.assertFalse(a_shape.IsNull())
step_reader.SetMatMode(True) status = step_reader.ReadFile(filename) if status == IFSelect_RetDone: step_reader.Transfer(doc) labels = TDF_LabelSequence() color_labels = TDF_LabelSequence() shape_tool.GetFreeShapes(labels) print("Number of shapes at root :%i" % labels.Length()) for i in range(labels.Length()): sub_shapes_labels = TDF_LabelSequence() print("Is Assembly :", shape_tool.IsAssembly(labels.Value(i + 1))) sub_shapes = shape_tool.GetSubShapes(labels.Value(i + 1), sub_shapes_labels) print("Number of subshapes in the assemly :%i" % sub_shapes_labels.Length()) l_colors.GetColors(color_labels) print("Number of colors=%i" % color_labels.Length()) for i in range(color_labels.Length()): color = color_labels.Value(i + 1) print(color.DumpToString()) for i in range(labels.Length()): label = labels.Value(i + 1) a_shape = shape_tool.GetShape(label) m = l_layers.GetLayers(a_shape) _shapes.append(a_shape)