@@ -57,7 +57,7 @@ def makeAxis(num=5,size=1000,name="Axes"):
57
57
if not FreeCAD .ActiveDocument :
58
58
FreeCAD .Console .PrintError ("No active document. Aborting\n " )
59
59
return
60
- obj = FreeCAD .ActiveDocument .addObject ("App ::FeaturePython" ,"Axis" )
60
+ obj = FreeCAD .ActiveDocument .addObject ("Part ::FeaturePython" ,"Axis" )
61
61
obj .Label = translate ("Arch" ,name )
62
62
_Axis (obj )
63
63
if FreeCAD .GuiUp :
@@ -225,6 +225,7 @@ def onDocumentRestored(self,obj):
225
225
226
226
def execute (self ,obj ):
227
227
228
+ pl = obj .Placement
228
229
import Part
229
230
geoms = []
230
231
dist = 0
@@ -242,13 +243,13 @@ def execute(self,obj):
242
243
geoms .append (Part .LineSegment (p1 ,p2 ).toShape ())
243
244
if geoms :
244
245
sh = Part .Compound (geoms )
245
- sh .Placement = obj .Placement
246
246
obj .Shape = sh
247
+ obj .Placement = pl
247
248
248
- def onChanged (self ,obj ,prop ):
249
+ # def onChanged(self,obj,prop):
249
250
250
- if prop in ["Angles" ,"Distances" ,"Placement" ]:
251
- self .execute (obj )
251
+ # if prop in ["Angles","Distances","Placement"]:
252
+ # self.execute(obj)
252
253
253
254
def __getstate__ (self ):
254
255
@@ -306,7 +307,7 @@ def setProperties(self,vobj):
306
307
if not "DrawStyle" in pl :
307
308
vobj .addProperty ("App::PropertyEnumeration" ,"DrawStyle" ,"Axis" ,QT_TRANSLATE_NOOP ("App::Property" ,"The type of line to draw this axis" ))
308
309
vobj .DrawStyle = ["Solid" ,"Dashed" ,"Dotted" ,"Dashdot" ]
309
- vobj .DrawStyle = "Dashdot"
310
+ vobj .DrawStyle = "Dashdot"
310
311
if not "BubblePosition" in pl :
311
312
vobj .addProperty ("App::PropertyEnumeration" ,"BubblePosition" ,"Axis" ,QT_TRANSLATE_NOOP ("App::Property" ,"Where to add bubbles to this axis: Start, end, both or none" ))
312
313
vobj .BubblePosition = ["Start" ,"End" ,"Both" ,"None" ]
@@ -315,7 +316,7 @@ def setProperties(self,vobj):
315
316
vobj .LineWidth = 1
316
317
if not "LineColor" in pl :
317
318
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" )
319
320
if not "StartNumber" in pl :
320
321
vobj .addProperty ("App::PropertyInteger" ,"StartNumber" ,"Axis" ,QT_TRANSLATE_NOOP ("App::Property" ,"The number of the first axis" ))
321
322
vobj .StartNumber = 1
@@ -389,7 +390,7 @@ def updateData(self,obj,prop):
389
390
i = 0
390
391
for e in obj .Shape .Edges :
391
392
for v in e .Vertexes :
392
- verts .append ([ v . X , v . Y , v . Z ] )
393
+ verts .append (tuple ( obj . Placement . inverse (). multVec ( v . Point )) )
393
394
vset .append (i )
394
395
i += 1
395
396
vset .append (- 1 )
@@ -441,13 +442,13 @@ def onChanged(self, vobj, prop):
441
442
pos = [vobj .BubblePosition ]
442
443
for i in range (len (vobj .Object .Shape .Edges )):
443
444
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 ]
445
446
if p == "Start" :
446
- p1 = verts [0 ]. Point
447
- p2 = verts [1 ]. Point
447
+ p1 = verts [0 ]
448
+ p2 = verts [1 ]
448
449
else :
449
- p1 = verts [1 ]. Point
450
- p2 = verts [0 ]. Point
450
+ p1 = verts [1 ]
451
+ p2 = verts [0 ]
451
452
dv = p2 .sub (p1 )
452
453
dv .normalize ()
453
454
if hasattr (vobj .BubbleSize ,"Value" ):
0 commit comments