Code: Select all
def freecad_blade(freeecad_doc, blade: Blade):
doc_name = freeecad_doc
obj_name = freeecad_doc
doc = App.newDocument(doc_name)
profiles = []
for af in blade.airfoils:
my_plane = App.Placement()
my_plane.Base = App.Vector(0, 0, af.z[0])
if af.is_circle:
profile = Draft.make_circle(radius=af.chord_length / 2, placement=my_plane)
else:
points = [App.Vector(*point) for point in af.coordinates]
points[-1] = points[0]
profile = Draft.make_bspline(points, closed=True)
profile.Label = af.name
profiles.append(profile)
te = Draft.make_bspline([App.Vector(*point) for point in blade.le])
te.Label = "TE"
le = Draft.make_bspline([App.Vector(*point) for point in blade.te])
le.Label = "LE"
doc.addObject("Part::Loft", "blade_loft")
blade_loft = doc.getObject("blade_loft")
blade_loft.MaxDegree = 2
blade_loft.Solid = True
blade_loft.Sections = profiles
doc.recompute()
doc.saveAs("test")
return App.getDocument(obj_name).getObject("blade_loft")
The problem is that the loft command gives an error and doesn't produce any geometry. I opened the produced file with FreeCAD, and tried to make the loft by hand, by adding and recomputing, and the result is horrible until it crashed.
I, have attached an image of the loft made by hand, and my freecad generated file.
Maybe loft its not what i need here, but I also have tried with additive loft and sweep, with no result