Slice
[Slices][Desktop Automation]
The Slice
object represents an entire slice stack.
Properties
Property | Read/write | Type | Description |
---|---|---|---|
layercount | read | number | returns count of layers |
layersize | read | number | returns thickness of the layers (if consistent throughout the slice) |
maxx | read | number | maximum X of the slice in mm |
maxy | read | number | maximum Y of the slice |
maxz | read | number | maximum Z of the slice |
minx | read | number | minimum X of the slice in mm |
miny | read | number | minimum Y of the slice in mm |
minz | read | number | minimum Z of the slice in mm |
name | read/write | string | returns/sets name of the slice |
![]() |
read/write | string | Scales an applied offset using key=value pairs matched against face group names preserved during slicing. This property only exists for slice objects generated using createoffset() and cannot be set on or read from other slice objects. |
Methods
Name | Syntax | Description |
---|---|---|
addproperty | slice:addproperty (property:String, value:Number) | Adds a property value for the named property. Valid properties are: tag, markspeed, jumpspeed, premarkdelay, postmarkdelay, polygondelay, laserindex, power, laserfocus |
addtag | slice:addtag(tagvalue:String) | Adds a tag value to the tag-list of a slice |
calculateslicearealayerindex | slice:calculateslicearea(sliceindex:Int) | Calculates the area of a layer; layer is selected by its index; returns the value |
calculateslicearea | slice:calculateslicearea(sliceheight:Float) | Calculates the area of a layer; layer is selected by its height; returns the value |
calculateslicecontourlayerindex | slice:calculateslicecontour(sliceindex:Int) | Calculate the contour length of a layer; layer is selected by its index; returns the value |
calculateslicecontour | slice:calculateslicecontour(sliceheight:Float) | Calculate the contour length of a layer; layer is selected by its height; returns the value |
conversion_connectopencontours | resultsliceobject = slice:conversion_connectopencontours() | |
conversion_contourtohatches | resultsliceobject = slice:conversion_contourtohatches() | |
conversion_filtercontoursbyarea | resultsliceobject = slice:conversion_filtercontoursbyarea (MinContourArea:Number) | |
conversion_filter | resultsliceobject = slice:conversion_filter(PreserveHatches:Boolean; PreserveOpenContours:Boolean; PreserveClosedContours:Boolean) | |
conversion_hatchestocontour | resultsliceobject = slice:conversion_hatchestocontour(Accuracy:Number; DoMergeHatches:Boolean; KeepMergeOrder:Boolean ) | |
conversion_hatchpermutation | resultsliceobject = slice:conversion_hatchpermutation (PermuteEveryNthHatch:Int) | |
conversion_layerfilter | resultsliceobject = slice:conversion_layerfilter (everynthlayer, layeroffset:Int) | |
conversion_randomizeseam | resultsliceobject = slice:conversion_randomizeseam() | |
conversion_revertdirection | resultsliceobject = slice:conversion_revertdirection (RevertEveryNthLayer:Int; RevertLayerOffset:Int) | |
createaggregation | slice:createaggregation(Offset[mm]:Float, Accuracy:Float) | Create an aggregation; returns the result as new Slice object |
![]() |
resultsliceobject = slice:createbyinput (input: SliceInput) | Returns new Slice object from a SliceInput object |
createcontoursegmentation | resultsliceobject = slice:createcontoursegmentation(Length:Number; Count:Int; Overlap:Number; RandomizeSeam:Boolean; IncludeHatches:Boolean) | Defaults if omitted: Overlap: 0 RandomizeSeam: false IncludeHatches: false |
createdownskin | slice:createdownskin() | Generates downskin contours from a slice stack effectively by boolean unification of the current and the next layer up; returns the result as new Slice object. Does not take any arguments. Additional functionality like shrinkage and (re-) expansion for cleaning noise contours and other artifacts must be replicated separately with their respective methods. |
createflowsegmentation | resultsliceobject = slice:createflowsegmentation(angle:Number; directionTolerance:Number; InvertNegatives:Boolean; IncludeHatches:Boolean) | |
createimagerenderer | slice:createimagerenderer(layerindex:Int, size:Float) | Create an image of the slice |
createlayerunification | slice:createlayerunification(depth:Int) | Generates a new slice stack where any layer is an aggregate of boolean unifications of the original stack's equivalent layer and depth layers up. depth must be larger than 0. |
createoffset | slice:createoffset(offset[mm]:Float, is_inner_offset:Boolean, roundness [degree]:Float = 30) | Generates an offset. is_inner_offset controls direction, roundness is a threshold for subdivisions circumscribing a corner to reach before another subdivision is inserted; returns the result as new Slice object. |
createquadfilling | slice:createquadfilling(HatchDistance:Float, Angle:Float, AngleIncrement:Float, OnlyEachLayer:Int, HatchOriginIncrement:Float, QuadSizeX:Float, QuadSizeY:Float) | Create a quad filling Defaults: Angle: 0 AngleIncrement: 0 OnlyEachLayer: 1 HatchOriginIncrement: 0 QuadSizeX: 20 QuadSizeY: 20 |
createradialfilling | slice:createradialfilling(centertype:Int, hatchdistance:Float, circleradius:Float, minimalradius:Float, angle:Float, angleincrement:Float, overlap:Float, alternate: boolean, adjustminmax: boolean ) | Create a radial filling. The centertype accepts values 0="center for each island" and 1="one center at slice center". An adjustminmax value of true adjusts the minimum and maximum radius to the current slice, this may reduce the number of stripes. |
createrenderer | slice:createrenderer(layerfactor:Int) | |
createrotatedslice | slice:createrotatedslice(rotationfactor:Int) | Generates a rotated slice, rotated by an angle of rotationfactor |
createscaledslice | slice:createscaledslice (factorx:Int, factory:Int) | Generates a scaled slice. factory is optional; if called without, factorx is used for both x and y. |
createsimplehatching | slice:createsimplehatching(hatchdistance:Float, angle:Float, angleincrement:Float, onlyeachlayer:Int, hatchoriginincrement:Float) | Generates hatching on the slice object. Angleincrement rotates every layer by this amount against the previous one; layers may be skipped in intervals of onlyeachlayer; hatchoriginincrement shifts the start of hatches so that they do not start in the same spot. Returns the result as new Slice object. Defaults when omitted: angle: 0 angleincrement: 0 onlyeachlayer: 1 hatchoriginincrement: 0 |
createstripefilling | slice:createstripefilling(HatchDistance:Float, StripeWidth:Float, StripeGap:Float, Angle:Float, AngleIncrement:Float, OnlyEachLayer:Int, SortType:Int ) | Create a strip filling Defaults when omitted: StripeWidth: 10 Angle: 0 AngleIncrement: 0 OnlyEachLayer: 0 |
createtranslatedslice | slice:createtranslatedslice(factorx:Int, factory:Int) | Generates slice translated by factorx and factory. |
createupskin | slice:createupskin() | Generates upskin contours from a slice stack effectively by boolean unification of the current and the next layer down; returns the result as new Slice object. Does not take any arguments. Additional functionality like shrinkage and (re-) expansion for cleaning noise contours and other artifacts must be replicated separately with their respective methods. |
duplicate | slice:duplicate | Duplicates the slice object. |
executecalculation | slice:executecalculation(debugmessage:String, layerthickness:Number) | Applies all calculations. |
getlayerz | slice:getlayerz(layerindex:Int) | Returns the Z height of a layer stack |
getpropertynumber | slice:getpropertynumber (property:String, defaultvalue:String) | Queries the current number value of the named property, if not set, the given defaultvalue is used. See also: addproperty |
hastag | slice:hastag(tagvalue:String) | Returns true when the slice tag list contains the given tag and false otherwise. |
hatchcutting | resultsliceobject = slice:hatchcutting() | Trims hatches using the contours in the same slice stack, returns new stack with trimmed hatches. Has no parameters. To cut a stack of hatches with a stack of contours, merge the stacks first. |
hatchextension | resultsliceobject = slice:hatchextension(FixedDistance1, AngleFactorA1, AngleFactorB1, AngleFactorC1, AnglePowerA1, AnglePowerB1, AnglePowerC1, FixedDistance2, AngleFactorA2, AngleFactorB2, AngleFactorC2, AnglePowerA2, AnglePowerB2 , AnglePowerC2: number) | Experimental function to perform hatch extension to compensate for laser switching ("skywriting") for machines that do not do this on their own. |
loadlayer | slice:loadlayer(index:Int) | Returns the slice layer at the given index; returns the result as new slice layer object |
loadmultilasersplitlayerweights | slice:loadmultilasersplitlayerweights(CSVFilePath) | Loads laser weight factors from CSV formatted file |
moveslice | slice:moveslice(X:Float, Y:Float, Z:Float) | Moves a slice by the given values in millimeters. Has no return value. |
multilaserquadrantsplit | slicelist = slice:multilaserquadrantsplit (type:number, lasercount:number, left:number, right:number, front:number, back:number, offset_range:number, offset_per_layer:number, close_cut_contours:Boolean) | Splits the slice in defined quadrants. Returns slice list. Parameters: type: 0=quadrant 1=linearX 2=linearY left, right, front, back: Dimension of the platform offset_range: Overlapping band width offset_per_layer: Cutting line shift per layer close_cut_contours: If quadrant splitting runs through closed contours, the resulting open contours are closed along the split lines. Does nothing for open hatchings. |
multilaserregionsplit | slicelist = slice:multilaserregionsplit (lasercount:int, regionsize:float, gasflowangle:float, centerpointshift:float, borderdelta1:float, borderdelta2:float, ... borderdeltaN:float) | Splits available toolpath into a number of stripes or lanes relative to the buildroom, centered around {X, Y} = {0, 0}. See Multilaser splitting in the Processing slices reference for details. Returns list of slice objects. |
multilasersplit | slicelist = slice:multilasersplit (lasercount:int, accuracy:float, maxblocksize:float, maxdistance:float, perlayershift:float, gasflowangle:float, overlap:float, overlapagainstflow:float) | Sets up the slice for multi-laser processing. Returns slice list. |
pointreduction | slice:pointreduction (ATolerance:Number) | Applies point reduction on slice |
reduce | slice:reduce(tolerance:Float) | Reduces the points of a slice under observance of maximum deformation by tolerance in millimeters; returns the result as new Slice object |
removeselfintersectionmulticore | slice:removeselfintersections() | Removes the self intersections using multi cpu cores; returns the result as new Slice object |
removeselfintersections | slice:removeselfintersections() | Removes the self-intersections; returns the result as new Slice object |
removetag | slice:removetag(tagvalue:String) | Removes the given tagvalue from the tag-list of the current slice. |
savetofile | slice:savetofile(identifier:String, slicetype:Int, layersize:Float, minz:Float, maxZ:Float) | Exports a slice to a given slice format; identifier gives the name; slicetype gives the slice type; returns nothing. Slice type global constants are stCLI, stCLS, stSLC, stSLI, stUSF. |
setmultilasersplitlayerweights | slice:setmultilasersplitlayerweights(Layer, Weight1, Weight2, ...) | Sets up to 8 laser weight factors for specific layer |
smooth | slice:smooth(value:Number) | Smoothens a slice; returns the result as new Slice object |
substractslice | slice:subtractslice(sliceobject:Object) | Subtracts from slice the given sliceobject ; returns the result as new Slice object |
translate | slice:translate(X:Float, Y:Float, Z:Float) | Moves an existing slice by the given values in millimeters; returns nothing |
Examples
multilasersplit
slicelist = slice:multilasersplit (2, 0.25, 500, 20, 2.5, 45, 0.3, 1.2)
-- Laser Count 2
-- Accuracy 0.25
-- Max Blocksize 500
-- Max Distance 20
-- Shift per layer 2.5
-- Gas flow Angle 45
-- overlap in flow: 0.3
-- overlap against flow: 1.2
laser1slice = slicelist:getslice (0)
laser1slice.name = "Laser 1"
laser2slice = slicelist:getslice (1)
laser2slice.name = "Laser 2"
system:addslicetotree (laser1slice)
system:addslicetotree (laser2slice)
Offset scaling with face group names
To use offset scaling in a meaningful way, slice a model that has face groups. The face groups' names are maintained as "tags".
Note: This is different from the slice property "Tag" which applies to the whole slice stack and is used to hold beam exposure parameters for export formats that support it and where Netfabb's export is set up to include them in some form or another.
offsetslice = slice:createoffset(10)
offsetslice.name = 'Offset with tags'
offsetslice.slicetagmapping = 'red=1\nblue=0.5\ngray=0.1'
system:addslicetotree(offsetslice)
system:messagedlg('Offset-mapping is:\n' .. offsetslice.slicetagmapping)