Error in wiki code: Path scripting: Path Shape feature

Need help, or want to share a macro? Post here!
Forum rules
Be nice to others! Respect the FreeCAD code of conduct!
Post Reply
tximikel
Posts: 3
Joined: Wed Jan 23, 2019 6:19 pm
Contact:

Error in wiki code: Path scripting: Path Shape feature

Post by tximikel »

Hi all!
I'm newbie in FreeCad forum, i've an error practising with Path Scripting following the wiki code, exactly in the section "The path shape feature", when run the following code in FreeCAD (both versions 0.17 and daily 0.18):

Code: Select all

import Part
v1 = FreeCAD.Vector(0,0,0)
v2 = FreeCAD.Vector(0,2,0)
v3 = FreeCAD.Vector(2,2,0)
v4 = FreeCAD.Vector(3,3,0)
wire = Part.makePolygon([v1,v2,v3,v4])
o = FreeCAD.ActiveDocument.addObject("Path::FeatureShape","myPath2")
>>> o.Shape = wire
Traceback (most recent call last):
  File "<input>", line 1, in <module>
AttributeError: 'App.DocumentObject' object has no attribute 'Shape'
Then i've solved this issue using the following two alternative code options:

Code: Select all

#option #1 with Path
>>> o.Path=Path.fromShape(wire)

#option #2 with Part
>>> po = FreeCAD.ActiveDocument.addObject("Part::Feature","myPartPath")
>>> po.Shape=wire
These are suitable options, or you know better one? can anyone activate my forum username in wiki to edit wiki page to correct it? or could you suggest me other option...
Thanks, great pleasure to share in FreeCAD ;) hugs, @tximikel
Post Reply