OpenSCAD User Manual/3D to 2D Projection

From Wikibooks, open books for an open world
< OpenSCAD User Manual
Jump to: navigation, search


Using the projection() function, you can create 2d drawings from 3d models, and export them to the dxf format. It works by projecting a 3D model to the (x,y) plane, with z at 0. If cut=true, only points with z=0 will be considered (effectively cutting the object), with cut=false, points above and below the plane will be considered as well (creating a proper projection).

Example: Consider example002.scad, that comes with OpenSCAD. You can load it and render it to example002.stl (with F6). You can then load that stl file back into OpenSCAD, like so:

import_stl("example002.stl");

Openscad projection example 2x.png



Then you can do a 'cut' projection, which gives you the 'slice' of the x-y plane with z=0.

projection(cut = true) import_stl("example002.stl");

Openscad projection example 3x.png


You can also do an 'ordinary' projection, which gives a sort of 'shadow' of the object onto the xy plane.

projection(cut = false) import_stl("example002.stl");

Openscad example projection 8x.png



Another Example

What if we take example002 and move it up, out of the X-Y plane? And rotate it?

translate([0,0,25]) rotate([90,0,0]) import_stl("/tmp/d.stl");

Openscad projection example 4x.png


Now, you can project it and get a 'side view' of the entire object.

projection(cut=false) import_stl(“/full/path/to/stl”);

Openscad projection example 5x.png


Links:

Personal tools
Namespaces
Variants
Actions
Navigation
Community
Toolbox
Sister projects
Print/export