discuss@lists.openscad.org

OpenSCAD general discussion Mailing-list

View all threads

SVG to points array

JW
Joe Weinpert
Thu, Feb 2, 2023 4:22 PM

Is there a way to read an SVG file or to convert an SVG path to generate a
usable points array?

Is there a way to read an SVG file or to convert an SVG path to generate a usable points array?
NH
nop head
Thu, Feb 2, 2023 4:28 PM

No but there is an OpenSCAD exporter plugin for InkScape so you can read an
SVG and export an OpenSCAD file that has a point list in it.

Also there is a Python library that will read SVGs and it would be easy to
write a script that outputs a point list in OpenSCAD format if you know
Python.

On Thu, 2 Feb 2023 at 16:22, Joe Weinpert joe.weinpert@gmail.com wrote:

Is there a way to read an SVG file or to convert an SVG path to generate a
usable points array?


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

No but there is an OpenSCAD exporter plugin for InkScape so you can read an SVG and export an OpenSCAD file that has a point list in it. Also there is a Python library that will read SVGs and it would be easy to write a script that outputs a point list in OpenSCAD format if you know Python. On Thu, 2 Feb 2023 at 16:22, Joe Weinpert <joe.weinpert@gmail.com> wrote: > Is there a way to read an SVG file or to convert an SVG path to generate a > usable points array? > > _______________________________________________ > OpenSCAD mailing list > To unsubscribe send an email to discuss-leave@lists.openscad.org >
SL
Steve Lelievre
Thu, Feb 2, 2023 5:19 PM

If you're an Inkscape user and and if the starting shape is a single
loop and if it's a one-time exercise (so a manual process isn't too much
of a burden) :

If your starting shape in Inkscape has bezier curves, use 'Flatten
Beziers' to convert the shape to have only straight segments.

Open the XML editor, and select the desired path. Make sure 'Show
Attributes' is turned on.

Copy the d attribute and paste to something like MS Word. You'll have a
leading and trailing control symbol, such M and Z, which should be deleted.

That should leave a list of point coordinates with a space between each
point and a comma between the x and y values. Then use Replace All to
adjust the layout as required.

The method is a bit of a kludge, but it has worked for me a few times.

Steve

On 2023-02-02 8:22 a.m., Joe Weinpert wrote:

Is there a way to read an SVG file or to convert an SVG path to
generate a usable points array?


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

If you're an Inkscape user and and if the starting shape is a single loop and if it's a one-time exercise (so a manual process isn't too much of a burden) : If your starting shape in Inkscape has bezier curves, use 'Flatten Beziers' to convert the shape to have only straight segments. Open the XML editor, and select the desired path. Make sure 'Show Attributes' is turned on. Copy the d attribute and paste to something like MS Word. You'll have a leading and trailing control symbol, such M and Z, which should be deleted. That should leave a list of point coordinates with a space between each point and a comma between the x and y values. Then use Replace All to adjust the layout as required. The method is a bit of a kludge, but it has worked for me a few times. Steve On 2023-02-02 8:22 a.m., Joe Weinpert wrote: > Is there a way to read an SVG file or to convert an SVG path to > generate a usable points array? > > > _______________________________________________ > OpenSCAD mailing list > To unsubscribe send an email todiscuss-leave@lists.openscad.org
JB
Jordan Brown
Thu, Feb 2, 2023 6:04 PM

On 2/2/2023 8:22 AM, Joe Weinpert wrote:

Is there a way to read an SVG file or to convert an SVG path to
generate a usable points array?

No, but pull request #4478
https://github.com/openscad/openscad/pull/4478 can so maybe it's coming.

On 2/2/2023 8:22 AM, Joe Weinpert wrote: > Is there a way to read an SVG file or to convert an SVG path to > generate a usable points array? No, but pull request #4478 <https://github.com/openscad/openscad/pull/4478> can so maybe it's coming.
JB
Jordan Brown
Thu, Feb 2, 2023 6:06 PM

On 2/2/2023 9:19 AM, Steve Lelievre wrote:

If you're an Inkscape user and and if the starting shape is a single
loop and if it's a one-time exercise (so a manual process isn't too
much of a burden) :

Reading out the Bézier control points and feeding them into an OpenSCAD
Bézier function isn't awful.

On 2/2/2023 9:19 AM, Steve Lelievre wrote: > > If you're an Inkscape user and and if the starting shape is a single > loop and if it's a one-time exercise (so a manual process isn't too > much of a burden) : > Reading out the Bézier control points and feeding them into an OpenSCAD Bézier function isn't awful.
JW
Joe Weinpert
Thu, Feb 2, 2023 6:17 PM

Thanks Steve

This is actually the way I have been doing it except I use UltraEdit
instead of MS Word for replacements within the Inkscape path.

Also, when I do the Extensions -> Modify Path -> Flatten Beziers each point
gets separated by the " L " (line to) svg command.  By replacing these with
"],[" it works great.

On Thu, Feb 2, 2023 at 12:20 PM Steve Lelievre <
steve.lelievre.canada@gmail.com> wrote:

If you're an Inkscape user and and if the starting shape is a single loop
and if it's a one-time exercise (so a manual process isn't too much of a
burden) :

If your starting shape in Inkscape has bezier curves, use 'Flatten
Beziers' to convert the shape to have only straight segments.

Open the XML editor, and select the desired path. Make sure 'Show
Attributes' is turned on.

Copy the d attribute and paste to something like MS Word. You'll have a
leading and trailing control symbol, such M and Z, which should be deleted.

That should leave a list of point coordinates with a space between each
point and a comma between the x and y values. Then use Replace All to
adjust the layout as required.

The method is a bit of a kludge, but it has worked for me a few times.

Steve

On 2023-02-02 8:22 a.m., Joe Weinpert wrote:

Is there a way to read an SVG file or to convert an SVG path to generate a
usable points array?


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


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

Thanks Steve This is actually the way I have been doing it except I use UltraEdit instead of MS Word for replacements within the Inkscape path. Also, when I do the Extensions -> Modify Path -> Flatten Beziers each point gets separated by the " L " (line to) svg command. By replacing these with "],[" it works great. On Thu, Feb 2, 2023 at 12:20 PM Steve Lelievre < steve.lelievre.canada@gmail.com> wrote: > If you're an Inkscape user and and if the starting shape is a single loop > and if it's a one-time exercise (so a manual process isn't too much of a > burden) : > > If your starting shape in Inkscape has bezier curves, use 'Flatten > Beziers' to convert the shape to have only straight segments. > > Open the XML editor, and select the desired path. Make sure 'Show > Attributes' is turned on. > > Copy the d attribute and paste to something like MS Word. You'll have a > leading and trailing control symbol, such M and Z, which should be deleted. > > That should leave a list of point coordinates with a space between each > point and a comma between the x and y values. Then use Replace All to > adjust the layout as required. > > The method is a bit of a kludge, but it has worked for me a few times. > > Steve > > > > > > On 2023-02-02 8:22 a.m., Joe Weinpert wrote: > > Is there a way to read an SVG file or to convert an SVG path to generate a > usable points array? > > > _______________________________________________ > OpenSCAD mailing list > To unsubscribe send an email to discuss-leave@lists.openscad.org > > _______________________________________________ > OpenSCAD mailing list > To unsubscribe send an email to discuss-leave@lists.openscad.org >
AM
Adrian Mariano
Thu, Feb 2, 2023 9:09 PM

There is the pathbuilder library which says:

function svgPoints(s)
//
//  Processes a SVG path string and returns a 2D point list.

Sounds like it does what the original poster wants?

https://github.com/dinther/pathbuilder

On Thu, Feb 2, 2023 at 1:18 PM Joe Weinpert joe.weinpert@gmail.com wrote:

Thanks Steve

This is actually the way I have been doing it except I use UltraEdit
instead of MS Word for replacements within the Inkscape path.

Also, when I do the Extensions -> Modify Path -> Flatten Beziers each
point gets separated by the " L " (line to) svg command.  By replacing
these with "],[" it works great.

On Thu, Feb 2, 2023 at 12:20 PM Steve Lelievre <
steve.lelievre.canada@gmail.com> wrote:

If you're an Inkscape user and and if the starting shape is a single loop
and if it's a one-time exercise (so a manual process isn't too much of a
burden) :

If your starting shape in Inkscape has bezier curves, use 'Flatten
Beziers' to convert the shape to have only straight segments.

Open the XML editor, and select the desired path. Make sure 'Show
Attributes' is turned on.

Copy the d attribute and paste to something like MS Word. You'll have a
leading and trailing control symbol, such M and Z, which should be deleted.

That should leave a list of point coordinates with a space between each
point and a comma between the x and y values. Then use Replace All to
adjust the layout as required.

The method is a bit of a kludge, but it has worked for me a few times.

Steve

On 2023-02-02 8:22 a.m., Joe Weinpert wrote:

Is there a way to read an SVG file or to convert an SVG path to generate
a usable points array?


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


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


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

There is the pathbuilder library which says: function svgPoints(s) // // Processes a SVG path string and returns a 2D point list. Sounds like it does what the original poster wants? https://github.com/dinther/pathbuilder On Thu, Feb 2, 2023 at 1:18 PM Joe Weinpert <joe.weinpert@gmail.com> wrote: > Thanks Steve > > This is actually the way I have been doing it except I use UltraEdit > instead of MS Word for replacements within the Inkscape path. > > Also, when I do the Extensions -> Modify Path -> Flatten Beziers each > point gets separated by the " L " (line to) svg command. By replacing > these with "],[" it works great. > > > > On Thu, Feb 2, 2023 at 12:20 PM Steve Lelievre < > steve.lelievre.canada@gmail.com> wrote: > >> If you're an Inkscape user and and if the starting shape is a single loop >> and if it's a one-time exercise (so a manual process isn't too much of a >> burden) : >> >> If your starting shape in Inkscape has bezier curves, use 'Flatten >> Beziers' to convert the shape to have only straight segments. >> >> Open the XML editor, and select the desired path. Make sure 'Show >> Attributes' is turned on. >> >> Copy the d attribute and paste to something like MS Word. You'll have a >> leading and trailing control symbol, such M and Z, which should be deleted. >> >> That should leave a list of point coordinates with a space between each >> point and a comma between the x and y values. Then use Replace All to >> adjust the layout as required. >> >> The method is a bit of a kludge, but it has worked for me a few times. >> >> Steve >> >> >> >> >> >> On 2023-02-02 8:22 a.m., Joe Weinpert wrote: >> >> Is there a way to read an SVG file or to convert an SVG path to generate >> a usable points array? >> >> >> _______________________________________________ >> OpenSCAD mailing list >> To unsubscribe send an email to discuss-leave@lists.openscad.org >> >> _______________________________________________ >> OpenSCAD mailing list >> To unsubscribe send an email to discuss-leave@lists.openscad.org >> > _______________________________________________ > OpenSCAD mailing list > To unsubscribe send an email to discuss-leave@lists.openscad.org >