solid.Shape

Methods

Method Reference: solid.Shape.write

solid.Shape: write (S, FILE)

solid.Shape: write (S, FILE, 'Tolerance', TOL)

Write a solid to a STEP, STL, OBJ, PLY or 3MF file.

write (S, FILE) writes the shape S in the format named by the extension of FILE, in either case:

.step
STEP (ISO 10303-21, application protocol 214), in millimetres. The exact geometry is kept, so this is the file to send to a CAD program or to another manufacturer. The part is named after the base name of FILE, and each solid carries its solid.Shape.Colour.
.stl, .obj, .ply, .3mf
A mesh of triangles in millimetres, the mesh solid.Shape.tessellate makes, written by polymesh.Mesh.write: binary STL, OBJ, binary PLY, or 3MF, the archive slicers take. The facets approximate every curved surface; their vertices lie on it. OBJ, PLY and 3MF carry the solids’ colours on their triangles; STL has none.

write (…, 'Tolerance', TOL) sets, for a mesh, the largest distance in millimetres between a facet and the true surface. It is 0.01 by default, well below what a printer resolves; a larger value gives a smaller file. No facet spans more than 20 degrees of a curved surface, whatever TOL. A STEP file is exact and takes no tolerance.

The empty shape has nothing to write and is refused, and so is a folder that does not exist.

 
 ## Exact for a CAD program, and a coarser mesh for a slicer
 S = subtract (solid.box (40, 30, 10), ...
               translate (solid.cylinder (5, 10), [20, 15, 0]));
 write (S, 'block.step');
 write (S, 'block.stl', 'Tolerance', 0.05);

See also: solid.read, solid.Shape.tessellate, polymesh.Mesh.write

Source Code: solid.Shape