From f252f54573da10a597c7e98fb9ca0b44b0d0ccc2 Mon Sep 17 00:00:00 2001 From: Yorik van Havre Date: Wed, 28 Dec 2016 20:27:46 -0200 Subject: [PATCH] Arch: Allow Arch Components to be clone of any other Arch type --- src/Mod/Arch/ArchComponent.py | 4 +++- src/Mod/Draft/Draft.py | 9 +++++---- 2 files changed, 8 insertions(+), 5 deletions(-) diff --git a/src/Mod/Arch/ArchComponent.py b/src/Mod/Arch/ArchComponent.py index b0f9d7a67185..8d1dfa6f3b6e 100644 --- a/src/Mod/Arch/ArchComponent.py +++ b/src/Mod/Arch/ArchComponent.py @@ -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 @@ -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 diff --git a/src/Mod/Draft/Draft.py b/src/Mod/Draft/Draft.py index 4672e06e5911..23ee78a8ce40 100644 --- a/src/Mod/Draft/Draft.py +++ b/src/Mod/Draft/Draft.py @@ -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()+" " @@ -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)()