discuss@lists.openscad.org

OpenSCAD general discussion Mailing-list

View all threads

SVG import recenter

TP
Torsten Paul
Sun, Jan 21, 2018 4:52 PM

On 21.01.2018 16:26, Parkinbot wrote:

Despite fixing the bug, wouldn't it be nice (and easy to implement)
to have a function syntax for svg-import? Something like:

Nice, yes. Easy to implement, no.
Already the definition of the data structure is not trivial. That
example code will not simply work with an SVG describing a ring
(= circle with a hole) as it would just union a big and a smaller
circle so the hole would be lost.

ciao,
Torsten.

On 21.01.2018 16:26, Parkinbot wrote: > Despite fixing the bug, wouldn't it be nice (and easy to implement) > to have a function syntax for svg-import? Something like: > Nice, yes. Easy to implement, no. Already the definition of the data structure is not trivial. That example code will not simply work with an SVG describing a ring (= circle with a hole) as it would just union a big and a smaller circle so the hole would be lost. ciao, Torsten.
P
Parkinbot
Sun, Jan 21, 2018 5:14 PM

You are right. My fast example did not cover these cases, but this is not
important for functional stuff, where you can discover negative volumes.

This code

$fn = 4;
difference()
{
circle(20);
circle(10);
}

will give:

<?xml version="1.0" standalone="no"?> <!DOCTYPE svg PUBLIC &quot;-//W3C//DTD SVG 1.1//EN&quot; &quot;http://www.w3.org/Graphics/SVG/1.1/DTD/svg11.dtd&quot;>

<svg width="40mm" height="40mm" viewBox="-20 -20 40 40" xmlns="http://www.w3.org/2000/svg" version="1.1">

<title>OpenSCAD Model</title> <path d=" M 20,-0 L 0,-20 L -20,-0 L 0,20 z M -10,-0 L 0,-10 L 10,-0 L 0,10 z " stroke="black" fill="lightgray" stroke-width="0.5"/> </svg>

and I would expect to get this:
import = [[[ 20,-0 ],[ 0,-20 ],[-20,-0], [ 0,20]], [[ -10,-0],[ 0,-10 ],[
10,-0 ],[ 0,10]]];

which results from the M sections. Currently I am using my own converter for
this. But it would be a nice to have. Also equivalentkly for STLs.

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

You are right. My fast example did not cover these cases, but this is not important for functional stuff, where you can discover negative volumes. This code $fn = 4; difference() { circle(20); circle(10); } will give: <?xml version="1.0" standalone="no"?> <!DOCTYPE svg PUBLIC &quot;-//W3C//DTD SVG 1.1//EN&quot; &quot;http://www.w3.org/Graphics/SVG/1.1/DTD/svg11.dtd&quot;> <svg width="40mm" height="40mm" viewBox="-20 -20 40 40" xmlns="http://www.w3.org/2000/svg" version="1.1"> <title>OpenSCAD Model</title> <path d=" M 20,-0 L 0,-20 L -20,-0 L 0,20 z M -10,-0 L 0,-10 L 10,-0 L 0,10 z " stroke="black" fill="lightgray" stroke-width="0.5"/> </svg> and I would expect to get this: import = [[[ 20,-0 ],[ 0,-20 ],[-20,-0], [ 0,20]], [[ -10,-0],[ 0,-10 ],[ 10,-0 ],[ 0,10]]]; which results from the M sections. Currently I am using my own converter for this. But it would be a nice to have. Also equivalentkly for STLs. -- Sent from: http://forum.openscad.org/