Problem lofting several airfoils profiles

Need help, or want to share a macro? Post here!
Forum rules
Be nice to others! Respect the FreeCAD code of conduct!
Post Reply
efirvida
Posts: 1
Joined: Wed May 31, 2023 6:43 pm

Problem lofting several airfoils profiles

Post by efirvida »

Hi everyone, Iḿ know here so I don't know if this is the right place for this, but Im generating my geometry from source code, besides I think that the problem is not with my code. My code is:

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")
which basically creates splines from airfoil coordinates in the X;Y plane, put that spline in Z offset and tries to create a loft with all profiles. I have to say that all profiles have the same number of points, I don't know if that is important.

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
Attachments
test.FCStd
(47.39 KiB) Downloaded 9 times
Screenshot_20230531_150017.png
Screenshot_20230531_150017.png (337.06 KiB) Viewed 357 times
User avatar
hammax
Veteran
Posts: 1985
Joined: Thu Jan 19, 2017 5:03 pm
Location: Ammersee DE

Re: Problem lofting several airfoils profiles

Post by hammax »

... no use of python?
Simple version.
Lofting by using a master sketch and scaled (+ twisted ) clones of it.
A smooth profile is generated by a knotless BSpline pair, redrawn on top of original profile.

Weird_Prof.PNG
Weird_Prof.PNG (23.13 KiB) Viewed 292 times
Attachments
test_3.FCStd
FC.20.1
(40.37 KiB) Downloaded 5 times
test_2.FCStd
FC.20.1
(45.99 KiB) Downloaded 5 times
Post Reply