Code: Select all
import BOPTools.SplitFeatures
active = App.ActiveDocument
sphere = active.addObject("Part::Sphere", "Sphere")
sphere.Radius = 20 * App.Units.MilliMetre
sphere.Angle1 = 30 * App.Units.Degree
inner = active.addObject("Part::Sphere", "Sphere")
inner.Radius = 18 * App.Units.MilliMetre
cut = active.addObject("Part::Cut", "Cut")
cut.Base = sphere
cut.Tool = inner
cyl = active.addObject("Part::Cylinder", "Cylinder")
cyl.Radius = 10 * App.Units.MilliMetre
cyl.Height = 25 * App.Units.MilliMetre
cyl.Placement = App.Placement(App.Vector(0, 0, 0), App.Rotation(App.Vector(0, 1, 0), -20 * App.Units.Degree))
sph_sec = active.addObject("Part::Section", "Section")
sph_sec.Base = cut
sph_sec.Tool = cyl
fragment = BOPTools.SplitFeatures.makeBooleanFragments(name='BooleanFragments')
fragment.Objects = [cut, sph_sec]
fragment.Mode = 'Standard'
fragment.Proxy.execute(fragment) # <-- Line 34
fragment.purgeTouched()
for obj in fragment.ViewObject.Proxy.claimChildren():
obj.ViewObject.hide()
However it fails with this error message:
Code: Select all
08:29:18 Traceback (most recent call last):
File "/home/reox/.FreeCAD/Macro/baztest.FCMacro", line 34, in <module>
fragment.Proxy.execute(fragment)
File "/tmp/.mount_FreeCADMFQ6K/usr/Mod/Part/BOPTools/SplitFeatures.py", line 93, in execute
selfobj.Shape = SplitAPI.booleanFragments(shapes, selfobj.Mode, selfobj.Tolerance)
File "/tmp/.mount_FreeCADMFQ6K/usr/Mod/Part/BOPTools/SplitAPI.py", line 45, in booleanFragments
pieces, map = list_of_shapes[0].generalFuse(list_of_shapes[1:], tolerance)
<class 'Part.OCCError'>: Base shape is null
Code: Select all
>>> ### Begin command Part_BooleanFragments
>>> j = BOPTools.SplitFeatures.makeBooleanFragments(name='BooleanFragments')
>>> j.Objects = [App.ActiveDocument.Cut, App.ActiveDocument.Section]
>>> j.Mode = 'Standard'
>>> j.Proxy.execute(j)
>>> j.purgeTouched()
>>> for obj in j.ViewObject.Proxy.claimChildren():
>>> obj.ViewObject.hide()
>>> ### End command Part_BooleanFragments
Code: Select all
OS: CentOS Linux 7 (Core) (XFCE/xfce)
Word size of OS: 64-bit
Word size of FreeCAD: 64-bit
Version: 0.19.24291 (Git) AppImage
Build type: Release
Branch: (HEAD detached at 0.19.2)
Hash: 7b5e18a0759de778b74d3a5c17eba9cb815035ac
Python version: 3.8.8
Qt version: 5.12.9
Coin version: 4.0.0
OCC version: 7.4.0
Locale: German/Germany (de_DE)