How to call Multiloft from Curves WB

Need help, or want to share a macro? Post here!
Forum rules
Be nice to others! Respect the FreeCAD code of conduct!
Post Reply
browntoastjam
Posts: 37
Joined: Fri Aug 20, 2021 9:51 pm

How to call Multiloft from Curves WB

Post by browntoastjam »

Hello All

Is there a way to call the multiloft function from the Curves WB?
The wiki page is quite blank (on scripting)

For concreteness, I have three faces (face1,face2,face3) and I want to run multiloft on them.

Thanks


OS: Ubuntu 20.04.3 LTS (XFCE/xubuntu)
Word size of FreeCAD: 64-bit
Version: 0.20.25645 (Git) AppImage
Build type: Release
Branch: master
Hash: 37d9757399b4c2ec30318eb88d7cd7c508246345
Python version: 3.9.7
Qt version: 5.12.9
Coin version: 4.0.0
OCC version: 7.5.2
Locale: English/United States (en_US)
User avatar
Chris_G
Veteran
Posts: 2598
Joined: Tue Dec 31, 2013 4:10 pm
Location: France
Contact:

Re: How to call Multiloft from Curves WB

Post by Chris_G »

You want to build a loft shape through face1, face2 and face3 ?
Then you don't need multiloft.
Part.makeLoft() will do it :
Help on built-in function makeLoft:
makeLoft(list of wires,[solid=False,ruled=False,closed=False,maxDegree=5]) -- Create a loft shape.

Code: Select all

wires = [f.Wire1 for f in (face1,face2,face3)]
loft = Part.makeLoft(wires, solid=True)
Part.show(loft)
TheMarkster
Veteran
Posts: 5513
Joined: Thu Apr 05, 2018 1:53 am

Re: How to call Multiloft from Curves WB

Post by TheMarkster »

Chris_G wrote: Sat Sep 18, 2021 7:25 am Part.makeLoft() will do it :
It could be useful in Curves to have a feature python loft object that can loft between selected subobjects, for example loft between a selected edge and a selected face or a selected vertex and a selected face, etc. MultiLoft, as I understand it, uses all faces of selected objects.

But already some problems I ran into. In some experiments I have tried lofting between vertices, but Part.makeLoft() always fails. In the Gui the Part::Loft object can manage one vertex and another profile, example: loft between part::vertex and part::plane to create pyramid. I don't know why the Gui can succeed with vertices, but not the python function. Either I am doing something wrong or in the Gui version something is done to fix it, but even in the Gui vertex to vertex lofting is not supported. Workaround for that is simply make a line and use that for the shape.

A trick for vertex to other subobject lofting could be to make a very, very scaled down copy of the other subobject to replace the vertex in the loft. For example, the user selects a vertex and a face the loft is done between the face and a scaled down copy of the face placed at the position of the vertex.

When lofting face to face another problem can be the self-intersection. Here I select 4 faces from the 3 prisms and try to loft them.

Code: Select all

>>> ### Begin command to_console
>>> doc1 = FreeCAD.getDocument('Unnamed')
>>> o1 = doc1.getObject('Prism002')
>>> f1 = o1.Shape.Face4
>>> o2 = doc1.getObject('Prism')
>>> f2 = o2.Shape.Face1
>>> f3 = o2.Shape.Face3
>>> o3 = doc1.getObject('Prism001')
>>> f4 = o3.Shape.Face4
>>> _sub_link_buffer = ((o1,('Face4')),(o2,('Face1')),(o2,('Face3')),(o3,('Face4')),)
>>> ol = (o1,o2,o3,)
>>> fl = (f1,f2,f3,f4,)
>>> ### End command to_console
>>> loft = Part.makeLoft([f1.Wire1,f2.Wire1,f3.Wire1,f4.Wire1],True,True)
>>> Part.show(loft)
Snip macro screenshot-932226.png
Snip macro screenshot-932226.png (49.6 KiB) Viewed 658 times
Using Draft Facebinders also fails in this example. I tried reversing that last face and using the reversed object, but same result. Perhaps reversing the wire would work. Or perhaps some algorithm can sort this out. Maybe check for self-intersections and try a different thing. For the user the workaround is to loft the edges and combine the new faces into a shell, and from there a solid.

Edit: attach file
Attachments
loft_experiment.FCStd
(23.2 KiB) Downloaded 20 times
Post Reply