Ejemplo n.º 1
0
    def test_write_step_file(self):
        ''' Exports a colored box into a STEP file '''
        ### initialisation
        h_doc = Handle_TDocStd_Document()
        assert (h_doc.IsNull())
        # Create the application
        app = XCAFApp_Application.GetApplication().GetObject()
        app.NewDocument(TCollection_ExtendedString("MDTV-CAF"), h_doc)
        # Get root assembly
        doc = h_doc.GetObject()
        h_shape_tool = XCAFDoc_DocumentTool_ShapeTool(doc.Main())
        l_Colors = XCAFDoc_DocumentTool_ColorTool(doc.Main())
        shape_tool = h_shape_tool.GetObject()
        colors = l_Colors.GetObject()
        ### create the shape to export
        test_shape = BRepPrimAPI_MakeBox(100., 100., 100.).Shape()

        ### add shape
        shp_label = shape_tool.AddShape(test_shape)
        ### set a color for this shape
        r = 1
        g = b = 0.5
        red_color = Quantity_Color(r, g, b, 0)
        colors.SetColor(shp_label, red_color, XCAFDoc_ColorGen)
        # write file
        WS = XSControl_WorkSession()
        writer = STEPCAFControl_Writer(WS.GetHandle(), False)
        writer.Transfer(h_doc, STEPControl_AsIs)
        status = writer.Write("./test_io/test_ocaf_generated.stp")
        assert status
        assert os.path.isfile("./test_io/test_ocaf_generated.stp")
Ejemplo n.º 2
0
 def test_create_app(self):
     ''' Creates an OCAF app and an empty document '''
     # create an handle to a document
     h_doc = Handle_TDocStd_Document()
     assert (h_doc.IsNull())
     # Create the application
     app = XCAFApp_Application.GetApplication().GetObject()
     app.NewDocument(TCollection_ExtendedString("MDTV-CAF"), h_doc)