diff --git a/src/Mod/Draft/Draft.py b/src/Mod/Draft/Draft.py index 834586a9c3..89b2298d7a 100644 --- a/src/Mod/Draft/Draft.py +++ b/src/Mod/Draft/Draft.py @@ -247,6 +247,9 @@ def isClone(obj,objtype,recursive=False): return True elif recursive and (getType(obj.Objects[0]) == "Clone"): return isClone(obj.Objects[0],objtype,recursive) + elif hasattr(obj,"CloneOf"): + if obj.CloneOf: + return True return False def getGroupNames(): @@ -2430,12 +2433,13 @@ def clone(obj,delta=None): if (len(obj) == 1) and obj[0].isDerivedFrom("Part::Part2DObject"): cl = FreeCAD.ActiveDocument.addObject("Part::Part2DObjectPython","Clone2D") cl.Label = "Clone of " + obj[0].Label + " (2D)" - elif (len(obj) == 1) and hasattr(obj[0],"IfcAttributes"): + elif (len(obj) == 1) and hasattr(obj[0],"CloneOf"): # arch objects can be clones import Arch cl = getattr(Arch,"make"+obj[0].Proxy.Type)() - cl.Label = "Clone of " + obj[0].Label - cl.CloneOf = obj[0] + base = getCloneBase(obj[0]) + cl.Label = "Clone of " + base.Label + cl.CloneOf = base return cl else: cl = FreeCAD.ActiveDocument.addObject("Part::FeaturePython","Clone") @@ -2448,6 +2452,16 @@ def clone(obj,delta=None): cl.Placement.move(delta) formatObject(cl,obj[0]) return cl + +def getCloneBase(obj): + '''getCloneBase(obj): returns the object cloned by this object, if + any, or this object if it is no clone''' + if hasattr(obj,"CloneOf"): + if obj.CloneOf: + return getCloneBase(obj.CloneOf) + if getType(obj) == "Clone": + return obj.Objects[0] + return obj def heal(objlist=None,delete=True,reparent=True): '''heal([objlist],[delete],[reparent]) - recreates Draft objects that are damaged,