Skip to content

Commit a60b695

Browse files
committed
Arch: Axis can now be referenced in sketches
1 parent ae95f77 commit a60b695

File tree

1 file changed

+14
-13
lines changed

1 file changed

+14
-13
lines changed

src/Mod/Arch/ArchAxis.py

Lines changed: 14 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -57,7 +57,7 @@ def makeAxis(num=5,size=1000,name="Axes"):
5757
if not FreeCAD.ActiveDocument:
5858
FreeCAD.Console.PrintError("No active document. Aborting\n")
5959
return
60-
obj = FreeCAD.ActiveDocument.addObject("App::FeaturePython","Axis")
60+
obj = FreeCAD.ActiveDocument.addObject("Part::FeaturePython","Axis")
6161
obj.Label = translate("Arch",name)
6262
_Axis(obj)
6363
if FreeCAD.GuiUp:
@@ -225,6 +225,7 @@ def onDocumentRestored(self,obj):
225225

226226
def execute(self,obj):
227227

228+
pl = obj.Placement
228229
import Part
229230
geoms = []
230231
dist = 0
@@ -242,13 +243,13 @@ def execute(self,obj):
242243
geoms.append(Part.LineSegment(p1,p2).toShape())
243244
if geoms:
244245
sh = Part.Compound(geoms)
245-
sh.Placement = obj.Placement
246246
obj.Shape = sh
247+
obj.Placement = pl
247248

248-
def onChanged(self,obj,prop):
249+
#def onChanged(self,obj,prop):
249250

250-
if prop in ["Angles","Distances","Placement"]:
251-
self.execute(obj)
251+
# if prop in ["Angles","Distances","Placement"]:
252+
# self.execute(obj)
252253

253254
def __getstate__(self):
254255

@@ -306,7 +307,7 @@ def setProperties(self,vobj):
306307
if not "DrawStyle" in pl:
307308
vobj.addProperty("App::PropertyEnumeration","DrawStyle","Axis",QT_TRANSLATE_NOOP("App::Property","The type of line to draw this axis"))
308309
vobj.DrawStyle = ["Solid","Dashed","Dotted","Dashdot"]
309-
vobj.DrawStyle = "Dashdot"
310+
vobj.DrawStyle = "Dashdot"
310311
if not "BubblePosition" in pl:
311312
vobj.addProperty("App::PropertyEnumeration","BubblePosition","Axis",QT_TRANSLATE_NOOP("App::Property","Where to add bubbles to this axis: Start, end, both or none"))
312313
vobj.BubblePosition = ["Start","End","Both","None"]
@@ -315,7 +316,7 @@ def setProperties(self,vobj):
315316
vobj.LineWidth = 1
316317
if not "LineColor" in pl:
317318
vobj.addProperty("App::PropertyColor","LineColor","Axis",QT_TRANSLATE_NOOP("App::Property","The color of this axis"))
318-
vobj.LineColor = ArchCommands.getDefaultColor("Helpers")
319+
vobj.LineColor = ArchCommands.getDefaultColor("Helpers")
319320
if not "StartNumber" in pl:
320321
vobj.addProperty("App::PropertyInteger","StartNumber","Axis",QT_TRANSLATE_NOOP("App::Property","The number of the first axis"))
321322
vobj.StartNumber = 1
@@ -389,7 +390,7 @@ def updateData(self,obj,prop):
389390
i = 0
390391
for e in obj.Shape.Edges:
391392
for v in e.Vertexes:
392-
verts.append([v.X,v.Y,v.Z])
393+
verts.append(tuple(obj.Placement.inverse().multVec(v.Point)))
393394
vset.append(i)
394395
i += 1
395396
vset.append(-1)
@@ -441,13 +442,13 @@ def onChanged(self, vobj, prop):
441442
pos = [vobj.BubblePosition]
442443
for i in range(len(vobj.Object.Shape.Edges)):
443444
for p in pos:
444-
verts = vobj.Object.Shape.Edges[i].Vertexes
445+
verts = [vobj.Object.Placement.inverse().multVec(v.Point) for v in vobj.Object.Shape.Edges[i].Vertexes]
445446
if p == "Start":
446-
p1 = verts[0].Point
447-
p2 = verts[1].Point
447+
p1 = verts[0]
448+
p2 = verts[1]
448449
else:
449-
p1 = verts[1].Point
450-
p2 = verts[0].Point
450+
p1 = verts[1]
451+
p2 = verts[0]
451452
dv = p2.sub(p1)
452453
dv.normalize()
453454
if hasattr(vobj.BubbleSize,"Value"):

0 commit comments

Comments
 (0)