I am trying to create a parametrized elliptical rod/cylinder.
At the moment, I have managed to script it as follows:
Code: Select all
import FreeCAD as App
import Part
import Sketcher
doc = App.newDocument()
sketch = doc.addObject("Sketcher::SketchObject", "Sketch")
# parameters
h=5
w=2
L=10
# create object
S1=App.Vector(0, h/2, 0)
S2=App.Vector(-w/2, 0, 0)
C=App.Vector(0, 0, 0)
sketch.addGeometry(Part.Ellipse(S1, S2, C), False)
body = doc.addObject('PartDesign::Body','Body')
pad = body.newObject('PartDesign::Pad','Pad')
pad.Profile = sketch
pad.Length = L
doc.recompute()
https://wiki.freecad.org/Scripted_objects
How can I do this?
I looked into the DistanceBolt example here, but cannot find an ellipctical replacement for makeCircle.
I would also still need to find a way to close the faces after extrusion.