Skip to content

Commit

Permalink
Arch: Axis can now be referenced in sketches
Browse files Browse the repository at this point in the history
  • Loading branch information
yorikvanhavre committed Jan 18, 2019
1 parent ae95f77 commit a60b695
Showing 1 changed file with 14 additions and 13 deletions.
27 changes: 14 additions & 13 deletions src/Mod/Arch/ArchAxis.py
Expand Up @@ -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:
Expand Down Expand Up @@ -225,6 +225,7 @@ def onDocumentRestored(self,obj):

def execute(self,obj):

pl = obj.Placement
import Part
geoms = []
dist = 0
Expand All @@ -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):

Expand Down Expand Up @@ -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"]
Expand All @@ -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
Expand Down Expand Up @@ -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)
Expand Down Expand Up @@ -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"):
Expand Down

4 comments on commit a60b695

@Jansolo75
Copy link

@Jansolo75 Jansolo75 commented on a60b695 Mar 19, 2021

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hi Yorik:
Is there exists some instruction for avoid this: <class 'AttributeError'>: addEventCallbackPivy 12:35:07 Grid Disabled: Requested number of lines 45382 is larger than the maximum configured of 10000 .Grid Disabled: Requested number of lines 45382 is larger than the maximum configured of 10000 ?

Im re-begginer in FC and I need to use Axis System linked to sketches, for working in my migration workflow.
Regards

@Jansolo75
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I paste an image , I want to draw a sketch constraining to the Axis intersections, and when the Axis System will be modified, the sketch updates with it.
Any other suggestions are well received.
image

@Jansolo75
Copy link

@Jansolo75 Jansolo75 commented on a60b695 Mar 21, 2021

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I solved how to made a Dynamic Axis System in Freecad Forum " How do I constrain a squetch to an axis"
Thanks

@luzpaz
Copy link
Contributor

@luzpaz luzpaz commented on a60b695 Mar 21, 2021

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please open a forum thread next time. It's just easier for the core devs to address.

Please sign in to comment.