Macro to draw folding lines on a loft

Need help, or want to share a macro? Post here!
Forum rules
Be nice to others! Respect the FreeCAD code of conduct!
jfc4120
Posts: 448
Joined: Sat Jul 02, 2022 11:16 pm

Re: Macro to draw folding lines on a loft

Post by jfc4120 »

@mm2107 still have a look at:

https://wiki.freecad.org/Macro_Cut_Line

On some things, it works great.
User avatar
nm2107
Posts: 42
Joined: Sun Feb 20, 2022 10:37 pm

Re: Macro to draw folding lines on a loft

Post by nm2107 »

jfc4120 wrote: Tue Mar 14, 2023 11:22 pm @mm2107 still have a look at:

https://wiki.freecad.org/Macro_Cut_Line

On some things, it works great.
Yes, I checked it out, it uses the `discretize` function in order to cut edges, that's what I'm also using :)
jfc4120
Posts: 448
Joined: Sat Jul 02, 2022 11:16 pm

Re: Macro to draw folding lines on a loft

Post by jfc4120 »

I sent you another PM for a program to check out, see images here:

It lays out the first section of an elbow, but select only a 2 piece it will give a pipe miter. In inches but just tweak to mm.
Attachments
elbow2.png
elbow2.png (35.4 KiB) Viewed 841 times
elbow.png
elbow.png (8.14 KiB) Viewed 841 times
User avatar
nm2107
Posts: 42
Joined: Sun Feb 20, 2022 10:37 pm

Re: Macro to draw folding lines on a loft

Post by nm2107 »

Nice one !

Mh I'm going nowhere with simple vectors comparison when I try to form the folding lines. Maybe simply manipulating vertexes isn't enough, and I should start to consider the surface which could exist between the two sketches (i.e. the loft), and try to see if I could make some polygons on this surface which are developable (i.e. gauss curvature == 0.0, as EdWilliams mentioned). To sum sup, start considering the surface of the loft ... I should read more about surfaces, because I don't know a lot about them.
edwilliams16
Veteran
Posts: 3107
Joined: Thu Sep 24, 2020 10:31 pm
Location: Hawaii
Contact:

Re: Macro to draw folding lines on a loft

Post by edwilliams16 »

Creating a developable (ruled) surface between curves (assuming it is possible):

If curve1 is X1= X1(u1) and curve2 is X2 = X2(u2) then the rule lines connect points such that the tangent vectors dX1/du1 and dX2/du2 are coplanar with the line between the points X2(u2) - X1(u1).
or (X2(u2) - X1(u1)).dot(dX1/du1 .cross(dX2/du2) )=0
Solving this for u2 given u1 creates the ruling. I have this working numerically in the generalized cone thread. It reduced the Gaussian Curvature of my test surface by 10^5, so I take it as flat.
Supposedly for cubic splines, the equation to be solved is a quartic, so soluble algebraically. I have not pursued this.
User avatar
nm2107
Posts: 42
Joined: Sun Feb 20, 2022 10:37 pm

Re: Macro to draw folding lines on a loft

Post by nm2107 »

User avatar
nm2107
Posts: 42
Joined: Sun Feb 20, 2022 10:37 pm

Re: Macro to draw folding lines on a loft

Post by nm2107 »

Regarding the links I posted above, and your message EdWilliams, I managed to try an implementation of the vector's triple product. The result looks interesting, I have to figure out why some folding lines are placed inside the shape tho (maybe because of tangent vector orientation ?)
Screenshot from 2023-03-24 21-16-06.png
Screenshot from 2023-03-24 21-16-06.png (49.11 KiB) Viewed 677 times
Screenshot from 2023-03-24 21-16-26.png
Screenshot from 2023-03-24 21-16-26.png (30.43 KiB) Viewed 677 times
Code at https://github.com/nm2107/FreeCADLoftFo ... es.FCMacro (still messy because of WIP)
User avatar
nm2107
Posts: 42
Joined: Sun Feb 20, 2022 10:37 pm

Re: Macro to draw folding lines on a loft

Post by nm2107 »

Indeed, it was because of the tangent direction ^^

The result is much better now :) :
Screenshot from 2023-03-24 21-44-03.png
Screenshot from 2023-03-24 21-44-03.png (49.75 KiB) Viewed 668 times
cf commit https://github.com/nm2107/FreeCADLoftFo ... es.FCMacro

EDIT commit https://github.com/nm2107/FreeCADLoftFo ... es.FCMacro has a better fix ;)
edwilliams16
Veteran
Posts: 3107
Joined: Thu Sep 24, 2020 10:31 pm
Location: Hawaii
Contact:

Re: Macro to draw folding lines on a loft

Post by edwilliams16 »

That is working nicely! Have you tried an oloid? viewtopic.php?style=4&p=659487#p659487 and containing thread.

Your first reference was good - but they weren't to clear about the piecewise part. Lofting between two convex curves is algorithmically straight-forward. If they have concave bits with multiple solutions for the generators, it's harder to untangle.
jfc4120
Posts: 448
Joined: Sat Jul 02, 2022 11:16 pm

Re: Macro to draw folding lines on a loft

Post by jfc4120 »

@nm2107 Do you have the code worked out for parts at an angle yet? Like image:
Attachments
ob_cut.png
ob_cut.png (2.52 KiB) Viewed 568 times
Post Reply