From a60b6957db228c42a00a1e002a415cbb8309d3c8 Mon Sep 17 00:00:00 2001 From: Yorik van Havre Date: Fri, 18 Jan 2019 17:40:50 -0200 Subject: [PATCH] Arch: Axis can now be referenced in sketches --- src/Mod/Arch/ArchAxis.py | 27 ++++++++++++++------------- 1 file changed, 14 insertions(+), 13 deletions(-) diff --git a/src/Mod/Arch/ArchAxis.py b/src/Mod/Arch/ArchAxis.py index e0385919d7ac..1ee055dda767 100644 --- a/src/Mod/Arch/ArchAxis.py +++ b/src/Mod/Arch/ArchAxis.py @@ -57,7 +57,7 @@ def makeAxis(num=5,size=1000,name="Axes"): if not FreeCAD.ActiveDocument: FreeCAD.Console.PrintError("No active document. Aborting\n") return - obj = FreeCAD.ActiveDocument.addObject("App::FeaturePython","Axis") + obj = FreeCAD.ActiveDocument.addObject("Part::FeaturePython","Axis") obj.Label = translate("Arch",name) _Axis(obj) if FreeCAD.GuiUp: @@ -225,6 +225,7 @@ def onDocumentRestored(self,obj): def execute(self,obj): + pl = obj.Placement import Part geoms = [] dist = 0 @@ -242,13 +243,13 @@ def execute(self,obj): geoms.append(Part.LineSegment(p1,p2).toShape()) if geoms: sh = Part.Compound(geoms) - sh.Placement = obj.Placement obj.Shape = sh + obj.Placement = pl - def onChanged(self,obj,prop): + #def onChanged(self,obj,prop): - if prop in ["Angles","Distances","Placement"]: - self.execute(obj) + # if prop in ["Angles","Distances","Placement"]: + # self.execute(obj) def __getstate__(self): @@ -306,7 +307,7 @@ def setProperties(self,vobj): if not "DrawStyle" in pl: vobj.addProperty("App::PropertyEnumeration","DrawStyle","Axis",QT_TRANSLATE_NOOP("App::Property","The type of line to draw this axis")) vobj.DrawStyle = ["Solid","Dashed","Dotted","Dashdot"] - vobj.DrawStyle = "Dashdot" + vobj.DrawStyle = "Dashdot" if not "BubblePosition" in pl: vobj.addProperty("App::PropertyEnumeration","BubblePosition","Axis",QT_TRANSLATE_NOOP("App::Property","Where to add bubbles to this axis: Start, end, both or none")) vobj.BubblePosition = ["Start","End","Both","None"] @@ -315,7 +316,7 @@ def setProperties(self,vobj): vobj.LineWidth = 1 if not "LineColor" in pl: vobj.addProperty("App::PropertyColor","LineColor","Axis",QT_TRANSLATE_NOOP("App::Property","The color of this axis")) - vobj.LineColor = ArchCommands.getDefaultColor("Helpers") + vobj.LineColor = ArchCommands.getDefaultColor("Helpers") if not "StartNumber" in pl: vobj.addProperty("App::PropertyInteger","StartNumber","Axis",QT_TRANSLATE_NOOP("App::Property","The number of the first axis")) vobj.StartNumber = 1 @@ -389,7 +390,7 @@ def updateData(self,obj,prop): i = 0 for e in obj.Shape.Edges: for v in e.Vertexes: - verts.append([v.X,v.Y,v.Z]) + verts.append(tuple(obj.Placement.inverse().multVec(v.Point))) vset.append(i) i += 1 vset.append(-1) @@ -441,13 +442,13 @@ def onChanged(self, vobj, prop): pos = [vobj.BubblePosition] for i in range(len(vobj.Object.Shape.Edges)): for p in pos: - verts = vobj.Object.Shape.Edges[i].Vertexes + verts = [vobj.Object.Placement.inverse().multVec(v.Point) for v in vobj.Object.Shape.Edges[i].Vertexes] if p == "Start": - p1 = verts[0].Point - p2 = verts[1].Point + p1 = verts[0] + p2 = verts[1] else: - p1 = verts[1].Point - p2 = verts[0].Point + p1 = verts[1] + p2 = verts[0] dv = p2.sub(p1) dv.normalize() if hasattr(vobj.BubbleSize,"Value"):