I've been trying python scripting again. I wanted to use the makePipe function to create a spring. In the console, using snippets of code found here and there, here's what I've come up with:
Code: Select all
import Part, FreeCAD, math
from FreeCAD import Base
helix=Part.makeHelix(1,10,3)
circle = Part.makeCircle(0.35,Base.Vector(3,0,0),Base.Vector(0,1,0))
circle = Part.Wire([circle])
pipe = Part.Wire(helix).makePipe(circle)
Part.show(pipe)
But I find geometry creation through the console tedious. I'd much rather draw my 2D elements with the GUI tools, then run a script on them.
So I created an Helix object with the "Primitives > Create primitives" Part menu, then a Draft Circle for my section.
To register them in the console, I did this:
Code: Select all
myCircle=App.ActiveDocument.getObject("Circle")
myHelix=App.ActiveDocument.getObject("Helix")
So OK, I guess I need to extract the wire out of the circle. I do this:>>> pipe = Part.Wire(myHelix).makePipe(myCircle)
Traceback (most recent call last):
File "<input>", line 1, in <module>
Exception: edge or wire or list of edges and wires expected
So now I'm stumped.>>> section=Part.Wire([myCircle])
Traceback (most recent call last):
File "<input>", line 1, in <module>
TypeError: item is not a shape
It would help if I could understand any of this. I'm not sure my brain is wired for it.