|
Menu location |
---|
Part → Split → Boolean fragments |
Workbenches |
Part |
Default shortcut |
None |
Introduced in version |
0.17 |
See also |
Part Slice, Part XOR, Part JoinFeatures, Part Boolean |
The Part BooleanFragments tool computes all fragments that can result from applying Boolean operations between input shapes. For example, for two intersecting spheres, three non-overlapping but touching solids are generated.
In the image above, the pieces were moved apart manually afterwards, to reveal the slicing.
The output shape is always a compound. The content of the compound depends on input shape types and operation mode. That means, you don't immediately get access to individual pieces of the result - the pieces remain grouped together. The individual pieces can be extracted by exploding the compound (Draft Downgrade).
The tool has three modes: "Standard", "Split", and "CompSolid".
"Standard" and "Split" differ by the action of the tool on wires, shells and compsolids. If "Split", those are separated. If "Standard", they are kept together (get extra segments).
Compounding structure in "Standard" and "Split" modes follows the compounding structure of inputs. That is, if you feed in two compounds, each containing a sphere like on example above, the result will also contain two compounds, each containing the pieces of the originally contained sphere. That means, the common piece will be repeated twice in the result. Only if the input spheres are both not in compounds, the result will contain the common piece once.
In "CompSolid" mode, the solids are joined into a compsolid (compsolid is a set of solids connected by faces; they are related to solids like wires are related to edges, and shells are related to faces; the name is probably a shortened phrase "composite solid"). The output is a non-nested compound of compsolids.
Boolean Fragments
Boolean Fragments tool in "Standard mode" is OpenCascade's General Fuse Operator (GFA). It accepts a combination of probably all shape types, and the logic of output is quite convoluted. See OpenCascade user guide: Boolean operations.
For "Split" and "CompSolid" modes, extra post-processing is done by FreeCAD.
The tool can by used in macros and from the python console by using the following function:
BOPTools.SplitFeatures.makeBooleanFragments(name)
BooleanFragments can also be applied to plain shapes, without the need to have a document object, via:
import BOPTools.SplitAPI
BOPTools.SplitAPI.booleanFragments(list_of_shapes, mode, tolerance = 0.0)
# OR, for Standard mode:
list_of_shapes = [App.ActiveDocument.Sphere.Shape, App.ActiveDocument.Sphere001.Shape]
pieces, map = list_of_shapes[0].generalFuse(list_of_shapes[1:], tolerance)
# pieces receives a compound of shapes; map receives a list of lists of shapes, defining list_of_shapes <--> pieces correspondence
This can be useful for making custom Python scripted features.
Example:
import BOPTools.SplitFeatures
j = BOPTools.SplitFeatures.makeBooleanFragments(name= 'BooleanFragments')
j.Objects = FreeCADGui.Selection.getSelection()
The tool itself is implemented in Python, see /Mod/Part/BOPTools/SplitFeatures.py under where FreeCAD is installed.
The tool was introduced in FreeCAD v0.17.8053. FreeCAD needs to be compiled with OCC 6.9.0 or later; otherwise, the tool is unavailable.