Skip to content

Commit

Permalink
Arch: Allow Arch Components to be clone of any other Arch type
Browse files Browse the repository at this point in the history
  • Loading branch information
yorikvanhavre committed Dec 28, 2016
1 parent c084af8 commit f252f54
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 5 deletions.
4 changes: 3 additions & 1 deletion src/Mod/Arch/ArchComponent.py
Expand Up @@ -333,6 +333,8 @@ def __init__(self,obj):
obj.setEditorMode("PerimeterLength",1)

def execute(self,obj):
if self.clone(obj):
return
if obj.Base:
obj.Shape = obj.Base.Shape

Expand All @@ -350,7 +352,7 @@ def clone(self,obj):
"if this object is a clone, sets the shape. Returns True if this is the case"
if hasattr(obj,"CloneOf"):
if obj.CloneOf:
if Draft.getType(obj.CloneOf) == Draft.getType(obj):
if (Draft.getType(obj.CloneOf) == Draft.getType(obj)) or (Draft.getType(obj) == "Component"):
pl = obj.Placement
obj.Shape = obj.CloneOf.Shape.copy()
obj.Placement = pl
Expand Down
9 changes: 5 additions & 4 deletions src/Mod/Draft/Draft.py
Expand Up @@ -2699,11 +2699,12 @@ def makeShapeString(String,FontFile,Size = 100,Tracking = 0):
FreeCAD.ActiveDocument.recompute()
return obj

def clone(obj,delta=None):
'''clone(obj,[delta]): makes a clone of the given object(s). The clone is an exact,
def clone(obj,delta=None,forcedraft=False):
'''clone(obj,[delta,forcedraft]): makes a clone of the given object(s). The clone is an exact,
linked copy of the given object. If the original object changes, the final object
changes too. Optionally, you can give a delta Vector to move the clone from the
original position.'''
original position. If forcedraft is True, the resulting object is a Draft clone
even if the input object is an Arch object.'''
prefix = getParam("ClonePrefix","")
if prefix:
prefix = prefix.strip()+" "
Expand All @@ -2712,7 +2713,7 @@ def clone(obj,delta=None):
if (len(obj) == 1) and obj[0].isDerivedFrom("Part::Part2DObject"):
cl = FreeCAD.ActiveDocument.addObject("Part::Part2DObjectPython","Clone2D")
cl.Label = prefix + obj[0].Label + " (2D)"
elif (len(obj) == 1) and hasattr(obj[0],"CloneOf"):
elif (len(obj) == 1) and hasattr(obj[0],"CloneOf") and (not forcedraft):
# arch objects can be clones
import Arch
cl = getattr(Arch,"make"+obj[0].Proxy.Type)()
Expand Down

0 comments on commit f252f54

Please sign in to comment.