I am new to FreeCAD and its python scripting. I need to be able to extract the fragments from two intersecting cubes similar to the following example: https://www.freecadweb.org/wiki/Part_BooleanFragments
I was able to write a small python script that gets me the compound object. And if I export a STEP file, I get the correct 3 bodies https://www.dropbox.com/s/yaysd5m5c7115 ... 0.png?dl=0. The problem is that I do not know how to access and display these same three bodies in FreeCAD. Here is the script so far. I would appreciate enhancements to it if it is not quite right (it does run and gives me the expected two cubes):
Code: Select all
doc = FreeCAD.newDocument('TwoBoxes')
Gui.activeDocument().activeView().viewAxonometric()
b1 = doc.addObject("Part::Box","BOX1")
b2 = doc.addObject("Part::Box","BOX2")
b2.Placement.Base.x = 6
b2.Placement.Base.y = 6
b2.Placement.Base.z = 6
b1.ViewObject.Transparency=50
b2.ViewObject.Transparency=50
boxes = [b1, b2]
bf = Part.BOPTools.SplitFeatures.makeBooleanFragments(name= 'BoolFrag')
bf.Objects = boxes
bf.Mode = 'Standard'
bf.ViewObject.Transparency = 60
doc.recompute()
Gui.SendMsgToActiveView("ViewFit")
Thanks!