Draft: Improved behaviour of Clone tool when dealing with Arch objects
This commit is contained in:
parent
5d0bc520b9
commit
fbbc9e21a9
|
@ -247,6 +247,9 @@ def isClone(obj,objtype,recursive=False):
|
||||||
return True
|
return True
|
||||||
elif recursive and (getType(obj.Objects[0]) == "Clone"):
|
elif recursive and (getType(obj.Objects[0]) == "Clone"):
|
||||||
return isClone(obj.Objects[0],objtype,recursive)
|
return isClone(obj.Objects[0],objtype,recursive)
|
||||||
|
elif hasattr(obj,"CloneOf"):
|
||||||
|
if obj.CloneOf:
|
||||||
|
return True
|
||||||
return False
|
return False
|
||||||
|
|
||||||
def getGroupNames():
|
def getGroupNames():
|
||||||
|
@ -2430,12 +2433,13 @@ def clone(obj,delta=None):
|
||||||
if (len(obj) == 1) and obj[0].isDerivedFrom("Part::Part2DObject"):
|
if (len(obj) == 1) and obj[0].isDerivedFrom("Part::Part2DObject"):
|
||||||
cl = FreeCAD.ActiveDocument.addObject("Part::Part2DObjectPython","Clone2D")
|
cl = FreeCAD.ActiveDocument.addObject("Part::Part2DObjectPython","Clone2D")
|
||||||
cl.Label = "Clone of " + obj[0].Label + " (2D)"
|
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
|
# arch objects can be clones
|
||||||
import Arch
|
import Arch
|
||||||
cl = getattr(Arch,"make"+obj[0].Proxy.Type)()
|
cl = getattr(Arch,"make"+obj[0].Proxy.Type)()
|
||||||
cl.Label = "Clone of " + obj[0].Label
|
base = getCloneBase(obj[0])
|
||||||
cl.CloneOf = obj[0]
|
cl.Label = "Clone of " + base.Label
|
||||||
|
cl.CloneOf = base
|
||||||
return cl
|
return cl
|
||||||
else:
|
else:
|
||||||
cl = FreeCAD.ActiveDocument.addObject("Part::FeaturePython","Clone")
|
cl = FreeCAD.ActiveDocument.addObject("Part::FeaturePython","Clone")
|
||||||
|
@ -2448,6 +2452,16 @@ def clone(obj,delta=None):
|
||||||
cl.Placement.move(delta)
|
cl.Placement.move(delta)
|
||||||
formatObject(cl,obj[0])
|
formatObject(cl,obj[0])
|
||||||
return cl
|
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):
|
def heal(objlist=None,delete=True,reparent=True):
|
||||||
'''heal([objlist],[delete],[reparent]) - recreates Draft objects that are damaged,
|
'''heal([objlist],[delete],[reparent]) - recreates Draft objects that are damaged,
|
||||||
|
|
Loading…
Reference in New Issue
Block a user