diff --git a/src/Mod/Part/CompoundTools/Explode.py b/src/Mod/Part/CompoundTools/Explode.py index 11fb6fc25f..000393afc6 100644 --- a/src/Mod/Part/CompoundTools/Explode.py +++ b/src/Mod/Part/CompoundTools/Explode.py @@ -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 diff --git a/src/Mod/Part/CompoundTools/_CommandExplodeCompound.py b/src/Mod/Part/CompoundTools/_CommandExplodeCompound.py index 11afd7fa15..4b1dfe8946 100644 --- a/src/Mod/Part/CompoundTools/_CommandExplodeCompound.py +++ b/src/Mod/Part/CompoundTools/_CommandExplodeCompound.py @@ -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()")