discuss@lists.openscad.org

OpenSCAD general discussion

View all threads

path construction

D
dinther
Sun, Apr 4, 2021 2:53 AM

I have made several attempts to build some generic code that makes it easier
to construct 2D shapes. Mostly guided by the SVG path syntax.

Such a syntax is a sequence and therefore order and tracking state is
essential, exactly something openSCAD is designed NOT to do unless you wish
to burn out your braincells with recursive logic. That is not an option
anyway because the code would look horrible.

Is there any way, any suggestion how I can cleanly create a 2D path
involving fillets, arcs, straight segments and splines using nice clean code
that doesn't involve boolean shape operations?

What I want is pseudo code like this:

startPath(20,20); //starts empty point array
h(10); //relative 10 units along x axis
V(10); //absolute 10 units along y axis
a(r=10, to=[0,-20]); // arc with a radius of 10 ending at relative x 0 and y
-20
points = end();
polygon(points);

//creates a rivet outline with a rounded head

I know there are many purists driving openSCAD along and I respect and
appreciate the energy you put into this. But if I can't use programming
logic I used for decades, or at least do stuff like this somehow, I am outta
here because I spend way too much time wrangling code to do want I want it
to do.

--
Sent from: http://forum.openscad.org/

I have made several attempts to build some generic code that makes it easier to construct 2D shapes. Mostly guided by the SVG path syntax. Such a syntax is a sequence and therefore order and tracking state is essential, exactly something openSCAD is designed NOT to do unless you wish to burn out your braincells with recursive logic. That is not an option anyway because the code would look horrible. Is there any way, any suggestion how I can cleanly create a 2D path involving fillets, arcs, straight segments and splines using nice clean code that doesn't involve boolean shape operations? What I want is pseudo code like this: startPath(20,20); //starts empty point array h(10); //relative 10 units along x axis V(10); //absolute 10 units along y axis a(r=10, to=[0,-20]); // arc with a radius of 10 ending at relative x 0 and y -20 points = end(); polygon(points); //creates a rivet outline with a rounded head I know there are many purists driving openSCAD along and I respect and appreciate the energy you put into this. But if I can't use programming logic I used for decades, or at least do stuff like this somehow, I am outta here because I spend way too much time wrangling code to do want I want it to do. -- Sent from: http://forum.openscad.org/
RD
Revar Desmera
Sun, Apr 4, 2021 3:33 AM

On Apr 3, 2021, at 7:53 PM, dinther vandinther@gmail.com wrote:

I have made several attempts to build some generic code that makes it easier to construct 2D shapes. Mostly guided by the SVG path syntax.

Such a syntax is a sequence and therefore order and tracking state is essential, exactly something openSCAD is designed NOT to do unless you wish to burn out your braincells with recursive logic. That is not an option anyway because the code would look horrible.

Is there any way, any suggestion how I can cleanly create a 2D path involving fillets, arcs, straight segments and splines using nice clean code that doesn't involve boolean shape operations?

What I want is pseudo code like this:

startPath(20,20); //starts empty point array
h(10); //relative 10 units along x axis
V(10); //absolute 10 units along y axis
a(r=10, to=[0,-20]); // arc with a radius of 10 ending at relative x 0 and y -20
points = end();
polygon(points);

//creates a rivet outline with a rounded head

I know there are many purists driving openSCAD along and I respect and appreciate the energy you put into this. But if I can't use programming logic I used for decades, or at least do stuff like this somehow, I am outta here because I spend way too much time wrangling code to do want I want it to do.
Sent from the OpenSCAD mailing list archive at Nabble.com.


OpenSCAD mailing list
To unsubscribe send an email to discuss-leave@lists.openscad.org

Sounds like turtle() in BOSL2. Or maybe the bezier path construction functions. https://github.com/revarbat/BOSL2/wiki/shapes2d.scad#function-turtle https://github.com/revarbat/BOSL2/wiki/beziers.scad#section-bezier-path-construction -Revar > On Apr 3, 2021, at 7:53 PM, dinther <vandinther@gmail.com> wrote: > > I have made several attempts to build some generic code that makes it easier to construct 2D shapes. Mostly guided by the SVG path syntax. > > Such a syntax is a sequence and therefore order and tracking state is essential, exactly something openSCAD is designed NOT to do unless you wish to burn out your braincells with recursive logic. That is not an option anyway because the code would look horrible. > > Is there any way, any suggestion how I can cleanly create a 2D path involving fillets, arcs, straight segments and splines using nice clean code that doesn't involve boolean shape operations? > > What I want is pseudo code like this: > > startPath(20,20); //starts empty point array > h(10); //relative 10 units along x axis > V(10); //absolute 10 units along y axis > a(r=10, to=[0,-20]); // arc with a radius of 10 ending at relative x 0 and y -20 > points = end(); > polygon(points); > > //creates a rivet outline with a rounded head > > I know there are many purists driving openSCAD along and I respect and appreciate the energy you put into this. But if I can't use programming logic I used for decades, or at least do stuff like this somehow, I am outta here because I spend way too much time wrangling code to do want I want it to do. > Sent from the OpenSCAD mailing list archive at Nabble.com. > _______________________________________________ > OpenSCAD mailing list > To unsubscribe send an email to discuss-leave@lists.openscad.org
D
dinther
Thu, Apr 15, 2021 2:34 PM

Yeah, I had seen turtle. I am all for clean robust code but looking at the
turtle syntax that really looks like a kludge due to the way the language
works.

The bezier example looks intriguing but it is still array based.

Practically everything I build is based on extruded polygons joined together
with a bunch of boolean operations.

I think the functional language is holding OpenSCAD back and that is a real
pity. I am going to see how openjscad hangs together and make that work for
me by writing a library for it. (Strange incidentally that  openjscad.org
http://openjscad.org/  site has vanished.)

--
Sent from: http://forum.openscad.org/

Yeah, I had seen turtle. I am all for clean robust code but looking at the turtle syntax that really looks like a kludge due to the way the language works. The bezier example looks intriguing but it is still array based. Practically everything I build is based on extruded polygons joined together with a bunch of boolean operations. I think the functional language is holding OpenSCAD back and that is a real pity. I am going to see how openjscad hangs together and make that work for me by writing a library for it. (Strange incidentally that openjscad.org <http://openjscad.org/> site has vanished.) -- Sent from: http://forum.openscad.org/