Darn. I meant this to go to the list. Sorry Thomas. -------- Forwarded Message -------- > You have here a strong conflict > (complexity/granularity) that can, as far is I know and from what I've > seen, be simply solved by this way: > - the assembly is a simple XML file that contain pointers to other CAD > files and an absolute 3x4 position matrix, > - store the CAD files and the XML in your PDM system, > - generate the 'assembly view' on the fly whenever requested.
This is more-or-less what I was after. After some quality time spent with the OCC user manuals, and also with the help your XCAF demo, I've figured out that XDE/XCAF does indeed do what I want. I'm trying to create a (STEP) document in which I insert some shapes (each defined according to their own local coords), then position these shapes in the global coords to form an assembly. Adding some color is also nice. I don't need fancy (SolidWorks style) "mating" functionality. I've attached my working example, in case it's useful to others. > At last, if one really wants to be rigourous, follow the STEP PDM Schema > 1.2 specifications: > http://www.steptools.com/support/stdev_docs/express/pdm/pdmug_release4_3.pdf > . This document is a master piece, in my opinion the best ever written > about assemblies (and a lot more things), that everyone should read once! I'm looking at this. It may take me a while to digest... thanks for the comments. Bryan
from OCC import XCAFApp, STEPCAFControl, TDocStd, TCollection,\ XCAFDoc, BRepPrimAPI, Quantity, STEPControl,\ TopLoc, gp # # Create the TDocStd document # h_doc = TDocStd.Handle_TDocStd_Document() print "Empty Doc?", h_doc.IsNull() # # Create the application # app = XCAFApp.GetApplication().GetObject() app.NewDocument(TCollection.TCollection_ExtendedString("MDTV-CAF"),h_doc) # # Get root assembly # doc = h_doc.GetObject() h_shape_tool = XCAFDoc.XCAFDoc_DocumentTool().ShapeTool(doc.Main()) l_Colors = XCAFDoc.XCAFDoc_DocumentTool().ColorTool(doc.Main()) shape_tool = h_shape_tool.GetObject() colors = l_Colors.GetObject() top_label = shape_tool.NewShape() #this is the "root" label for the assembly print "Is Assembly", shape_tool.IsAssembly(top_label) #not yet, 'cos it's empty # #Add some shapes # box = BRepPrimAPI.BRepPrimAPI_MakeBox(10,20,30).Shape() box_label = shape_tool.AddShape(box, False) cyl = BRepPrimAPI.BRepPrimAPI_MakeCylinder(25,50).Shape() cyl_label = shape_tool.AddShape(cyl, False) # #Add components as references to our shape # tr = gp.gp_Trsf() tr.SetTranslation(gp.gp_Vec(100,100,100)) loc = TopLoc.TopLoc_Location(tr) box_comp1 = shape_tool.AddComponent(top_label, box_label, loc) tr = gp.gp_Trsf() tr.SetTranslation(gp.gp_Vec(200,200,200)) loc = TopLoc.TopLoc_Location(tr) box_comp2 = shape_tool.AddComponent(top_label, box_label, loc) tr = gp.gp_Trsf() tr.SetTranslation(gp.gp_Vec(150,200,100)) loc = TopLoc.TopLoc_Location(tr) cyl_comp = shape_tool.AddComponent(top_label, cyl_label, loc) print "Is Assembly", shape_tool.IsAssembly(top_label) #it is now... # #Add some colors # red = Quantity.Quantity_Color(Quantity.Quantity_NOC_RED) green = Quantity.Quantity_Color(Quantity.Quantity_NOC_GREEN) colors.SetColor(cyl_comp, red, XCAFDoc.XCAFDoc_ColorGen) colors.SetColor(box_comp2, green, XCAFDoc.XCAFDoc_ColorGen) mode = STEPControl.STEPControl_AsIs writer = STEPCAFControl.STEPCAFControl_Writer() writer.Transfer(h_doc, mode) writer.Write("XDE_test.step")
_______________________________________________ Pythonocc-users mailing list Pythonocc-users@gna.org https://mail.gna.org/listinfo/pythonocc-users