From 0544ecbd3e003bcdae0d483d39417dfc68c131fe Mon Sep 17 00:00:00 2001 From: Yorik van Havre Date: Tue, 6 Jun 2017 19:30:26 -0300 Subject: [PATCH] Arch: Allow Arch objects to be arrayed if their Axis property is set --- src/Mod/Arch/ArchAxis.py | 7 +++++-- src/Mod/Arch/ArchComponent.py | 28 +++++++++++++++++++++++++--- 2 files changed, 30 insertions(+), 5 deletions(-) diff --git a/src/Mod/Arch/ArchAxis.py b/src/Mod/Arch/ArchAxis.py index 121ba95eb3..adee4619fa 100644 --- a/src/Mod/Arch/ArchAxis.py +++ b/src/Mod/Arch/ArchAxis.py @@ -237,6 +237,9 @@ class _ViewProviderAxis: vobj.addDisplayMode(sep,"Default") self.onChanged(vobj,"BubbleSize") self.onChanged(vobj,"ShowLabel") + self.onChanged(vobj,"LineColor") + self.onChanged(vobj,"LineWidth") + self.onChanged(vobj,"DrawStyle") def getDisplayModes(self,vobj): return ["Default"] @@ -679,8 +682,8 @@ class _AxisSystem: cv = e3.Vertexes[0].Point pts.extend(bset) else: - cv = e3.Vertexes[0].Point.sub(vc) - pts.extend([p.add(cv) for p in bset]) + v = e3.Vertexes[0].Point.sub(cv) + pts.extend([p.add(v) for p in bset]) return pts diff --git a/src/Mod/Arch/ArchComponent.py b/src/Mod/Arch/ArchComponent.py index e3da39e0d1..edd60c1f5a 100644 --- a/src/Mod/Arch/ArchComponent.py +++ b/src/Mod/Arch/ArchComponent.py @@ -324,6 +324,7 @@ class Component: obj.addProperty("App::PropertyArea","HorizontalArea","Arch",QT_TRANSLATE_NOOP("App::Property","The area of the projection of this object onto the XY plane")) obj.addProperty("App::PropertyLength","PerimeterLength","Arch",QT_TRANSLATE_NOOP("App::Property","The perimeter length of the horizontal area")) obj.addProperty("App::PropertyLink","HiRes","Arch",QT_TRANSLATE_NOOP("App::Property","An optional higher-resolution mesh or shape for this object")) + obj.addProperty("App::PropertyLink","Axis","Arch",QT_TRANSLATE_NOOP("App::Property","An optional axis or axis system on which this object should be duplicated")) obj.Proxy = self self.Type = "Component" self.Subvolume = None @@ -590,6 +591,27 @@ class Component: print("Arch: unable to cut object ",o.Name, " from ", obj.Name) return base + def spread(self,obj,shape,placement): + "spreads this shape along axis positions" + points = None + if hasattr(obj,"Axis"): + if obj.Axis: + if hasattr(obj.Axis,"Proxy"): + if hasattr(obj.Axis.Proxy,"getPoints"): + points = obj.Axis.Proxy.getPoints(obj.Axis) + if not points: + if obj.Axis.isDerivedFrom("Part.Feature"): + points = [v.Point for v in obj.Axis.Shape.Vertexes] + if points: + shps = [] + for p in points: + sh = shape.copy() + sh.translate(p) + shps.append(sh) + import Part + shape = Part.makeCompound(shps) + return shape + def applyShape(self,obj,shape,placement,allowinvalid=False,allownosolid=False): "checks and cleans the given shape, and apply it to the object" if shape: @@ -602,19 +624,19 @@ class Component: FreeCAD.Console.PrintError(translate("Arch","Error computing the shape of this object")+"\n") return shape = shape.removeSplitter() - obj.Shape = shape + obj.Shape = self.spread(obj,shape,placement) if not placement.isNull(): obj.Placement = placement else: if allownosolid: - obj.Shape = shape + obj.Shape = self.spread(obj,shape,placement) if not placement.isNull(): obj.Placement = placement else: FreeCAD.Console.PrintWarning(obj.Label + " " + translate("Arch","has no solid")+"\n") else: if allowinvalid: - obj.Shape = shape + obj.Shape = self.spread(obj,shape,placement) if not placement.isNull(): obj.Placement = placement else: