discuss@lists.openscad.org

OpenSCAD general discussion Mailing-list

View all threads

SVG Export

S
shadowwynd
Thu, Mar 26, 2015 3:30 AM

Firstly, thanks for implementing SVG export.  It works much better than DXF
export for things like a laser cutter.  DXF files import a circle as a group
of lines, each of which is cut by the laser.  If doing multiple passes, the
cutter does each line segment n times, then moves onto the next segment.
The SVG version cuts the complete circle before cutting the next pass.  This
reduces a lot of whiplash on the laser or cutting head.

Here is my slight problem.  OpenSCAD is unitless, but de facto standard is
that the units are in millimeters.  An STL file (also unitless) that I make
in OpenSCAD with "cube(10)" pulls up on every single slicing program I have
tried as a 10mm cube.  When OpenSCAD makes a SVG file, it does not put any
units in for the dimensions.

In Inkscape, which I use for my vector editing, Inkscape defaults to px as
the default unit if no unit is given.  This means that anything I try to cut
from OpenSCAD is much smaller than it needs to be.  I can fix this in the
.SVG file itself by changing this line in the file thusly:

<svg width="216" height="280"  ....> to <svg width="216mm" height="280mm"
....>

According to the SVG standards at:
http://www.w3.org/TR/SVG/types.html#DataTypeLength
the datatype "length" used in the length and width descriptors of an SVG
file can be just a number, or a number plus a unit (10, 10mm, 10cm, 10in,
etc.)  Could it be an option to set the units of an SVG file so that we
don't need to edit the file first?  I personally would have no problem if
the default SVG units for the width and height were set to mm, since that is
the defacto standard for 3D models, it would make sense to be that way for
2D models as well.

Thoughts?

--
View this message in context: http://forum.openscad.org/SVG-Export-tp12216.html
Sent from the OpenSCAD mailing list archive at Nabble.com.

Firstly, thanks for implementing SVG export. It works much better than DXF export for things like a laser cutter. DXF files import a circle as a group of lines, each of which is cut by the laser. If doing multiple passes, the cutter does each line segment n times, then moves onto the next segment. The SVG version cuts the complete circle before cutting the next pass. This reduces a lot of whiplash on the laser or cutting head. Here is my slight problem. OpenSCAD is unitless, but de facto standard is that the units are in millimeters. An STL file (also unitless) that I make in OpenSCAD with "cube(10)" pulls up on every single slicing program I have tried as a 10mm cube. When OpenSCAD makes a SVG file, it does not put any units in for the dimensions. In Inkscape, which I use for my vector editing, Inkscape defaults to px as the default unit if no unit is given. This means that anything I try to cut from OpenSCAD is much smaller than it needs to be. I can fix this in the .SVG file itself by changing this line in the file thusly: <svg width="216" height="280" ....> to <svg width="216mm" height="280mm" ....> According to the SVG standards at: http://www.w3.org/TR/SVG/types.html#DataTypeLength the datatype "length" used in the length and width descriptors of an SVG file can be just a number, or a number plus a unit (10, 10mm, 10cm, 10in, etc.) Could it be an option to set the units of an SVG file so that we don't need to edit the file first? I personally would have no problem if the default SVG units for the width and height were set to mm, since that is the defacto standard for 3D models, it would make sense to be that way for 2D models as well. Thoughts? -- View this message in context: http://forum.openscad.org/SVG-Export-tp12216.html Sent from the OpenSCAD mailing list archive at Nabble.com.
TP
Torsten Paul
Thu, Mar 26, 2015 10:48 AM

I personally would have no problem if the default SVG units for the
width and height were set to mm, since that is the defacto standard
for 3D models, it would make sense to be that way for 2D models as well.

Forcing the units to mm where OpenSCAD has none could then just break
things for other people (strangely the Inkscape on my system seems to
default to mm when importing unit-less files).

Thoughts?

I think the most useful option is https://github.com/openscad/openscad/issues/649
which would allow to specify properties for the export. This would help
not only SVG but other formats too.

ciao,
Torsten.

> I personally would have no problem if the default SVG units for the > width and height were set to mm, since that is the defacto standard > for 3D models, it would make sense to be that way for 2D models as well. > Forcing the units to mm where OpenSCAD has none could then just break things for other people (strangely the Inkscape on my system seems to default to mm when importing unit-less files). > Thoughts? > I think the most useful option is https://github.com/openscad/openscad/issues/649 which would allow to specify properties for the export. This would help not only SVG but other formats too. ciao, Torsten.
TH
Tim Hawkins
Thu, Mar 26, 2015 12:01 PM

Why not have a option in prefferences for "default SVG output units" that
defaults to "none".

Then everybody can be happy happy shiney.

On Thu, Mar 26, 2015, 18:48 Torsten Paul Torsten.Paul@gmx.de wrote:

I personally would have no problem if the default SVG units for the
width and height were set to mm, since that is the defacto standard
for 3D models, it would make sense to be that way for 2D models as well.

Forcing the units to mm where OpenSCAD has none could then just break
things for other people (strangely the Inkscape on my system seems to
default to mm when importing unit-less files).

Thoughts?

I think the most useful option is https://github.com/openscad/
openscad/issues/649
which would allow to specify properties for the export. This would help
not only SVG but other formats too.

ciao,
Torsten.


OpenSCAD mailing list
Discuss@lists.openscad.org
http://lists.openscad.org/mailman/listinfo/discuss_lists.openscad.org

Why not have a option in prefferences for "default SVG output units" that defaults to "none". Then everybody can be happy happy shiney. On Thu, Mar 26, 2015, 18:48 Torsten Paul <Torsten.Paul@gmx.de> wrote: > > I personally would have no problem if the default SVG units for the > > width and height were set to mm, since that is the defacto standard > > for 3D models, it would make sense to be that way for 2D models as well. > > > Forcing the units to mm where OpenSCAD has none could then just break > things for other people (strangely the Inkscape on my system seems to > default to mm when importing unit-less files). > > > Thoughts? > > > I think the most useful option is https://github.com/openscad/ > openscad/issues/649 > which would allow to specify properties for the export. This would help > not only SVG but other formats too. > > ciao, > Torsten. > > _______________________________________________ > OpenSCAD mailing list > Discuss@lists.openscad.org > http://lists.openscad.org/mailman/listinfo/discuss_lists.openscad.org >
P
pim
Thu, Mar 26, 2015 1:04 PM

On 26-3-2015 4:30, shadowwynd wrote:

Firstly, thanks for implementing SVG export.  It works much better than DXF
export for things like a laser cutter.  DXF files import a circle as a group
of lines, each of which is cut by the laser.  If doing multiple passes, the
cutter does each line segment n times, then moves onto the next segment.
The SVG version cuts the complete circle before cutting the next pass.  This
reduces a lot of whiplash on the laser or cutting head.

Here is my slight problem.  OpenSCAD is unitless, but de facto standard is
that the units are in millimeters.  An STL file (also unitless) that I make
in OpenSCAD with "cube(10)" pulls up on every single slicing program I have
tried as a 10mm cube.  When OpenSCAD makes a SVG file, it does not put any
units in for the dimensions.

In Inkscape, which I use for my vector editing, Inkscape defaults to px as
the default unit if no unit is given.  This means that anything I try to cut
from OpenSCAD is much smaller than it needs to be.

The default unit in Inkscape  can be changed via the /Document
Properties/ dialog
(File → Document Properties... (Shift+Ctrl+D))

On 26-3-2015 4:30, shadowwynd wrote: > Firstly, thanks for implementing SVG export. It works much better than DXF > export for things like a laser cutter. DXF files import a circle as a group > of lines, each of which is cut by the laser. If doing multiple passes, the > cutter does each line segment n times, then moves onto the next segment. > The SVG version cuts the complete circle before cutting the next pass. This > reduces a lot of whiplash on the laser or cutting head. > > Here is my slight problem. OpenSCAD is unitless, but de facto standard is > that the units are in millimeters. An STL file (also unitless) that I make > in OpenSCAD with "cube(10)" pulls up on every single slicing program I have > tried as a 10mm cube. When OpenSCAD makes a SVG file, it does not put any > units in for the dimensions. > > In Inkscape, which I use for my vector editing, Inkscape defaults to px as > the default unit if no unit is given. This means that anything I try to cut > from OpenSCAD is much smaller than it needs to be. The default unit in Inkscape can be changed via the /Document Properties/ dialog (File → Document Properties... (**Shift*+*Ctrl*+*D**))
S
shadowwynd
Thu, Mar 26, 2015 4:47 PM

I know that the units can be changed in Inkscape; but this doesn't
retroactively apply.

  1. Make drawing in OpenSCAD 200 wide , save as .SVG
  2. Open file in Inkscape 0.91, comes in as 200 px wide  (60 mm)
  3. If I change the default units in Document Properties, it doesn't change
    the file that was just imported, it changes the rulers; instead of being 200
    px wide, it is now 60 mm wide.

I just tried changing the default.svg to have a default unit of mm but it
still opens up unitless files as px.

A drop-down on SVG Export that remembers the last setting would be nice.

--
View this message in context: http://forum.openscad.org/SVG-Export-tp12216p12229.html
Sent from the OpenSCAD mailing list archive at Nabble.com.

I know that the units can be changed in Inkscape; but this doesn't retroactively apply. 1) Make drawing in OpenSCAD 200 wide , save as .SVG 2) Open file in Inkscape 0.91, comes in as 200 px wide (60 mm) 3) If I change the default units in Document Properties, it doesn't change the file that was just imported, it changes the rulers; instead of being 200 px wide, it is now 60 mm wide. I just tried changing the default.svg to have a default unit of mm but it still opens up unitless files as px. A drop-down on SVG Export that remembers the last setting would be nice. -- View this message in context: http://forum.openscad.org/SVG-Export-tp12216p12229.html Sent from the OpenSCAD mailing list archive at Nabble.com.
IN
Ian Nichols
Thu, Mar 26, 2015 5:27 PM

On 26 March 2015 at 16:47, shadowwynd shadowwynd@gmail.com wrote:

I know that the units can be changed in Inkscape; but this doesn't
retroactively apply.

  1. Make drawing in OpenSCAD 200 wide , save as .SVG
  2. Open file in Inkscape 0.91, comes in as 200 px wide  (60 mm)
  3. If I change the default units in Document Properties, it doesn't change
    the file that was just imported, it changes the rulers; instead of being
    200
    px wide, it is now 60 mm wide.

Presumably that's because there's a setting somewhere that says there are
3.33 pixels per mm?  <desperate hope> is it possible to change that to 1
pixel per mm?</desperate hope>.

Ian

--
Stand firm for what you believe in, until and unless logic and experience
prove you wrong.  Remember: when the emperor looks naked, the emperor is
naked, the truth and a lie are not "sort-of the same thing" and there is
no aspect, no facet, no moment of life that can't be improved with pizza.

-Daria Morgendorffer

On 26 March 2015 at 16:47, shadowwynd <shadowwynd@gmail.com> wrote: > I know that the units can be changed in Inkscape; but this doesn't > retroactively apply. > > 1) Make drawing in OpenSCAD 200 wide , save as .SVG > 2) Open file in Inkscape 0.91, comes in as 200 px wide (60 mm) > 3) If I change the default units in Document Properties, it doesn't change > the file that was just imported, it changes the rulers; instead of being > 200 > px wide, it is now 60 mm wide. > Presumably that's because there's a setting somewhere that says there are 3.33 pixels per mm? <desperate hope> is it possible to change that to 1 pixel per mm?</desperate hope>. Ian -- Stand firm for what you believe in, until and unless logic and experience prove you wrong. Remember: when the emperor looks naked, the emperor *is* naked, the truth and a lie are not "sort-of the same thing" and there is no aspect, no facet, no moment of life that can't be improved with pizza. -Daria Morgendorffer
S
shadowwynd
Thu, Mar 26, 2015 6:21 PM

For my own use in the interim, this python script (drag-n drop using this
link:
https://mindlesstechnology.wordpress.com/2008/03/29/make-python-scripts-droppable-in-windows/
https://mindlesstechnology.wordpress.com/2008/03/29/make-python-scripts-droppable-in-windows/
) converts any unit (including none) to mm.

SVG_dim_to_mm.py http://forum.openscad.org/file/n12232/SVG_dim_to_mm.py

--
View this message in context: http://forum.openscad.org/SVG-Export-tp12216p12232.html
Sent from the OpenSCAD mailing list archive at Nabble.com.

For my own use in the interim, this python script (drag-n drop using this link: https://mindlesstechnology.wordpress.com/2008/03/29/make-python-scripts-droppable-in-windows/ <https://mindlesstechnology.wordpress.com/2008/03/29/make-python-scripts-droppable-in-windows/> ) converts any unit (including none) to mm. SVG_dim_to_mm.py <http://forum.openscad.org/file/n12232/SVG_dim_to_mm.py> -- View this message in context: http://forum.openscad.org/SVG-Export-tp12216p12232.html Sent from the OpenSCAD mailing list archive at Nabble.com.
LG
Laurence Gonsalves
Thu, Mar 26, 2015 6:50 PM

On Thu, Mar 26, 2015 at 10:27 AM, Ian Nichols ian.a.nichols@gmail.com
wrote:

Presumably that's because there's a setting somewhere that says there are
3.33 pixels per mm?  <desperate hope> is it possible to change that to 1
pixel per mm?</desperate hope>.

Based on http://wiki.inkscape.org/wiki/index.php/Units_In_Inkscape it
sounds like 1px = 1/96in in SVG, as in CSS.

It is possible to change the default unit in Inkscape and get it to
"stick", by creating a new document, changing the document properties, and
then saving over the default.svg file (on Linux it seems to be located in
~/.config/inkscape/templates/). This only affects new documents, though. I
tried doing this, and then loading an OpenSCAD-exported-SVG into Inkscape,
and it still comes up as using px.

Having per-file-type export options makes a lot of sense to me, as you're
bound to run into situations where you have to lose/add some information in
the export process and there is no "one right way" to do that. Inkscape and
GIMP both have option dialogs for exporting: https://imgur.com/a/g0pXW

GIMP displays the options dialogs after the file chooser, as it uses the
file chooser itself to select the file type. The options available depend
on the file type, and are sticky. Inkscape instead has a (dockable)
modeless dialog -- pretty much a tool palette -- that handles exporting,
and has a button to make the file chooser appear.

Personally, I think the approach GIMP uses is easier to understand, and I'd
guess that it'd also be the easier one to implement in OpenSCAD.

On Thu, Mar 26, 2015 at 10:27 AM, Ian Nichols <ian.a.nichols@gmail.com> wrote: > > Presumably that's because there's a setting somewhere that says there are > 3.33 pixels per mm? <desperate hope> is it possible to change that to 1 > pixel per mm?</desperate hope>. > Based on http://wiki.inkscape.org/wiki/index.php/Units_In_Inkscape it sounds like 1px = 1/96in in SVG, as in CSS. It is possible to change the default unit in Inkscape and get it to "stick", by creating a new document, changing the document properties, and then saving over the default.svg file (on Linux it seems to be located in ~/.config/inkscape/templates/). This only affects new documents, though. I tried doing this, and then loading an OpenSCAD-exported-SVG into Inkscape, and it still comes up as using px. Having per-file-type export options makes a lot of sense to me, as you're bound to run into situations where you have to lose/add some information in the export process and there is no "one right way" to do that. Inkscape and GIMP both have option dialogs for exporting: https://imgur.com/a/g0pXW GIMP displays the options dialogs after the file chooser, as it uses the file chooser itself to select the file type. The options available depend on the file type, and are sticky. Inkscape instead has a (dockable) modeless dialog -- pretty much a tool palette -- that handles exporting, and has a button to make the file chooser appear. Personally, I think the approach GIMP uses is easier to understand, and I'd guess that it'd also be the easier one to implement in OpenSCAD.
NH
nop head
Fri, Mar 27, 2015 12:04 PM

Yes, I don't think SVG is compatible with unit less dimensions. Without
explicit units It defaults to px, so isn't really compatible with OpenScad
and STLs unit less philosophy.  I think units need to be added when the
file is exported and they should default to mm but be configurable.

For Mendel90 I wrote a Python DXF to SVG convertor and that specifies mm in
the SVG to make it work in InkScape.

On 26 March 2015 at 18:50, Laurence Gonsalves <from-openscad@xenomachina.com

wrote:

On Thu, Mar 26, 2015 at 10:27 AM, Ian Nichols ian.a.nichols@gmail.com
wrote:

Presumably that's because there's a setting somewhere that says there are
3.33 pixels per mm?  <desperate hope> is it possible to change that to 1
pixel per mm?</desperate hope>.

Based on http://wiki.inkscape.org/wiki/index.php/Units_In_Inkscape it
sounds like 1px = 1/96in in SVG, as in CSS.

It is possible to change the default unit in Inkscape and get it to
"stick", by creating a new document, changing the document properties, and
then saving over the default.svg file (on Linux it seems to be located in
~/.config/inkscape/templates/). This only affects new documents, though. I
tried doing this, and then loading an OpenSCAD-exported-SVG into Inkscape,
and it still comes up as using px.

Having per-file-type export options makes a lot of sense to me, as you're
bound to run into situations where you have to lose/add some information in
the export process and there is no "one right way" to do that. Inkscape and
GIMP both have option dialogs for exporting: https://imgur.com/a/g0pXW

GIMP displays the options dialogs after the file chooser, as it uses the
file chooser itself to select the file type. The options available depend
on the file type, and are sticky. Inkscape instead has a (dockable)
modeless dialog -- pretty much a tool palette -- that handles exporting,
and has a button to make the file chooser appear.

Personally, I think the approach GIMP uses is easier to understand, and
I'd guess that it'd also be the easier one to implement in OpenSCAD.


OpenSCAD mailing list
Discuss@lists.openscad.org
http://lists.openscad.org/mailman/listinfo/discuss_lists.openscad.org

Yes, I don't think SVG is compatible with unit less dimensions. Without explicit units It defaults to px, so isn't really compatible with OpenScad and STLs unit less philosophy. I think units need to be added when the file is exported and they should default to mm but be configurable. For Mendel90 I wrote a Python DXF to SVG convertor and that specifies mm in the SVG to make it work in InkScape. On 26 March 2015 at 18:50, Laurence Gonsalves <from-openscad@xenomachina.com > wrote: > On Thu, Mar 26, 2015 at 10:27 AM, Ian Nichols <ian.a.nichols@gmail.com> > wrote: > >> >> Presumably that's because there's a setting somewhere that says there are >> 3.33 pixels per mm? <desperate hope> is it possible to change that to 1 >> pixel per mm?</desperate hope>. >> > > Based on http://wiki.inkscape.org/wiki/index.php/Units_In_Inkscape it > sounds like 1px = 1/96in in SVG, as in CSS. > > It is possible to change the default unit in Inkscape and get it to > "stick", by creating a new document, changing the document properties, and > then saving over the default.svg file (on Linux it seems to be located in > ~/.config/inkscape/templates/). This only affects new documents, though. I > tried doing this, and then loading an OpenSCAD-exported-SVG into Inkscape, > and it still comes up as using px. > > Having per-file-type export options makes a lot of sense to me, as you're > bound to run into situations where you have to lose/add some information in > the export process and there is no "one right way" to do that. Inkscape and > GIMP both have option dialogs for exporting: https://imgur.com/a/g0pXW > > GIMP displays the options dialogs after the file chooser, as it uses the > file chooser itself to select the file type. The options available depend > on the file type, and are sticky. Inkscape instead has a (dockable) > modeless dialog -- pretty much a tool palette -- that handles exporting, > and has a button to make the file chooser appear. > > Personally, I think the approach GIMP uses is easier to understand, and > I'd guess that it'd also be the easier one to implement in OpenSCAD. > > _______________________________________________ > OpenSCAD mailing list > Discuss@lists.openscad.org > http://lists.openscad.org/mailman/listinfo/discuss_lists.openscad.org > >