discuss@lists.openscad.org

OpenSCAD general discussion Mailing-list

View all threads

2D PathBuilder

PV
Paul van Dinther
Thu, Sep 23, 2021 4:16 AM

This out of hand exercise to implement svg path syntax to create shapes has
been a lot of fun.
Pity, I can't post a picture here but I can include openSCAD code to show
it off.

I revised my earlier version and now strictly stick to the standard SVG one
litter commands. Commands that are not part of the SVG syntax are longer.

With exception of the arc command all 20 commands have been implemented. I
know you can of course import SVG but then it isn't parametric. It wasn't
so long ago that I needed to ask on this forum how to flatten a list!

So there are now two ways to use pathbuilder. You can simply write a svg
path string like so:

The official Nike swoosh rendered in 5 segments per spline curve.

svgShape("M68.56-4 0 5L18.4-25.36Q12.16-28 7.92-28q-4.8 0-6.96 3.36-1.36
2.16-.8 5.48t2.96 7.08q2 3.04 6.56 8-1.6-2.56-2.24-5.28-1.2-5.12
2.16-7.52Q11.2-18 14-18q2.24 0 5.04.72z")

or you can call each command by means of a module.

M(68.56,-4,0,$pb_spline=4)
L(18.4,-25.36)
Q(12.16,-28,7.92,-28)
q([-4.8,0,-6.96,3.36,-1.36,2.16,-.8,5.48])
t(2.96,7.08)
q([2,3.04,6.56,8,-1.6,-2.56,-2.24,-5.28,-1.2,-5.12,2.16,-7.5,2])
Q(11.2,-18,14,-18)
q(2.24,0,5.04,.72)
draw();

I like the string method because you can get your hands on the points list
and do your own stuff with it.

pts = svgPath("M68.56-4 0 5L18.... and so on

And of course, loads of extra features that svg doesn't offer...

fillet, chamfer, polar, turn, forward, elaborate line extend function to
extend a line to another reference which can be a
polyline itself. Written lots of documentation as well.

It will be a couple of days before I feel confident enough to upload the
update to git-hub but right now you can find the older version there.
https://github.com/dinther/pathbuilder

The code below was output from pathbuilder. Closest to visuals I can do.:-)

polygon([[68.56, -4], [18.4, -25.36], [18.4, -25.36], [15.405, -26.515],
[12.66, -27.34], [10.165, -27.835], [7.92, -28], [7.92, -28], [5.685,
-27.79], [3.78, -27.16], [2.205, -26.11], [0.96, -24.64], [0.96, -24.64],
[0.4, -23.4875], [0.08, -22.19], [-9.71445e-17, -20.7475], [0.16, -19.16],
[0.16, -19.16], [0.555, -17.4725], [1.18, -15.73], [2.035, -13.9325],
[3.12, -12.08], [3.12, -12.08], [4.28, -10.44], [5.76, -8.56], [7.56,
-6.44], [9.68, -4.08], [9.68, -4.08], [8.94, -5.37], [8.32, -6.68], [7.82,
-8.01], [7.44, -9.36], [7.44, -9.36], [7.125, -11.7488], [7.38, -13.795],
[8.205, -15.4988], [9.6, -16.86], [9.6, -16.86], [10.475, -17.3588], [11.5,
-17.715], [12.675, -17.9288], [14, -18], [14, -18], [15.155, -17.955],
[16.38, -17.82], [17.675, -17.595], [19.04, -17.28]]);

This out of hand exercise to implement svg path syntax to create shapes has been a lot of fun. Pity, I can't post a picture here but I can include openSCAD code to show it off. I revised my earlier version and now strictly stick to the standard SVG one litter commands. Commands that are not part of the SVG syntax are longer. With exception of the arc command all 20 commands have been implemented. I know you can of course import SVG but then it isn't parametric. It wasn't so long ago that I needed to ask on this forum how to flatten a list! So there are now two ways to use pathbuilder. You can simply write a svg path string like so: The official Nike swoosh rendered in 5 segments per spline curve. svgShape("M68.56-4 0 5L18.4-25.36Q12.16-28 7.92-28q-4.8 0-6.96 3.36-1.36 2.16-.8 5.48t2.96 7.08q2 3.04 6.56 8-1.6-2.56-2.24-5.28-1.2-5.12 2.16-7.52Q11.2-18 14-18q2.24 0 5.04.72z") or you can call each command by means of a module. M(68.56,-4,0,$pb_spline=4) L(18.4,-25.36) Q(12.16,-28,7.92,-28) q([-4.8,0,-6.96,3.36,-1.36,2.16,-.8,5.48]) t(2.96,7.08) q([2,3.04,6.56,8,-1.6,-2.56,-2.24,-5.28,-1.2,-5.12,2.16,-7.5,2]) Q(11.2,-18,14,-18) q(2.24,0,5.04,.72) draw(); I like the string method because you can get your hands on the points list and do your own stuff with it. pts = svgPath("M68.56-4 0 5L18.... and so on And of course, loads of extra features that svg doesn't offer... fillet, chamfer, polar, turn, forward, elaborate line extend function to extend a line to another reference which can be a polyline itself. Written lots of documentation as well. It will be a couple of days before I feel confident enough to upload the update to git-hub but right now you can find the older version there. https://github.com/dinther/pathbuilder The code below was output from pathbuilder. Closest to visuals I can do.:-) polygon([[68.56, -4], [18.4, -25.36], [18.4, -25.36], [15.405, -26.515], [12.66, -27.34], [10.165, -27.835], [7.92, -28], [7.92, -28], [5.685, -27.79], [3.78, -27.16], [2.205, -26.11], [0.96, -24.64], [0.96, -24.64], [0.4, -23.4875], [0.08, -22.19], [-9.71445e-17, -20.7475], [0.16, -19.16], [0.16, -19.16], [0.555, -17.4725], [1.18, -15.73], [2.035, -13.9325], [3.12, -12.08], [3.12, -12.08], [4.28, -10.44], [5.76, -8.56], [7.56, -6.44], [9.68, -4.08], [9.68, -4.08], [8.94, -5.37], [8.32, -6.68], [7.82, -8.01], [7.44, -9.36], [7.44, -9.36], [7.125, -11.7488], [7.38, -13.795], [8.205, -15.4988], [9.6, -16.86], [9.6, -16.86], [10.475, -17.3588], [11.5, -17.715], [12.675, -17.9288], [14, -18], [14, -18], [15.155, -17.955], [16.38, -17.82], [17.675, -17.595], [19.04, -17.28]]);
NH
nop head
Thu, Sep 23, 2021 6:44 AM

Nice. Why can't you post pictures? Can you see this?

[image: image.png]

On Thu, 23 Sept 2021 at 05:16, Paul van Dinther vandinther@gmail.com
wrote:

This out of hand exercise to implement svg path syntax to create shapes
has been a lot of fun.
Pity, I can't post a picture here but I can include openSCAD code to show
it off.

I revised my earlier version and now strictly stick to the standard SVG
one litter commands. Commands that are not part of the SVG syntax are
longer.

With exception of the arc command all 20 commands have been implemented. I
know you can of course import SVG but then it isn't parametric. It wasn't
so long ago that I needed to ask on this forum how to flatten a list!

So there are now two ways to use pathbuilder. You can simply write a svg
path string like so:

The official Nike swoosh rendered in 5 segments per spline curve.

svgShape("M68.56-4 0 5L18.4-25.36Q12.16-28 7.92-28q-4.8 0-6.96 3.36-1.36
2.16-.8 5.48t2.96 7.08q2 3.04 6.56 8-1.6-2.56-2.24-5.28-1.2-5.12
2.16-7.52Q11.2-18 14-18q2.24 0 5.04.72z")

or you can call each command by means of a module.

M(68.56,-4,0,$pb_spline=4)
L(18.4,-25.36)
Q(12.16,-28,7.92,-28)
q([-4.8,0,-6.96,3.36,-1.36,2.16,-.8,5.48])
t(2.96,7.08)
q([2,3.04,6.56,8,-1.6,-2.56,-2.24,-5.28,-1.2,-5.12,2.16,-7.5,2])
Q(11.2,-18,14,-18)
q(2.24,0,5.04,.72)
draw();

I like the string method because you can get your hands on the points list
and do your own stuff with it.

pts = svgPath("M68.56-4 0 5L18.... and so on

And of course, loads of extra features that svg doesn't offer...

fillet, chamfer, polar, turn, forward, elaborate line extend function to
extend a line to another reference which can be a
polyline itself. Written lots of documentation as well.

It will be a couple of days before I feel confident enough to upload the
update to git-hub but right now you can find the older version there.
https://github.com/dinther/pathbuilder

The code below was output from pathbuilder. Closest to visuals I can do.:-)

polygon([[68.56, -4], [18.4, -25.36], [18.4, -25.36], [15.405, -26.515],
[12.66, -27.34], [10.165, -27.835], [7.92, -28], [7.92, -28], [5.685,
-27.79], [3.78, -27.16], [2.205, -26.11], [0.96, -24.64], [0.96, -24.64],
[0.4, -23.4875], [0.08, -22.19], [-9.71445e-17, -20.7475], [0.16, -19.16],
[0.16, -19.16], [0.555, -17.4725], [1.18, -15.73], [2.035, -13.9325],
[3.12, -12.08], [3.12, -12.08], [4.28, -10.44], [5.76, -8.56], [7.56,
-6.44], [9.68, -4.08], [9.68, -4.08], [8.94, -5.37], [8.32, -6.68], [7.82,
-8.01], [7.44, -9.36], [7.44, -9.36], [7.125, -11.7488], [7.38, -13.795],
[8.205, -15.4988], [9.6, -16.86], [9.6, -16.86], [10.475, -17.3588], [11.5,
-17.715], [12.675, -17.9288], [14, -18], [14, -18], [15.155, -17.955],
[16.38, -17.82], [17.675, -17.595], [19.04, -17.28]]);


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

Nice. Why can't you post pictures? Can you see this? [image: image.png] On Thu, 23 Sept 2021 at 05:16, Paul van Dinther <vandinther@gmail.com> wrote: > This out of hand exercise to implement svg path syntax to create shapes > has been a lot of fun. > Pity, I can't post a picture here but I can include openSCAD code to show > it off. > > I revised my earlier version and now strictly stick to the standard SVG > one litter commands. Commands that are not part of the SVG syntax are > longer. > > With exception of the arc command all 20 commands have been implemented. I > know you can of course import SVG but then it isn't parametric. It wasn't > so long ago that I needed to ask on this forum how to flatten a list! > > So there are now two ways to use pathbuilder. You can simply write a svg > path string like so: > > The official Nike swoosh rendered in 5 segments per spline curve. > > svgShape("M68.56-4 0 5L18.4-25.36Q12.16-28 7.92-28q-4.8 0-6.96 3.36-1.36 > 2.16-.8 5.48t2.96 7.08q2 3.04 6.56 8-1.6-2.56-2.24-5.28-1.2-5.12 > 2.16-7.52Q11.2-18 14-18q2.24 0 5.04.72z") > > or you can call each command by means of a module. > > M(68.56,-4,0,$pb_spline=4) > L(18.4,-25.36) > Q(12.16,-28,7.92,-28) > q([-4.8,0,-6.96,3.36,-1.36,2.16,-.8,5.48]) > t(2.96,7.08) > q([2,3.04,6.56,8,-1.6,-2.56,-2.24,-5.28,-1.2,-5.12,2.16,-7.5,2]) > Q(11.2,-18,14,-18) > q(2.24,0,5.04,.72) > draw(); > > I like the string method because you can get your hands on the points list > and do your own stuff with it. > > pts = svgPath("M68.56-4 0 5L18.... and so on > > And of course, loads of extra features that svg doesn't offer... > > fillet, chamfer, polar, turn, forward, elaborate line extend function to > extend a line to another reference which can be a > polyline itself. Written lots of documentation as well. > > It will be a couple of days before I feel confident enough to upload the > update to git-hub but right now you can find the older version there. > https://github.com/dinther/pathbuilder > > The code below was output from pathbuilder. Closest to visuals I can do.:-) > > polygon([[68.56, -4], [18.4, -25.36], [18.4, -25.36], [15.405, -26.515], > [12.66, -27.34], [10.165, -27.835], [7.92, -28], [7.92, -28], [5.685, > -27.79], [3.78, -27.16], [2.205, -26.11], [0.96, -24.64], [0.96, -24.64], > [0.4, -23.4875], [0.08, -22.19], [-9.71445e-17, -20.7475], [0.16, -19.16], > [0.16, -19.16], [0.555, -17.4725], [1.18, -15.73], [2.035, -13.9325], > [3.12, -12.08], [3.12, -12.08], [4.28, -10.44], [5.76, -8.56], [7.56, > -6.44], [9.68, -4.08], [9.68, -4.08], [8.94, -5.37], [8.32, -6.68], [7.82, > -8.01], [7.44, -9.36], [7.44, -9.36], [7.125, -11.7488], [7.38, -13.795], > [8.205, -15.4988], [9.6, -16.86], [9.6, -16.86], [10.475, -17.3588], [11.5, > -17.715], [12.675, -17.9288], [14, -18], [14, -18], [15.155, -17.955], > [16.38, -17.82], [17.675, -17.595], [19.04, -17.28]]); > > > _______________________________________________ > OpenSCAD mailing list > To unsubscribe send an email to discuss-leave@lists.openscad.org >
D
dpa
Thu, Sep 23, 2021 11:28 AM

great idea !!

but it doesn't work for me:
I placed the "pathbuilder.scad" into my lib folder and tested your code in
OpenSCAD

use <pathbuilder.scad>
svgShape("M68.56-4 0 5L18.4-25.36Q12.16-28 7.92-28q-4.8 0-6.96 3.36-1.36
2.16-.8 5.48t2.96 7.08q2 3.04 6.56 8-1.6-2.56-2.24-5.28-1.2-5.12
2.16-7.52Q11.2-18 14-18q2.24 0 5.04.72z")

--> unknown module 'svgShape'.

or using single lines:
use <pathbuilder.scad>
M(68.56,-4,0,$pb_spline=4)
L(18.4,-25.36)
...
draw();

--> unknown module 'M'
If I remove the "M" line: unknown variable '$pb__pts'

and so on.. what have I missed?

Am Do., 23. Sept. 2021 um 06:16 Uhr schrieb Paul van Dinther <
vandinther@gmail.com>:

This out of hand exercise to implement svg path syntax to create shapes
has been a lot of fun.
Pity, I can't post a picture here but I can include openSCAD code to show
it off.

I revised my earlier version and now strictly stick to the standard SVG
one litter commands. Commands that are not part of the SVG syntax are
longer.

With exception of the arc command all 20 commands have been implemented. I
know you can of course import SVG but then it isn't parametric. It wasn't
so long ago that I needed to ask on this forum how to flatten a list!

So there are now two ways to use pathbuilder. You can simply write a svg
path string like so:

The official Nike swoosh rendered in 5 segments per spline curve.

svgShape("M68.56-4 0 5L18.4-25.36Q12.16-28 7.92-28q-4.8 0-6.96 3.36-1.36
2.16-.8 5.48t2.96 7.08q2 3.04 6.56 8-1.6-2.56-2.24-5.28-1.2-5.12
2.16-7.52Q11.2-18 14-18q2.24 0 5.04.72z")

or you can call each command by means of a module.

M(68.56,-4,0,$pb_spline=4)
L(18.4,-25.36)
Q(12.16,-28,7.92,-28)
q([-4.8,0,-6.96,3.36,-1.36,2.16,-.8,5.48])
t(2.96,7.08)
q([2,3.04,6.56,8,-1.6,-2.56,-2.24,-5.28,-1.2,-5.12,2.16,-7.5,2])
Q(11.2,-18,14,-18)
q(2.24,0,5.04,.72)
draw();

I like the string method because you can get your hands on the points list
and do your own stuff with it.

pts = svgPath("M68.56-4 0 5L18.... and so on

And of course, loads of extra features that svg doesn't offer...

fillet, chamfer, polar, turn, forward, elaborate line extend function to
extend a line to another reference which can be a
polyline itself. Written lots of documentation as well.

It will be a couple of days before I feel confident enough to upload the
update to git-hub but right now you can find the older version there.
https://github.com/dinther/pathbuilder

The code below was output from pathbuilder. Closest to visuals I can do.:-)

polygon([[68.56, -4], [18.4, -25.36], [18.4, -25.36], [15.405, -26.515],
[12.66, -27.34], [10.165, -27.835], [7.92, -28], [7.92, -28], [5.685,
-27.79], [3.78, -27.16], [2.205, -26.11], [0.96, -24.64], [0.96, -24.64],
[0.4, -23.4875], [0.08, -22.19], [-9.71445e-17, -20.7475], [0.16, -19.16],
[0.16, -19.16], [0.555, -17.4725], [1.18, -15.73], [2.035, -13.9325],
[3.12, -12.08], [3.12, -12.08], [4.28, -10.44], [5.76, -8.56], [7.56,
-6.44], [9.68, -4.08], [9.68, -4.08], [8.94, -5.37], [8.32, -6.68], [7.82,
-8.01], [7.44, -9.36], [7.44, -9.36], [7.125, -11.7488], [7.38, -13.795],
[8.205, -15.4988], [9.6, -16.86], [9.6, -16.86], [10.475, -17.3588], [11.5,
-17.715], [12.675, -17.9288], [14, -18], [14, -18], [15.155, -17.955],
[16.38, -17.82], [17.675, -17.595], [19.04, -17.28]]);


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

great idea !! but it doesn't work for me: I placed the "pathbuilder.scad" into my lib folder and tested your code in OpenSCAD use <pathbuilder.scad> svgShape("M68.56-4 0 5L18.4-25.36Q12.16-28 7.92-28q-4.8 0-6.96 3.36-1.36 2.16-.8 5.48t2.96 7.08q2 3.04 6.56 8-1.6-2.56-2.24-5.28-1.2-5.12 2.16-7.52Q11.2-18 14-18q2.24 0 5.04.72z") --> unknown module 'svgShape'. or using single lines: use <pathbuilder.scad> M(68.56,-4,0,$pb_spline=4) L(18.4,-25.36) ... draw(); --> unknown module 'M' If I remove the "M" line: unknown variable '$pb__pts' and so on.. what have I missed? Am Do., 23. Sept. 2021 um 06:16 Uhr schrieb Paul van Dinther < vandinther@gmail.com>: > This out of hand exercise to implement svg path syntax to create shapes > has been a lot of fun. > Pity, I can't post a picture here but I can include openSCAD code to show > it off. > > I revised my earlier version and now strictly stick to the standard SVG > one litter commands. Commands that are not part of the SVG syntax are > longer. > > With exception of the arc command all 20 commands have been implemented. I > know you can of course import SVG but then it isn't parametric. It wasn't > so long ago that I needed to ask on this forum how to flatten a list! > > So there are now two ways to use pathbuilder. You can simply write a svg > path string like so: > > The official Nike swoosh rendered in 5 segments per spline curve. > > svgShape("M68.56-4 0 5L18.4-25.36Q12.16-28 7.92-28q-4.8 0-6.96 3.36-1.36 > 2.16-.8 5.48t2.96 7.08q2 3.04 6.56 8-1.6-2.56-2.24-5.28-1.2-5.12 > 2.16-7.52Q11.2-18 14-18q2.24 0 5.04.72z") > > or you can call each command by means of a module. > > M(68.56,-4,0,$pb_spline=4) > L(18.4,-25.36) > Q(12.16,-28,7.92,-28) > q([-4.8,0,-6.96,3.36,-1.36,2.16,-.8,5.48]) > t(2.96,7.08) > q([2,3.04,6.56,8,-1.6,-2.56,-2.24,-5.28,-1.2,-5.12,2.16,-7.5,2]) > Q(11.2,-18,14,-18) > q(2.24,0,5.04,.72) > draw(); > > I like the string method because you can get your hands on the points list > and do your own stuff with it. > > pts = svgPath("M68.56-4 0 5L18.... and so on > > And of course, loads of extra features that svg doesn't offer... > > fillet, chamfer, polar, turn, forward, elaborate line extend function to > extend a line to another reference which can be a > polyline itself. Written lots of documentation as well. > > It will be a couple of days before I feel confident enough to upload the > update to git-hub but right now you can find the older version there. > https://github.com/dinther/pathbuilder > > The code below was output from pathbuilder. Closest to visuals I can do.:-) > > polygon([[68.56, -4], [18.4, -25.36], [18.4, -25.36], [15.405, -26.515], > [12.66, -27.34], [10.165, -27.835], [7.92, -28], [7.92, -28], [5.685, > -27.79], [3.78, -27.16], [2.205, -26.11], [0.96, -24.64], [0.96, -24.64], > [0.4, -23.4875], [0.08, -22.19], [-9.71445e-17, -20.7475], [0.16, -19.16], > [0.16, -19.16], [0.555, -17.4725], [1.18, -15.73], [2.035, -13.9325], > [3.12, -12.08], [3.12, -12.08], [4.28, -10.44], [5.76, -8.56], [7.56, > -6.44], [9.68, -4.08], [9.68, -4.08], [8.94, -5.37], [8.32, -6.68], [7.82, > -8.01], [7.44, -9.36], [7.44, -9.36], [7.125, -11.7488], [7.38, -13.795], > [8.205, -15.4988], [9.6, -16.86], [9.6, -16.86], [10.475, -17.3588], [11.5, > -17.715], [12.675, -17.9288], [14, -18], [14, -18], [15.155, -17.955], > [16.38, -17.82], [17.675, -17.595], [19.04, -17.28]]); > > > _______________________________________________ > OpenSCAD mailing list > To unsubscribe send an email to discuss-leave@lists.openscad.org >
TP
Torsten Paul
Thu, Sep 23, 2021 11:39 AM

On 23.09.21 13:28, dpa wrote:

and so on.. what have I missed?

That part of the original post:

It will be a couple of days before I feel confident
enough to upload the update to git-hub but right now
you can find the older version there.

(I did too first :-)

ciao,
Torsten.

On 23.09.21 13:28, dpa wrote: > and so on.. what have I missed? That part of the original post: > It will be a couple of days before I feel confident > enough to upload the update to git-hub but right now > you can find the older version there. (I did too first :-) ciao, Torsten.
D
dpa
Fri, Sep 24, 2021 3:13 PM

Am Do., 23. Sept. 2021 um 13:39 Uhr schrieb Torsten Paul <
Torsten.Paul@gmx.de>:

On 23.09.21 13:28, dpa wrote:

and so on.. what have I missed?

That part of the original post:

It will be a couple of days before I feel confident
enough to upload the update to git-hub but right now
you can find the older version there.

Thank you Torsten.
I just saw the link and tried without reading this "details" :)

@Paul: I searched for exactly this (the example in your mail) for some
weeks before.
The Background: I hit a weird limit in OpenSCAD when using the great
possibilities of BOSL2: in some categories the library can only handle
paths, but svg import is only a 3d object (no way to get paths out of svg
import !?!). Strange, but ok.. It's both open source, so there must be a
solution, right?
In Inkscape it is pretty simple to copy these svg objects like
M 0,0 H 60 C 60,10 25,4 15,15 4,25 10,60 0,60 Z
out of XML Editor. If there is a library, or any other possibility, to get
clean scad-paths by just pasting these svg paths.. It would be great!

I emphasize my deep interest in this project!

best
Dietrich

Am Do., 23. Sept. 2021 um 13:39 Uhr schrieb Torsten Paul < Torsten.Paul@gmx.de>: > On 23.09.21 13:28, dpa wrote: > > and so on.. what have I missed? > > That part of the original post: > > > It will be a couple of days before I feel confident > > enough to upload the update to git-hub but right now > > you can find the older version there. > Thank you Torsten. I just saw the link and tried without reading this "details" :) @Paul: I searched for exactly this (the example in your mail) for some weeks before. The Background: I hit a weird limit in OpenSCAD when using the great possibilities of BOSL2: in some categories the library can only handle paths, but svg import is only a 3d object (no way to get paths out of svg import !?!). Strange, but ok.. It's both open source, so there must be a solution, right? In Inkscape it is pretty simple to copy these svg objects like M 0,0 H 60 C 60,10 25,4 15,15 4,25 10,60 0,60 Z out of XML Editor. If there is a library, or any other possibility, to get clean scad-paths by just pasting these svg paths.. It would be great! I emphasize my deep interest in this project! best Dietrich
AM
Adrian Mariano
Fri, Sep 24, 2021 8:18 PM

Note that OpenSCAD has a fundamental limit that once you create
geometry there's no way to get any information out.  Geometry is like
a black hole.  So OpenSCAD can read SVG files but it turns them into
geometry.  No way to get information out.  For BOSL2 we are forced to
work on paths because there's no way to get information out of
geometry.  It's the same problem, really.  And OpenSCAD has no file
reading commands, so there's no way to write a file reader to read SVG
files into path data.

It should actually be pretty easy to find a convertor that will take
an SVG file and give you a coordinate list so that you can produce a
path, but this pathbuilder library looks like it could potentially
provide a nice solution to the problem that stays within OpenSCAD.

On Fri, Sep 24, 2021 at 11:13 AM dpa sc@pankd.de wrote:

Am Do., 23. Sept. 2021 um 13:39 Uhr schrieb Torsten Paul Torsten.Paul@gmx.de:

On 23.09.21 13:28, dpa wrote:

and so on.. what have I missed?

That part of the original post:

It will be a couple of days before I feel confident
enough to upload the update to git-hub but right now
you can find the older version there.

Thank you Torsten.
I just saw the link and tried without reading this "details" :)

@Paul: I searched for exactly this (the example in your mail) for some weeks before.
The Background: I hit a weird limit in OpenSCAD when using the great possibilities of BOSL2: in some categories the library can only handle paths, but svg import is only a 3d object (no way to get paths out of svg import !?!). Strange, but ok.. It's both open source, so there must be a solution, right?
In Inkscape it is pretty simple to copy these svg objects like
M 0,0 H 60 C 60,10 25,4 15,15 4,25 10,60 0,60 Z
out of XML Editor. If there is a library, or any other possibility, to get clean scad-paths by just pasting these svg paths.. It would be great!

I emphasize my deep interest in this project!

best
Dietrich


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

Note that OpenSCAD has a fundamental limit that once you create geometry there's no way to get any information out. Geometry is like a black hole. So OpenSCAD can read SVG files but it turns them into geometry. No way to get information out. For BOSL2 we are forced to work on paths because there's no way to get information out of geometry. It's the same problem, really. And OpenSCAD has no file reading commands, so there's no way to write a file reader to read SVG files into path data. It should actually be pretty easy to find a convertor that will take an SVG file and give you a coordinate list so that you can produce a path, but this pathbuilder library looks like it could potentially provide a nice solution to the problem that stays within OpenSCAD. On Fri, Sep 24, 2021 at 11:13 AM dpa <sc@pankd.de> wrote: > > Am Do., 23. Sept. 2021 um 13:39 Uhr schrieb Torsten Paul <Torsten.Paul@gmx.de>: >> >> On 23.09.21 13:28, dpa wrote: >> > and so on.. what have I missed? >> >> That part of the original post: >> >> > It will be a couple of days before I feel confident >> > enough to upload the update to git-hub but right now >> > you can find the older version there. > > > > Thank you Torsten. > I just saw the link and tried without reading this "details" :) > > @Paul: I searched for exactly this (the example in your mail) for some weeks before. > The Background: I hit a weird limit in OpenSCAD when using the great possibilities of BOSL2: in some categories the library can only handle paths, but svg import is only a 3d object (no way to get paths out of svg import !?!). Strange, but ok.. It's both open source, so there must be a solution, right? > In Inkscape it is pretty simple to copy these svg objects like > M 0,0 H 60 C 60,10 25,4 15,15 4,25 10,60 0,60 Z > out of XML Editor. If there is a library, or any other possibility, to get clean scad-paths by just pasting these svg paths.. It would be great! > > I emphasize my deep interest in this project! > > best > Dietrich > _______________________________________________ > OpenSCAD mailing list > To unsubscribe send an email to discuss-leave@lists.openscad.org
M
MichaelAtOz
Sun, Sep 26, 2021 11:20 PM

And OpenSCAD has no file reading commands,

In case you missed it see attached. It's not polished, but you can get at file data.

-----Original Message-----
From: Adrian Mariano [mailto:avm4@cornell.edu]
Sent: Sat, 25 Sep 2021 06:19
To: OpenSCAD general discussion
Subject: [OpenSCAD] Re: 2D PathBuilder

Note that OpenSCAD has a fundamental limit that once you create
geometry there's no way to get any information out.  Geometry is like
a black hole.  So OpenSCAD can read SVG files but it turns them into
geometry.  No way to get information out.  For BOSL2 we are forced to
work on paths because there's no way to get information out of
geometry.  It's the same problem, really.  And OpenSCAD has no file
reading commands, so there's no way to write a file reader to read SVG
files into path data.

It should actually be pretty easy to find a convertor that will take
an SVG file and give you a coordinate list so that you can produce a
path, but this pathbuilder library looks like it could potentially
provide a nice solution to the problem that stays within OpenSCAD.

--
This email has been checked for viruses by AVG.
https://www.avg.com

> And OpenSCAD has no file reading commands, In case you missed it see attached. It's not polished, but you can get at file data. > -----Original Message----- > From: Adrian Mariano [mailto:avm4@cornell.edu] > Sent: Sat, 25 Sep 2021 06:19 > To: OpenSCAD general discussion > Subject: [OpenSCAD] Re: 2D PathBuilder > > Note that OpenSCAD has a fundamental limit that once you create > geometry there's no way to get any information out. Geometry is like > a black hole. So OpenSCAD can read SVG files but it turns them into > geometry. No way to get information out. For BOSL2 we are forced to > work on paths because there's no way to get information out of > geometry. It's the same problem, really. And OpenSCAD has no file > reading commands, so there's no way to write a file reader to read SVG > files into path data. > > It should actually be pretty easy to find a convertor that will take > an SVG file and give you a coordinate list so that you can produce a > path, but this pathbuilder library looks like it could potentially > provide a nice solution to the problem that stays within OpenSCAD. > -- This email has been checked for viruses by AVG. https://www.avg.com
SP
Sanjeev Prabhakar
Mon, Sep 27, 2021 3:56 PM

wonderful work done by you.
thanks for sharing
regards
Sanjeev

On Thu, 23 Sept 2021 at 09:46, Paul van Dinther vandinther@gmail.com
wrote:

This out of hand exercise to implement svg path syntax to create shapes
has been a lot of fun.
Pity, I can't post a picture here but I can include openSCAD code to show
it off.

I revised my earlier version and now strictly stick to the standard SVG
one litter commands. Commands that are not part of the SVG syntax are
longer.

With exception of the arc command all 20 commands have been implemented. I
know you can of course import SVG but then it isn't parametric. It wasn't
so long ago that I needed to ask on this forum how to flatten a list!

So there are now two ways to use pathbuilder. You can simply write a svg
path string like so:

The official Nike swoosh rendered in 5 segments per spline curve.

svgShape("M68.56-4 0 5L18.4-25.36Q12.16-28 7.92-28q-4.8 0-6.96 3.36-1.36
2.16-.8 5.48t2.96 7.08q2 3.04 6.56 8-1.6-2.56-2.24-5.28-1.2-5.12
2.16-7.52Q11.2-18 14-18q2.24 0 5.04.72z")

or you can call each command by means of a module.

M(68.56,-4,0,$pb_spline=4)
L(18.4,-25.36)
Q(12.16,-28,7.92,-28)
q([-4.8,0,-6.96,3.36,-1.36,2.16,-.8,5.48])
t(2.96,7.08)
q([2,3.04,6.56,8,-1.6,-2.56,-2.24,-5.28,-1.2,-5.12,2.16,-7.5,2])
Q(11.2,-18,14,-18)
q(2.24,0,5.04,.72)
draw();

I like the string method because you can get your hands on the points list
and do your own stuff with it.

pts = svgPath("M68.56-4 0 5L18.... and so on

And of course, loads of extra features that svg doesn't offer...

fillet, chamfer, polar, turn, forward, elaborate line extend function to
extend a line to another reference which can be a
polyline itself. Written lots of documentation as well.

It will be a couple of days before I feel confident enough to upload the
update to git-hub but right now you can find the older version there.
https://github.com/dinther/pathbuilder

The code below was output from pathbuilder. Closest to visuals I can do.:-)

polygon([[68.56, -4], [18.4, -25.36], [18.4, -25.36], [15.405, -26.515],
[12.66, -27.34], [10.165, -27.835], [7.92, -28], [7.92, -28], [5.685,
-27.79], [3.78, -27.16], [2.205, -26.11], [0.96, -24.64], [0.96, -24.64],
[0.4, -23.4875], [0.08, -22.19], [-9.71445e-17, -20.7475], [0.16, -19.16],
[0.16, -19.16], [0.555, -17.4725], [1.18, -15.73], [2.035, -13.9325],
[3.12, -12.08], [3.12, -12.08], [4.28, -10.44], [5.76, -8.56], [7.56,
-6.44], [9.68, -4.08], [9.68, -4.08], [8.94, -5.37], [8.32, -6.68], [7.82,
-8.01], [7.44, -9.36], [7.44, -9.36], [7.125, -11.7488], [7.38, -13.795],
[8.205, -15.4988], [9.6, -16.86], [9.6, -16.86], [10.475, -17.3588], [11.5,
-17.715], [12.675, -17.9288], [14, -18], [14, -18], [15.155, -17.955],
[16.38, -17.82], [17.675, -17.595], [19.04, -17.28]]);


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

wonderful work done by you. thanks for sharing regards Sanjeev On Thu, 23 Sept 2021 at 09:46, Paul van Dinther <vandinther@gmail.com> wrote: > This out of hand exercise to implement svg path syntax to create shapes > has been a lot of fun. > Pity, I can't post a picture here but I can include openSCAD code to show > it off. > > I revised my earlier version and now strictly stick to the standard SVG > one litter commands. Commands that are not part of the SVG syntax are > longer. > > With exception of the arc command all 20 commands have been implemented. I > know you can of course import SVG but then it isn't parametric. It wasn't > so long ago that I needed to ask on this forum how to flatten a list! > > So there are now two ways to use pathbuilder. You can simply write a svg > path string like so: > > The official Nike swoosh rendered in 5 segments per spline curve. > > svgShape("M68.56-4 0 5L18.4-25.36Q12.16-28 7.92-28q-4.8 0-6.96 3.36-1.36 > 2.16-.8 5.48t2.96 7.08q2 3.04 6.56 8-1.6-2.56-2.24-5.28-1.2-5.12 > 2.16-7.52Q11.2-18 14-18q2.24 0 5.04.72z") > > or you can call each command by means of a module. > > M(68.56,-4,0,$pb_spline=4) > L(18.4,-25.36) > Q(12.16,-28,7.92,-28) > q([-4.8,0,-6.96,3.36,-1.36,2.16,-.8,5.48]) > t(2.96,7.08) > q([2,3.04,6.56,8,-1.6,-2.56,-2.24,-5.28,-1.2,-5.12,2.16,-7.5,2]) > Q(11.2,-18,14,-18) > q(2.24,0,5.04,.72) > draw(); > > I like the string method because you can get your hands on the points list > and do your own stuff with it. > > pts = svgPath("M68.56-4 0 5L18.... and so on > > And of course, loads of extra features that svg doesn't offer... > > fillet, chamfer, polar, turn, forward, elaborate line extend function to > extend a line to another reference which can be a > polyline itself. Written lots of documentation as well. > > It will be a couple of days before I feel confident enough to upload the > update to git-hub but right now you can find the older version there. > https://github.com/dinther/pathbuilder > > The code below was output from pathbuilder. Closest to visuals I can do.:-) > > polygon([[68.56, -4], [18.4, -25.36], [18.4, -25.36], [15.405, -26.515], > [12.66, -27.34], [10.165, -27.835], [7.92, -28], [7.92, -28], [5.685, > -27.79], [3.78, -27.16], [2.205, -26.11], [0.96, -24.64], [0.96, -24.64], > [0.4, -23.4875], [0.08, -22.19], [-9.71445e-17, -20.7475], [0.16, -19.16], > [0.16, -19.16], [0.555, -17.4725], [1.18, -15.73], [2.035, -13.9325], > [3.12, -12.08], [3.12, -12.08], [4.28, -10.44], [5.76, -8.56], [7.56, > -6.44], [9.68, -4.08], [9.68, -4.08], [8.94, -5.37], [8.32, -6.68], [7.82, > -8.01], [7.44, -9.36], [7.44, -9.36], [7.125, -11.7488], [7.38, -13.795], > [8.205, -15.4988], [9.6, -16.86], [9.6, -16.86], [10.475, -17.3588], [11.5, > -17.715], [12.675, -17.9288], [14, -18], [14, -18], [15.155, -17.955], > [16.38, -17.82], [17.675, -17.595], [19.04, -17.28]]); > > > _______________________________________________ > OpenSCAD mailing list > To unsubscribe send an email to discuss-leave@lists.openscad.org >