Fix Macro indentation? Macro_Unroll_Ruled_Surface

Need help, or want to share a macro? Post here!
Forum rules
Be nice to others! Respect the FreeCAD code of conduct!
User avatar
onekk
Veteran
Posts: 6208
Joined: Sat Jan 17, 2015 7:48 am
Contact:

Re: Fix Macro indentation?

Post by onekk »

edwilliams16 wrote: Sun Jul 24, 2022 11:55 pm The remaining pair of edges are digitized with an equal number of steps. Connecting up the corresponding points on the two edges draws the ruling (*). (Remember a ruled surface is one generated by taking a straight line and moving it in space - around a circle, for instance, generates a cylinder - with a tilt it generates a cone. A loft to a point is automatically ruled.)

....
I think the whole thing could be made more general by using the same algorithm using the straight iso-lines as the folding edges - as obtained from the Curves|Isolines tool. But I need to think and experiment more before trying it...

I think that it could be not too difficult to generalize it for a cone shaped, that have three edges, considering the "point" of the cone as first parameters for every LineSegment.

More complex cases, could be achieved, I'm not so skilled in geometrical things to go over these cases.

Regards

Carlo D.
GitHub page: https://github.com/onekk/freecad-doc.
- In deep articles on FreeCAD.
- Learning how to model with scripting.
- Various other stuffs.

Blog: https://okkmkblog.wordpress.com/
edwilliams16
Veteran
Posts: 3183
Joined: Thu Sep 24, 2020 10:31 pm
Location: Hawaii
Contact:

Re: Fix Macro indentation?

Post by edwilliams16 »

onekk wrote: Mon Jul 25, 2022 9:20 am

I think that it could be not too difficult to generalize it for a cone shaped, that have three edges, considering the "point" of the cone as first parameters for every LineSegment.

More complex cases, could be achieved, I'm not so skilled in geometrical things to go over these cases.

Regards

Carlo D.
I did get it working, after a fashion, with generalized cones that arise from lofting to a point.
User avatar
onekk
Veteran
Posts: 6208
Joined: Sat Jan 17, 2015 7:48 am
Contact:

Re: Fix Macro indentation?

Post by onekk »

edwilliams16 wrote: Mon Jul 25, 2022 9:26 am
onekk wrote: Mon Jul 25, 2022 9:20 am

I think that it could be not too difficult to generalize it for a cone shaped, that have three edges, considering the "point" of the cone as first parameters for every LineSegment.

More complex cases, could be achieved, I'm not so skilled in geometrical things to go over these cases.

Regards

Carlo D.
I did get it working, after a fashion, with generalized cones that arise from lofting to a point.
Could please post you version here when done?

Or maybe put your modified version in the original wiki page, as it has a copyright from 2013 and now it's rather obsolete, some credits in the macro header to the original creator I think will make a "good service" for many FC users.

Regards

Carlo D.
GitHub page: https://github.com/onekk/freecad-doc.
- In deep articles on FreeCAD.
- Learning how to model with scripting.
- Various other stuffs.

Blog: https://okkmkblog.wordpress.com/
heda
Veteran
Posts: 1348
Joined: Sat Dec 12, 2015 5:49 pm

Re: Fix Macro indentation? Macro_Unroll_Ruled_Surface

Post by heda »

edwilliams16 wrote: Sun Jul 24, 2022 11:55 pm It looks like the author tried to automate choosing the correct pair, and to consider different numbers of edges, but punted and left dead and/or non-working code.
might be wrong, but could not an algo be based on (assuming we are still talking about ruled surfaces, well 2 edge ruled...):
- identify straight edges
- if there are 4 straight edges use any pair (should be a setting for which - kinda looks like that setting is in place at least)
- if there is 1 straight edge, this could be handled, and if needed casing the degenerate point situation (one would imagine)
actually, could not one straight edge be viewed as a 4 edge face with the straight line doubled up?

if one takes a cylinder and cuts a plane at angle in one end, the current algo goes bananas - so that is another case where the current math is not sufficient.

btw: is it not so that a 4 edge arbitrary ruled surface cannot be "unrolled", it either has to have cuts/partitioning lines in it, or be deformed to be flattened (thinking of a 4 edge ruled surface made of wavy splines)
edwilliams16
Veteran
Posts: 3183
Joined: Thu Sep 24, 2020 10:31 pm
Location: Hawaii
Contact:

Re: Fix Macro indentation? Macro_Unroll_Ruled_Surface

Post by edwilliams16 »

heda wrote: Mon Jul 25, 2022 4:34 pm
You bring up a number of points that have also bothered me.

(1) Not all ruled surfaces are developable - but the converse is the case. I couldn't find any test in the Macro to check for this.
  • One way would be sample the Gaussian curvature face.Surface(u,v, 'Gauss') and make sure it is sufficiently small
  • Maybe there's a way of extracting this from the BSpline representation?
A ruled surface is defined parametrically by

S(u, v) = c(u) + s(u)* v
Using comma notation for partial derivatives, the normal vector is given by

n(u,v) = S,u X S,v = c,u X s + s,u X s * v
To be developable, the normal along a line of constant u needs to be independent of v. If not, the infinitesimal quadrilaterals we need to flatten would not be planar. This requires c,u X s to be parallel to s,u X s . Doing the vector algebra, this becomes

c,u . s,u X s = 0
What is this in BSpline terms?

(2) The Macro doesn't handle trimmed developable surfaces, like cut cones. I note that Curves|Flatten_Surface handles this case and presumably pieces of a cylindrical surface, too.

(3) I think one could do the logic to figure out which edges to use on the lines you suggest.

(4) I did my testing on surfaces that actually were developable - I was interested to see what he had done. Until then, I didn't recognize the limitations.
jfc4120
Posts: 448
Joined: Sat Jul 02, 2022 11:16 pm

Re: Fix Macro indentation? Macro_Unroll_Ruled_Surface

Post by jfc4120 »

I experimented with the latest version:

https://wiki.freecadweb.org/Macro_Unroll_Ruled_Surface

Found to be useful I needed to export as dxf to work with. Opened in Generalcad.

I experimented with a 4 sided ruled surface such as a duct transition and unrolled one side only to test, it worked.

But I achieved better results on same shape using mesh, unwrap 3 sides then the 4th separate.

I tried on a cone shape as well, same thing it worked, but to get any detail dimensions I had to export dxf.

I will say that the updated version can be used now.
Attachments
r1.png
r1.png (8.03 KiB) Viewed 360 times
r2.png
r2.png (14.44 KiB) Viewed 360 times
edwilliams16
Veteran
Posts: 3183
Joined: Thu Sep 24, 2020 10:31 pm
Location: Hawaii
Contact:

Re: Fix Macro indentation? Macro_Unroll_Ruled_Surface

Post by edwilliams16 »

The updated version has been fixed to be quite useable, but naturally it still has its original algorithmic limitations.
  • It doesn't test for zero Gaussian Curvature, so it will try to flatten Ruled Surfaces that aren't developable (= flattenable) eg Ruled_Surface, giving bogus results.
  • It can't handle faces which don't have a pair of opposite ruled edges - like Common Face1
  • It can't handle lofts to a point Loft003
The Curves|FlattenFace tool, OTOH, limits itself to pieces of a cylindrical or conical surface which are guaranteed developable, but can't do lofts to a point either - but if it gives an answer it should be correct.

Going via a mesh, its Unwrap Face also is willing to flatten faces that can't be flattened - but if I understand this post - it tries to do so with minimal deformation. https://forum.freecadweb.org/viewtopic. ... 802#p74802 - good for something elastic, not so good for sheet metal.
In the case of loft to a point, it can do as good a job as you desire by making the triangulation finer.
Attachments
ruletest2.FCStd
(26.63 KiB) Downloaded 7 times
Post Reply