<p>Use the projection() feature of OpenSCAD to effectively generate a plane cut. Position the cube structure in such a manner that the x/y plane intersects the desired shape to be exported. Rendering the code will then generate a 2D image. Previewing the code will generate a 1 mm thick 3D model which will &quot;flatten&quot; when rendered.</p>
<p>For the image below, I did not translate the cube, merely placed the cube generation within the projection feature.</p>
<pre><code>projection(){
MengerSponge(side, order);
}
</code></pre>
<p>This rendering will export to SVG as desired. Different positioning of the cube (rotate, translate) will create different patterns.</p>
<p><a href="https://i.sstatic.net/kSCtv.png" rel="noreferrer"><img src="https://i.sstatic.net/kSCtv.png" alt="projection of cube" /></a></p>

CC BY-SA 4.0
2022-11-09T19:01:09.237Z
Don't forget [`cut=true`](https://en.wikibooks.org/wiki/OpenSCAD_User_Manual/3D_to_2D_Projection)
R.. GitHub STOP HELPING ICE
CC BY-SA 4.0
2022-11-09T21:43:13.873Z
I did forget that, yet the result is "acceptable," yes? What is the failure mode of forgetting it?
fred_dot_u
CC BY-SA 4.0
2022-11-09T22:27:54.800Z
Without `cut=true`, you get a 2D shadow of the part, not a 2D cut (union of all cuts as Z ranges over -infinity to infinity).
R.. GitHub STOP HELPING ICE
CC BY-SA 4.0
2022-11-09T22:54:11.167Z
That's useful information. Is there a link to an example model in which both circumstances are provided?
fred_dot_u
CC BY-SA 4.0
2022-11-10T00:06:07.267Z
In tthe manual I linked to, no?
R.. GitHub STOP HELPING ICE
CC BY-SA 4.0
2022-11-09T16:37:20.637Z
2022-11-09T16:45:41.850Z
2022-11-09T16:45:41.850Z
fred_dot_u
<p>I have created a Mengersponge in OpenScad which is a 3D object. I wanted to get an SVG export from it for the laser cutter but I receive this error:&quot;Current top level object is not a 2D object.&quot; How do I select each side of this sponge to export it as SVG for laser cutting?</p>
<p>Code:</p>
<pre><code>module MengerSponge(side = 270, order =3){
    difference(){
        cube([side,side,side],center=true);
        MengerSponge_aux1(side, order);
    }
    }
module MengerSponge_aux1(side, order){
    rotations=[
    [90,0,0],
    [0,90,0],
    [0,0,90],
    ];
    for(rotation=rotations){
        rotate(rotation)
    MengerSponge_aux2(side, order);
        }
}


 module MengerSponge_aux2(side, order){
     if(order&gt;0){
        translate([0,-(side-(side/pow(3,order-1)))/2,0])
            for(i=[0:pow(3,order-1)-1]){
                translate([0,(side/pow(3,order-1))*i,0])
                    translate([-(side-(side/pow(3,order-1)))/2,0,0])
                        for(i=[0:pow(3,order-1)-1]){
                            translate([(side/pow(3,order-1))*i,0,0])
                                cube([(side/pow(3,order)),(side/pow(3,order)),side+1],center=true);
            }
        }
        MengerSponge_aux2(side, order-1);
     }
     else{
         echo(&quot;Fail&quot;);
     }
 }
side=270;
order=3;
MengerSponge(side, order);

<span class="math-container">```</span>
</code></pre>

<openscad>
OpenSCAD ERROR: Current top level object is not a 2D object
bluxixi
# OpenSCAD ERROR: Current top level object is not a 2D object

(Asked by: username_0 on 2022-11-09)

I have created a Mengersponge in OpenScad which is a 3D object. I wanted to get an SVG export from it for the laser cutter but I receive this error:"Current top level object is not a 2D object." How do I select each side of this sponge to export it as SVG for laser cutting?

Code:

```
module MengerSponge(side = 270, order =3){
    difference(){
        cube([side,side,side],center=true);
        MengerSponge_aux1(side, order);
    }
    }
module MengerSponge_aux1(side, order){
    rotations=[
    [90,0,0],
    [0,90,0],
    [0,0,90],
    ];
    for(rotation=rotations){
        rotate(rotation)
    MengerSponge_aux2(side, order);
        }
}

 module MengerSponge_aux2(side, order){
     if(order>0){
        translate([0,-(side-(side/pow(3,order-1)))/2,0])
            for(i=[0:pow(3,order-1)-1]){
                translate([0,(side/pow(3,order-1))*i,0])
                    translate([-(side-(side/pow(3,order-1)))/2,0,0])
                        for(i=[0:pow(3,order-1)-1]){
                            translate([(side/pow(3,order-1))*i,0,0])
                                cube([(side/pow(3,order)),(side/pow(3,order)),side+1],center=true);
            }
        }
        MengerSponge_aux2(side, order-1);
     }
     else{
         echo("Fail");
     }
 }
side=270;
order=3;
MengerSponge(side, order);

```

```

**Tags:** openscad


---

## 1 answers

### Answer by username_1 on 2022-11-09. Score: 7 | Accepted answer

Use the projection() feature of OpenSCAD to effectively generate a plane cut. Position the cube structure in such a manner that the x/y plane intersects the desired shape to be exported. Rendering the code will then generate a 2D image. Previewing the code will generate a 1 mm thick 3D model which will "flatten" when rendered.

For the image below, I did not translate the cube, merely placed the cube generation within the projection feature.

```
projection(){
MengerSponge(side, order);
}

```

This rendering will export to SVG as desired. Different positioning of the cube (rotate, translate) will create different patterns.

[![projection of cube](https://i.sstatic.net/kSCtv.png)](https://i.sstatic.net/kSCtv.png)

> **Comments:**
> **username_2**: Don't forget [`cut=true`](https://en.wikibooks.org/wiki/OpenSCAD_User_Manual/3D_to_2D_Projection)  
> **username_1**: I did forget that, yet the result is "acceptable," yes? What is the failure mode of forgetting it?  
> **username_2**: Without `cut=true`, you get a 2D shadow of the part, not a 2D cut (union of all cuts as Z ranges over -infinity to infinity).  
> **username_1**: That's useful information. Is there a link to an example model in which both circumstances are provided?  
> **username_2**: In tthe manual I linked to, no?  

---

