Nabble has removed Mailing-list integration.
Posts created here DO NOT GET SENT TO THE MAILING LIST.
Mailing-list emails DO NOT GET POSTED TO THE FORUM.
So basically the Forum is now out of date, we are looking into migrating the history.

For now you should send emails, people will see them, discuss@lists.openscad.org.

Sampling positions in an imported .SVG?

classic Classic list List threaded Threaded
5 messages Options
Reply | Threaded
Open this post in threaded view
|

Sampling positions in an imported .SVG?

amundsen
Hello,

Say we import an .SVG file containing a single curved line.

Is there some way to get a y position for any x?

The idea is to use a .svg as a kind of path to position shapes and solids.




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

_______________________________________________
OpenSCAD mailing list
[hidden email]
http://lists.openscad.org/mailman/listinfo/discuss_lists.openscad.org
Reply | Threaded
Open this post in threaded view
|

Re: Sampling positions in an imported .SVG?

OpenSCAD mailing list-2
How is the curve defined in the svg?

If it is a path of points, you can look for the X value and get the Y or find the 2 points between which your target X lies and then do a simple interpolation.
This means parsing the svg but if it is simple enough, it should not be too hard. If you want to do a better interpolation then I thnk that you are into creating a Bezier with more points and figuring how to apply your X to the formula.

If it is some other definition of a curve likeĀ  circle, you can get the center and radius and calculate the 2 possible Ys

Interesting problem. You might want to explain a bit more about the application to see if anyone has already solved the larger problem.

Ron

On 2020-06-17 3:52 p.m., amundsen wrote:
Hello,

Say we import an .SVG file containing a single curved line.

Is there some way to get a y position for any x?

The idea is to use a .svg as a kind of path to position shapes and solids.




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

_______________________________________________
OpenSCAD mailing list
[hidden email]
http://lists.openscad.org/mailman/listinfo/discuss_lists.openscad.org

-- 
Ron Wheeler
Artifact Software
438-345-3369
[hidden email]

_______________________________________________
OpenSCAD mailing list
[hidden email]
http://lists.openscad.org/mailman/listinfo/discuss_lists.openscad.org
Reply | Threaded
Open this post in threaded view
|

Re: Sampling positions in an imported .SVG?

acwest
Only way I know to do this is to parse the file yourself, except I don't think openscad has a read function

On Wed, 17 Jun 2020, 17:03 Ron Wheeler via Discuss, <[hidden email]> wrote:
How is the curve defined in the svg?

If it is a path of points, you can look for the X value and get the Y or find the 2 points between which your target X lies and then do a simple interpolation.
This means parsing the svg but if it is simple enough, it should not be too hard. If you want to do a better interpolation then I thnk that you are into creating a Bezier with more points and figuring how to apply your X to the formula.

If it is some other definition of a curve likeĀ  circle, you can get the center and radius and calculate the 2 possible Ys

Interesting problem. You might want to explain a bit more about the application to see if anyone has already solved the larger problem.

Ron

On 2020-06-17 3:52 p.m., amundsen wrote:
Hello,

Say we import an .SVG file containing a single curved line.

Is there some way to get a y position for any x?

The idea is to use a .svg as a kind of path to position shapes and solids.




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

_______________________________________________
OpenSCAD mailing list
[hidden email]
http://lists.openscad.org/mailman/listinfo/discuss_lists.openscad.org

-- 
Ron Wheeler
Artifact Software
438-345-3369
[hidden email]
_______________________________________________
OpenSCAD mailing list
[hidden email]
http://lists.openscad.org/mailman/listinfo/discuss_lists.openscad.org

_______________________________________________
OpenSCAD mailing list
[hidden email]
http://lists.openscad.org/mailman/listinfo/discuss_lists.openscad.org
Reply | Threaded
Open this post in threaded view
|

Re: Sampling positions in an imported .SVG?

amundsen
In reply to this post by amundsen
Currently it's just a theoretical question but the idea is to draw a curve in
Inkscape and save it into a .svg file then use this curve to position
objects. However in between I've seen there's a library with splines, maybe
it might be a better function. Still parsing some data from an svg might be
of some interest.



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

_______________________________________________
OpenSCAD mailing list
[hidden email]
http://lists.openscad.org/mailman/listinfo/discuss_lists.openscad.org
Reply | Threaded
Open this post in threaded view
|

Re: Sampling positions in an imported .SVG?

OpenSCAD mailing list-2
Splines sounds a lot easier.
Have you looked at an Inkscape file to see how a simple curve is represented?
I suspect that the way the curve is defined in Inkscape makes a difference in how the SVG is structured.

SVG is XML so there are a lot of tools to help in parsing it.

As long as the curve has only direction along the X axis it might not be too bad.

Ron


On 2020-06-17 5:33 p.m., amundsen wrote:
Currently it's just a theoretical question but the idea is to draw a curve in
Inkscape and save it into a .svg file then use this curve to position
objects. However in between I've seen there's a library with splines, maybe
it might be a better function. Still parsing some data from an svg might be
of some interest.



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

_______________________________________________
OpenSCAD mailing list
[hidden email]
http://lists.openscad.org/mailman/listinfo/discuss_lists.openscad.org

-- 
Ron Wheeler
Artifact Software
438-345-3369
[hidden email]

_______________________________________________
OpenSCAD mailing list
[hidden email]
http://lists.openscad.org/mailman/listinfo/discuss_lists.openscad.org