<p>Two options:</p>

<ol>
<li>Use <code>TRACE2SCAD</code> (<a href="http://aggregate.org/MAKE/TRACE2SCAD" rel="nofollow noreferrer">http://aggregate.org/MAKE/TRACE2SCAD</a>)</li>
<li>For the more adventurous: Dig up the old pull-request for the suggested <code>trace()</code> module: <a href="https://github.com/openscad/openscad/pull/1110" rel="nofollow noreferrer">https://github.com/openscad/openscad/pull/1110</a></li>
</ol>

CC BY-SA 3.0
2017-04-16T20:08:21.590Z
Thank you Marius.  I will be taking a look at trace2scad as another arrow in my quiver.
EvilTeach
CC BY-SA 3.0
2017-04-16T16:58:41.827Z
2017-04-16T16:58:41.827Z
kintel
<p>You could have done that with OpenSCAD, there are instructions for extruding. </p>

<p>Personally, I'd just do a 1 altitude copy with 
<a href="http://www.thingiverse.com/thing:1981938" rel="nofollow noreferrer">Image 2 STL 2 Heightmap Mesh Converter Generator</a>, then rotate in OpenSCAD. It's called <code>rotate_extrude()</code> and is used for seashells.</p>

<p>In MeshLab you can use <em>Laplacian Smooth</em> to depixelate/antialias it.</p>

CC BY-SA 3.0
2017-04-18T16:10:05.360Z
interesting.  I did the whole thing in openscad.
EvilTeach
CC BY-SA 3.0
2017-04-18T04:00:29.720Z
2017-05-02T22:47:17.187Z
2017-05-02T22:47:17.187Z
bandybabboon
<p>As you are already familiar with OpenSCAD, consider to use the <a href="https://en.wikibooks.org/wiki/OpenSCAD_User_Manual/3D_to_2D_Projection" rel="nofollow noreferrer">projection() function</a> to accomplish your goal.</p>

<p>If you allow for an interpretation that one can cast a shadow of the part on a surface below, it becomes a 2D representation of the part. This is effectively how projection works in OpenSCAD.</p>

<p>Note that the part image below is centered in x, y, z and the cut/projection action takes place at the z = 0 plane:</p>

<p><a href="https://i.sstatic.net/7USA0.png" rel="nofollow noreferrer"><img src="https://i.sstatic.net/7USA0.png" alt="sample model image"></a></p>

<p>When the function is applied to this model, the result is a non-contiguous 2d image:</p>

<p><a href="https://i.sstatic.net/COw50.png" rel="nofollow noreferrer"><img src="https://i.sstatic.net/COw50.png" alt="projected cut image"></a></p>

<p>When the cut parameter is ignored or set to false, the image which results is effectively an orthogonal shadow of the entire object, rather than a selected slice:</p>

<p><a href="https://i.sstatic.net/ffOe7.png" rel="nofollow noreferrer"><img src="https://i.sstatic.net/ffOe7.png" alt="flat shadow image"></a></p>

<p>It gets better, of course. In OpenSCAD, the translate, rotate and scale functions apply. One can tip a model over, resize it, spin it around, combine with the cut parameter and get any combination of 2d image from the original model:</p>

<p><a href="https://i.sstatic.net/cU1sN.png" rel="nofollow noreferrer"><img src="https://i.sstatic.net/cU1sN.png" alt="rotated model image"></a></p>

<p><a href="https://i.sstatic.net/HlXSF.png" rel="nofollow noreferrer"><img src="https://i.sstatic.net/HlXSF.png" alt="shadow rotated model"></a></p>

<p>It's important to note that OpenSCAD does provide non-zero thickness to these projections when rendered, or maybe when previewed. I always get those two swapped around. As your objective is a 2D result, you may be able to select from PNG (save as image) or Export as DXF or SVG.</p>

<p>Re-reading your post, I also missed part of a more useful answer. Once you have the profile you desire, you can use the <a href="https://en.wikibooks.org/wiki/OpenSCAD_User_Manual/2D_to_3D_Extrusion" rel="nofollow noreferrer">rotate_extrude function</a> on the profile you generate. Despite the non-zero thickness, it uses the zero-thickness aspect to create the model from that function.</p>

<p>That aspect of the answer is left as an exercise for the reader, as the options are many and results can be complex.</p>

CC BY-SA 3.0
2017-04-16T18:39:47.853Z
Clearly it is time to review all of the open scad functions.
EvilTeach
CC BY-SA 3.0
2017-04-16T15:52:51.100Z
2017-04-16T15:52:51.100Z
fred_dot_u
<p>The overall goal is to create a print of the liberty bell.  No clapper is needed.  The support beam is not needed.  I am just looking to mimic the outside shape of the bell.  After an application of Google-fu I found this image.  It has been cleaned up and cropped a bit.</p>

<p><a href="https://i.sstatic.net/HTg2W.png" rel="nofollow noreferrer"><img src="https://i.sstatic.net/HTg2W.png" alt="enter image description here"></a></p>

<p>In OpenScad the surface function was applied to the png to generate a height model.   I subtracted out a few cubes, and eventually got it down to a layer of about .1 height.</p>

<p>My Evil (pun intended) plan is to get it down to a 2d model.  Then by shifting a copy of model from itself, and subtracting the two.  That should leave just the curve.  Then rotate_extrude the curve to generate the actual bell at the desired thickness.</p>

<p>I see the problem coming. If the model is layered down to zero height it will vanish. Leaving me nothing to rotate.</p>

<p>So on to the question.</p>

<p><strong>Is there any tool or technique to turn the image into a 2d openscad object or failing that is there another way to approach the problem?</strong></p>

<p><a href="https://i.sstatic.net/0joh6.jpg" rel="nofollow noreferrer"><img src="https://i.sstatic.net/0joh6.jpg" alt=""></a> </p>

<p>The direction that fred pointed me at is viable. I didn't use the actual image shown here, but a manually generated one from OpenScad.  As a proof of concept the technique works well.</p>

CC BY-SA 3.0
2017-04-16T18:45:26.853Z
This sounds like what you're asking for is a 2D drawing file of a 3D part in a given plane? If so, Solidworks, Solid Edge, and Autocad are all fantastic at this, not sure about OpenSCAD though.
Diesel
<2d><openscad>
Is there a technique for turning an image into a 2d model?
EvilTeach
# Is there a technique for turning an image into a 2d model?

(Asked by: username_0 on 2017-04-16)

The overall goal is to create a print of the liberty bell. No clapper is needed. The support beam is not needed. I am just looking to mimic the outside shape of the bell. After an application of Google-fu I found this image. It has been cleaned up and cropped a bit.

[![enter image description here](https://i.sstatic.net/HTg2W.png)](https://i.sstatic.net/HTg2W.png)

In OpenScad the surface function was applied to the png to generate a height model. I subtracted out a few cubes, and eventually got it down to a layer of about .1 height.

My Evil (pun intended) plan is to get it down to a 2d model. Then by shifting a copy of model from itself, and subtracting the two. That should leave just the curve. Then rotate\_extrude the curve to generate the actual bell at the desired thickness.

I see the problem coming. If the model is layered down to zero height it will vanish. Leaving me nothing to rotate.

So on to the question.

**Is there any tool or technique to turn the image into a 2d openscad object or failing that is there another way to approach the problem?**

[![](https://i.sstatic.net/0joh6.jpg)](https://i.sstatic.net/0joh6.jpg)

The direction that fred pointed me at is viable. I didn't use the actual image shown here, but a manually generated one from OpenScad. As a proof of concept the technique works well.

**Tags:** 2d, openscad

> **Comments:**
> **username_1**: This sounds like what you're asking for is a 2D drawing file of a 3D part in a given plane? If so, Solidworks, Solid Edge, and Autocad are all fantastic at this, not sure about OpenSCAD though.  

---

## 3 answers

### Answer by username_4 on 2017-04-16. Score: 3 | Accepted answer

As you are already familiar with OpenSCAD, consider to use the [projection() function](https://en.wikibooks.org/wiki/OpenSCAD_User_Manual/3D_to_2D_Projection) to accomplish your goal.

If you allow for an interpretation that one can cast a shadow of the part on a surface below, it becomes a 2D representation of the part. This is effectively how projection works in OpenSCAD.

Note that the part image below is centered in x, y, z and the cut/projection action takes place at the z = 0 plane:

[![sample model image](https://i.sstatic.net/7USA0.png)](https://i.sstatic.net/7USA0.png)

When the function is applied to this model, the result is a non-contiguous 2d image:

[![projected cut image](https://i.sstatic.net/COw50.png)](https://i.sstatic.net/COw50.png)

When the cut parameter is ignored or set to false, the image which results is effectively an orthogonal shadow of the entire object, rather than a selected slice:

[![flat shadow image](https://i.sstatic.net/ffOe7.png)](https://i.sstatic.net/ffOe7.png)

It gets better, of course. In OpenSCAD, the translate, rotate and scale functions apply. One can tip a model over, resize it, spin it around, combine with the cut parameter and get any combination of 2d image from the original model:

[![rotated model image](https://i.sstatic.net/cU1sN.png)](https://i.sstatic.net/cU1sN.png)

[![shadow rotated model](https://i.sstatic.net/HlXSF.png)](https://i.sstatic.net/HlXSF.png)

It's important to note that OpenSCAD does provide non-zero thickness to these projections when rendered, or maybe when previewed. I always get those two swapped around. As your objective is a 2D result, you may be able to select from PNG (save as image) or Export as DXF or SVG.

Re-reading your post, I also missed part of a more useful answer. Once you have the profile you desire, you can use the [rotate\_extrude function](https://en.wikibooks.org/wiki/OpenSCAD_User_Manual/2D_to_3D_Extrusion) on the profile you generate. Despite the non-zero thickness, it uses the zero-thickness aspect to create the model from that function.

That aspect of the answer is left as an exercise for the reader, as the options are many and results can be complex.

> **Comments:**
> **username_0**: Clearly it is time to review all of the open scad functions.  

---

### Answer by username_2 on 2017-04-16. Score: 2

Two options:

1. Use `TRACE2SCAD` (<http://aggregate.org/MAKE/TRACE2SCAD>)
2. For the more adventurous: Dig up the old pull-request for the suggested `trace()` module: <https://github.com/openscad/openscad/pull/1110>

> **Comments:**
> **username_0**: Thank you Marius.  I will be taking a look at trace2scad as another arrow in my quiver.  

---

### Answer by username_3 on 2017-04-18. Score: 0

You could have done that with OpenSCAD, there are instructions for extruding.

Personally, I'd just do a 1 altitude copy with
[Image 2 STL 2 Heightmap Mesh Converter Generator](http://www.thingiverse.com/thing:1981938), then rotate in OpenSCAD. It's called `rotate_extrude()` and is used for seashells.

In MeshLab you can use *Laplacian Smooth* to depixelate/antialias it.

> **Comments:**
> **username_0**: interesting.  I did the whole thing in openscad.  

---

