Full color SVGs to 3D

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

Full color SVGs to 3D

Miro Hrončok
Hi fellow openscadders,

I have the following use case:

I would like to transform those Fedora badges (2D images) to printable STL:


Automatically.

I have SVGs and I would like to use the color value as high of the position in STL.

What I currently am able to do:

1. generate high resolution bitmap
2. greyscale it and convert it to OpenSCAD highmap by an easy Python script
3. generate STLs with OpenSCAD (with few improvements)

It works, but has 2 disadvantages:

1. Being generated from bitmap, regardless the high resolution, the generated STL is not very nice and it has quadrillions of triangles.


2. The OpenSCAD render takes a lot of time and RAM (hours, tens of gigs)

Is there any better way? E.g. using the SVG as source somehow and not the bitmap? Note that the SVG usually has some gradients as well.

Thanks for tips,
Miro Hrončok

Telefon: +420777974800

_______________________________________________
OpenSCAD mailing list
[hidden email]
http://rocklinux.net/mailman/listinfo/openscad
http://openscad.org - https://flattr.com/thing/121566
tp3
Reply | Threaded
Open this post in threaded view
|

Re: Full color SVGs to 3D

tp3
I don't think SVG will give much improvement. The SVG import I'm working on is supposed to import the vector structure and not the actual image, so for this use case it's not helping.

Using one of the badges as input (master-wordsmith.svg) and this mini scad script:

  scale([1, 1, 0.1]) surface("test.png", invert=true);

The result does not look too bad (needs to be scaled down quite a bit - scale 0.2 in cura gives a 53x53mm object):

$ convert -density 75 master-wordsmith.svg test.png
$ file test.png
test.png: PNG image data, 266 x 266, 16-bit/color RGBA, non-interlaced
$ time /data/OpenSCAD/openscad-master/openscad -o test.stl test.scad
real 0m53.310s
user 0m53.028s
sys 0m0.304s
$ ls -la test.stl
-rw-r--r-- 1 tp users 45575416 Sep  5 14:17 test.stl

That's with the current dev snapshot. Any usage of CSG operations will likely push the runtime to hours...
-- Torsten
Reply | Threaded
Open this post in threaded view
|

Re: Full color SVGs to 3D

Miro Hrončok
Thanks for input.

1. try with 1000x1000
2. png can be imported and the python script might be skipped?
3. currently this is in the .scad file:



Miro Hrončok

Telefon: +420777974800


2014-09-05 14:26 GMT+02:00 tp3 <[hidden email]>:
I don't think SVG will give much improvement. The SVG import I'm working on
is supposed to import the vector structure and not the actual image, so for
this use case it's not helping.

Using one of the badges as input (master-wordsmith.svg) and this mini scad
script:

  scale([1, 1, 0.1]) surface("test.png", invert=true);

The result does not look too bad (needs to be scaled down quite a bit -
scale 0.2 in cura gives a 53x53mm object):

$ convert -density 75 master-wordsmith.svg test.png
$ file test.png
test.png: PNG image data, 266 x 266, 16-bit/color RGBA, non-interlaced
$ time /data/OpenSCAD/openscad-master/openscad -o test.stl test.scad
real    0m53.310s
user    0m53.028s
sys     0m0.304s
$ ls -la test.stl
-rw-r--r-- 1 tp users 45575416 Sep  5 14:17 test.stl

That's with the current dev snapshot. Any usage of CSG operations will
likely push the runtime to hours...




-----
-- Torsten
--
View this message in context: http://forum.openscad.org/Full-color-SVGs-to-3D-tp9554p9555.html
Sent from the OpenSCAD mailing list archive at Nabble.com.
_______________________________________________
OpenSCAD mailing list
[hidden email]
http://rocklinux.net/mailman/listinfo/openscad
http://openscad.org - https://flattr.com/thing/121566


_______________________________________________
OpenSCAD mailing list
[hidden email]
http://rocklinux.net/mailman/listinfo/openscad
http://openscad.org - https://flattr.com/thing/121566
Reply | Threaded
Open this post in threaded view
|

Re: Full color SVGs to 3D

ednisley
In reply to this post by Miro Hrončok
On 09/05/2014 03:01 AM, Miro Hrončok wrote:
> Is there any better way?

Because you intend to 3D print the object, there's no point in rendering
more pixels than you can print. In round numbers, 0.25 mm resolution
will hold all the detail a fused-filament printer can deliver, so resize
the grayscale image to throw out all the fine detail.

That worked surprisingly well for some chocolate molds...

Grayscale image preparation:
http://softsolder.com/2014/02/14/chocolate-mold-image-preparation-checklist/

Grayscale to STL:
http://softsolder.com/2014/02/17/chocolate-molds-software-stack/

STL to chocolate:
http://softsolder.com/2014/04/04/chocolate-molds-3d-printed-positive-plate-vs-pourable-silicone/

Closeups of the molds and chocolate show that the gritty grayscale
resolution wasn't the limiting factor:
http://softsolder.com/2014/04/10/chocolate-molds-closeups/

I eventually printed multiple mold positives and glued them on an
acrylic sheet, because the slicer could duplicate the smaller file
faster than OpenSCAD could process the plated models. That's the same
problem you ran into: OpenSCAD isn't the right hammer for processing
hugely complex files built from images.

Hope that helps get you closer to your goal...

--
Ed
softsolder.com
_______________________________________________
OpenSCAD mailing list
[hidden email]
http://rocklinux.net/mailman/listinfo/openscad
http://openscad.org - https://flattr.com/thing/121566
 --
Ed
softsolder.com
Reply | Threaded
Open this post in threaded view
|

Re: Full color SVGs to 3D

Miro Hrončok
WOW, thanks for ultimate info.

However, even with 1000x1000 image, the print is very weird on the rounded edge (ie it doesn't "curve").

Miro Hrončok

Telefon: +420777974800


2014-09-05 14:47 GMT+02:00 Ed Nisley <[hidden email]>:
On 09/05/2014 03:01 AM, Miro Hrončok wrote:
> Is there any better way?

Because you intend to 3D print the object, there's no point in rendering
more pixels than you can print. In round numbers, 0.25 mm resolution
will hold all the detail a fused-filament printer can deliver, so resize
the grayscale image to throw out all the fine detail.

That worked surprisingly well for some chocolate molds...

Grayscale image preparation:
http://softsolder.com/2014/02/14/chocolate-mold-image-preparation-checklist/

Grayscale to STL:
http://softsolder.com/2014/02/17/chocolate-molds-software-stack/

STL to chocolate:
http://softsolder.com/2014/04/04/chocolate-molds-3d-printed-positive-plate-vs-pourable-silicone/

Closeups of the molds and chocolate show that the gritty grayscale
resolution wasn't the limiting factor:
http://softsolder.com/2014/04/10/chocolate-molds-closeups/

I eventually printed multiple mold positives and glued them on an
acrylic sheet, because the slicer could duplicate the smaller file
faster than OpenSCAD could process the plated models. That's the same
problem you ran into: OpenSCAD isn't the right hammer for processing
hugely complex files built from images.

Hope that helps get you closer to your goal...

--
Ed
softsolder.com
_______________________________________________
OpenSCAD mailing list
[hidden email]
http://rocklinux.net/mailman/listinfo/openscad
http://openscad.org - https://flattr.com/thing/121566


_______________________________________________
OpenSCAD mailing list
[hidden email]
http://rocklinux.net/mailman/listinfo/openscad
http://openscad.org - https://flattr.com/thing/121566
Reply | Threaded
Open this post in threaded view
|

Re: Full color SVGs to 3D

ednisley
On 09/05/2014 09:19 AM, Miro Hrončok wrote:
> However, even with 1000x1000 image, the print is very weird
 > on the rounded edge (ie it doesn't "curve").

The STL file is about 50x50 mm, so, to get 0.25 mm resolution, you
should rescale the source image to about 200x200 pixels. That will look
*horribly* gritty, but it doesn't matter: the 3D printed plastic will
smooth everything out.

In fact, the original PNG file is about 256x256, so I did a crude
grayscale conversion and ran it through my chocolate mold process. It
emerged looking like the Tux models: a coarsely pixelated outline that
will print reasonably well.

However, those badges were not designed with low-resolution 3D printers
in mind: the surface details are too small compared to the overall badge
size. For a typical plastic thread width of 0.4 mm, the smallest
"island" will be about 0.8 mm in diameter: two threads laid side by side.

The printer also can't produce the tiny letters or images on most of the
badges, because the smallest "pen stroke" is 0.4 mm wide and that
depends on the slicer's ability to produce single-stroke features.

If you have access to a higher-resolution printer, then those numbers
will be pessimistic. Even the Shapeways "Detail" photopolymer specifies
a 0.5 mm wall and a 0.2 mm embossed detail, so it's only a factor of two
better.

Low-resolution design will be your friend, ugly though it may seem.

--
Ed
softsolder.com
_______________________________________________
OpenSCAD mailing list
[hidden email]
http://rocklinux.net/mailman/listinfo/openscad
http://openscad.org - https://flattr.com/thing/121566
 --
Ed
softsolder.com
Reply | Threaded
Open this post in threaded view
|

Re: Full color SVGs to 3D

Greg Frost
This link has a description of using Inkscape to convert an image to a vector format for exporting to dxf:
http://blog.cubehero.com/2013/11/11/how-to-generate-extruded-3d-model-from-images-in-openscad/

This link has a nice description of how to optimise the vector representation before exporting as straight lines only:
http://repraprip.blogspot.com.au/2011/05/inkscape-to-openscad-dxf-tutorial.html?m=1

Between those two you should be able to find what you need to get images into extruded polygons in openscad with your desired quality.


Sent from my iPhone

> On 6 Sep 2014, at 3:51 am, Ed Nisley <[hidden email]> wrote:
>
>> On 09/05/2014 09:19 AM, Miro Hrončok wrote:
>> However, even with 1000x1000 image, the print is very weird
>> on the rounded edge (ie it doesn't "curve").
>
> The STL file is about 50x50 mm, so, to get 0.25 mm resolution, you
> should rescale the source image to about 200x200 pixels. That will look
> *horribly* gritty, but it doesn't matter: the 3D printed plastic will
> smooth everything out.
>
> In fact, the original PNG file is about 256x256, so I did a crude
> grayscale conversion and ran it through my chocolate mold process. It
> emerged looking like the Tux models: a coarsely pixelated outline that
> will print reasonably well.
>
> However, those badges were not designed with low-resolution 3D printers
> in mind: the surface details are too small compared to the overall badge
> size. For a typical plastic thread width of 0.4 mm, the smallest
> "island" will be about 0.8 mm in diameter: two threads laid side by side.
>
> The printer also can't produce the tiny letters or images on most of the
> badges, because the smallest "pen stroke" is 0.4 mm wide and that
> depends on the slicer's ability to produce single-stroke features.
>
> If you have access to a higher-resolution printer, then those numbers
> will be pessimistic. Even the Shapeways "Detail" photopolymer specifies
> a 0.5 mm wall and a 0.2 mm embossed detail, so it's only a factor of two
> better.
>
> Low-resolution design will be your friend, ugly though it may seem.
>
> --
> Ed
> softsolder.com
> _______________________________________________
> OpenSCAD mailing list
> [hidden email]
> http://rocklinux.net/mailman/listinfo/openscad
> http://openscad.org - https://flattr.com/thing/121566
_______________________________________________
OpenSCAD mailing list
[hidden email]
http://rocklinux.net/mailman/listinfo/openscad
http://openscad.org - https://flattr.com/thing/121566