Hey FreeCAD,
Firstly hope your all well, Well my daughter absolutely hates being called Chicken_Monkey. So like any good father I intend to build a brand around that phrase. Ideally I'd like to be able to traverse a Ball Point pen AKA "Sphere" along the out line of the Phrase Chicken_Monkey that part seemed to go ok. I now have the outline in both a wire & a sketch, but when I go to run either macro it can't get passed the first segment.
kind of hit a wall and not sure where to take day2 Python class?
FollowPath_Macro on joined segments?
Forum rules
Be nice to others! Respect the FreeCAD code of conduct!
Be nice to others! Respect the FreeCAD code of conduct!
-
- Posts: 81
- Joined: Wed Feb 03, 2021 8:07 am
FollowPath_Macro on joined segments?
- Attachments
-
- FollowPathWire.FCMacro
- (401 Bytes) Downloaded 12 times
-
- FollowPath.FCMacro
- (401 Bytes) Downloaded 11 times
-
- Chicken_Monkey.FCStd
- (497.88 KiB) Downloaded 12 times
-
- Veteran
- Posts: 5513
- Joined: Thu Apr 05, 2018 1:53 am
Re: FollowPath_Macro on joined segments?
shp.Length is the entire length of the wire, not the length of the current edge.
Code: Select all
obj = App.ActiveDocument.getObject("Wire")
shp = obj.Shape
edge = shp.Edges[0]
for edge in shp.Edges:
pos = 0
while pos < edge.Length:
try:
t = edge.getParameterByLength(pos)
v = edge.valueAt(t)
except ValueError as ve:
print(f"error: {ve}, t = {t}, v = {v}")
break
App.ActiveDocument.getObject("Sphere").Placement=App.Placement(v,App.Rotation(App.Vector(0,0,1),0))
App.ActiveDocument.recompute()
Gui.updateGui()
pos=pos+0.5
if App.ActiveDocument.Comment =="s":
break
-
- Posts: 81
- Joined: Wed Feb 03, 2021 8:07 am
Re: FollowPath_Macro on joined segments?
Markster,
Thx heaps, seems to ok.
https://youtu.be/BRh0rdjo7K8
Hope you get a laugh, I hope you don't mind me asking how many years in Python?
Thx heaps, seems to ok.
https://youtu.be/BRh0rdjo7K8
Hope you get a laugh, I hope you don't mind me asking how many years in Python?
-
- Veteran
- Posts: 5513
- Joined: Thu Apr 05, 2018 1:53 am
Re: FollowPath_Macro on joined segments?
I did some very minimal dabbling in python, but only after starting using FreeCAD in 2018, did I begin grasping more than the very basic concepts.