Freesteel Blog » Z-level slicer
This code has been sold to Autodesk as part of the HSMWorks CAM kernel. However, I have been working on a pure python replacement over at barmesh slicer code in bitbucket, or for pictures see this blogpost
- NEW! freesteelpy is a binary python package that can be used in your own applications for slicing triangulated surfaces. Included is python source code that slices STL files, the same code that is compiled into the windows command line application.
- Slice is free to use and distribute in its binary form as a command-line utility. It can be aggregated with Free Software.
- Slice accepts any STL file of a triangulated 3D model, and outputs in a variety of formats. Unlike other implementations that cut the triangles directly, the input model does not need to be water-tight, because we use a toolpath generating CAM algorithm which samples the contour using a small defined toolshape.
- Slice is the fundamental function of all layer-based rapid prototyping, but our implementation can also be used to generate contours in a volumetric offset or a silhouette shadow of a 3D model.
(c) 2010 - 2012 Freesteel, Slice v1.5, (http://www.freesteel.co.uk). Slice is distributed freeware and without warranty of any kind. May contain bugs. Use entirely at your own risk. Usage: slice [options]Options: --version show program's version number and exit --help show this help message and exit -o OUTFILE, --output=OUTFILE output file (*.xhtml , *.html , *.svg, *.cli, *.txt, *.hpgl, *.plt, *.bmp, *.jpg, *.png, *.tiff, *.gif). The HTML output uses an embedded SVG file and can be viewed in a compatible browser. Some browsers might require you to install a plugin for viewing SVG files. If an output file is omitted, results are printed to the console window. -m, --multiple in connection with output to an image format, write one file per z level -z Z, --zheights=Z slice at these z heights (comma separated list of values, can be of form 'lo, hi, step') -d WDIFF, --difference=WDIFF if set, adaptive steps so that slices don't differ by more than this -t TOOLTYPE, --type=TOOLTYPE type of slicing tool (disk or sphere; default is disk) -r RADIUS, --radius=RADIUS tool radius -f OFFSET, --offset=OFFSET offset contours (<0 to offset inwards, defaults to -radius for default tool) -s WRES, --resolution=WRES resolution (if omitted this calculated from the STL dimensions) -l LAYERTHICKNESS, --layer=LAYERTHICKNESS layer thickness for slicing with a disk (height of disk), default is 10% of the z height -v, --verbose print information -w IMGWIDTH, --width=IMGWIDTH image width (default 370) (used for output image formats) -h IMGHEIGHT, --height=IMGHEIGHT image height (default 370) (used for output image formats) -a ASPECT, --aspect=ASPECT aspect (default is xy, other values yz or xz) --cavity=CAVITY color of cavity areas (default is white). Colors can be given as names (white, black, ...), or hex codes (#ffffff, #000000, #ff0000, ...) --core=CORE color of core areas (default is black). Colors can be given as names (white, black, ...), or hex codes (#ffffff, #000000, #ff0000, ...) --background=BACKGROUND background color (defaults to cavity color selection). Colors can be given as names (white, black, ...), or hex codes (#ffffff, #000000, #ff0000, ...) --noprogress do not print progress bar --shell slice STL as shell (default is solid)
Examples
Cube10.stl
solid block10 facet normal 0 0 0 outer loop vertex 0 10 10 vertex 0 10 0 vertex 0 0 10 endloop endfacet facet normal 0 0 0 outer loop vertex 0 0 10 vertex 0 10 0 vertex 0 0 0 endloop endfacet facet normal 0 0 0 outer loop vertex 10 10 10 vertex 0 10 10 vertex 10 0 10 endloop endfacet facet normal 0 0 0 outer loop vertex 10 0 10 vertex 0 10 10 vertex 0 0 10 endloop endfacet facet normal 0 0 0 outer loop vertex 10 10 0 vertex 10 10 10 vertex 10 0 0 endloop endfacet facet normal 0 0 0 outer loop vertex 10 0 0 vertex 10 10 10 vertex 10 0 10 endloop endfacet facet normal 0 0 0 outer loop vertex 0 10 0 vertex 10 10 0 vertex 0 0 0 endloop endfacet facet normal 0 0 0 outer loop vertex 0 0 0 vertex 10 10 0 vertex 10 0 0 endloop endfacet facet normal 0 0 0 outer loop vertex 10 10 10 vertex 10 10 0 vertex 0 10 10 endloop endfacet facet normal 0 0 0 outer loop vertex 0 10 10 vertex 10 10 0 vertex 0 10 0 endloop endfacet facet normal 0 0 0 outer loop vertex 10 0 0 vertex 10 0 10 vertex 0 0 0 endloop endfacet facet normal 0 0 0 outer loop vertex 0 0 0 vertex 10 0 10 vertex 0 0 10 endloop endfacet endsolid
Using Cube10.stl, which is a 10x10x10 cube
> slice cube10.stl
prints the JSON formatted result:
{"xlo": 0.0, "yhi": 10.0, "xhi": 10.0, "zhi": 10.0, "ylo": 0.0, "zlo": 0.0} {"n_triangles": 12, "n_points": 8, "n_edges": 28, "n_unmatched_edges": 0} {"flat_area_z": [0.0, 10.0]}
To create a single slice at Z=5 with a tool radius 1mm and layer height of 0.1,
> slice -layer=0.1 -r1 -f0 cube10.stl
The response (in JSOP) is:
{"z": 5.0, "polygons": [{"points": [[-0.9078014184397163, -0.4194002678573765], [-0.911478589796249, -0.4113475177304966], [-0.9500634676302036, -0.312056737588 6527], [-0.9771031917621306, -0.2127659574468086], [-0.9935408316398511, -0.1134 7517730496448], [-0.9998993963780151, -0.014184397163120366], [-1.0, 0.085106382 9787233], ..., [-0.792456004957226, -0.6099290780141844], [-0. 8085106382978724, -0.5884815611038012], [-0.8597956319649682, -0.510638297872340 3], [-0.9078014184397163, -0.4194002678573765]], "type": "core"}]}
The shape of this is a square of width 12mm with 1mm rounded corners, because it is sampled with a disc of radius 1. If you want the cut on the surface, the shape must be offset back to its original form using -f-1.
You cannot slice exactly on a flat area because the result is ambiguous, so slicer moves the position of Z slightly.
> slice -z10 cube10.stl
returns
{"z":10.0075, "polygons": []}
To create a silhouette, simply set the z value to below the zlo for the model and the layer thickness to greater than the height of the model.
Downloads
- Windows Installer 2014-05-15 (5MB)
Python package and scripts for linux 32bit (6MB) by request- For more recent developments, go to we have some slicing blogpost or barmesh slicer code