Part: Check geometry in Part_ExplodeCompound command

This commit is contained in:
marioalexis
2022-03-09 00:43:53 -03:00
committed by wwmayer
parent d1fc159f4c
commit 8723f0b96d
2 changed files with 12 additions and 3 deletions

View File

@@ -1,10 +1,19 @@
import FreeCAD
import Part
from .CompoundFilter import makeCompoundFilter
def explodeCompound(compound_obj, b_group = None):
"""explodeCompound(compound_obj, b_group = None): creates a bunch of compound filters, to extract every child of a compound into a separate object.
group: if True, Group is always made. If False, group is never made. If None, group is made if there is more than one child.
returns: (group_object, list_of_child_objects)"""
sh = compound_obj.Shape
if (isinstance(compound_obj, FreeCAD.GeoFeature) and
isinstance(compound_obj.getPropertyOfGeometry(), Part.Shape)):
sh = compound_obj.getPropertyOfGeometry()
else:
raise TypeError("Object must be App.GeoFeature with Part.Shape property")
n = len(sh.childShapes(False,False))
if b_group is None:
b_group = n > 1

View File

@@ -93,9 +93,9 @@ def cmdExplode():
FreeCADGui.doCommand("input_obj = App.ActiveDocument."+obj.Name)
FreeCADGui.doCommand("CompoundTools.Explode.explodeCompound(input_obj)")
FreeCADGui.doCommand("input_obj.ViewObject.hide()")
except Exception:
except Exception as ex:
FreeCAD.ActiveDocument.abortTransaction()
raise
FreeCAD.Console.PrintError("{}\n".format(ex))
FreeCAD.ActiveDocument.commitTransaction()
FreeCADGui.doCommand("App.ActiveDocument.recompute()")