Share

SliceInput

[Slices][Desktop Automation]

Description

A SliceInput object is an alternative way to the Slice object methods like createsimplehatching() or createoffset() to generate new hatches and contours from existing Slice objects.

However, the two differ in use. For comparison, a Slice method is run directly on an existing Slice object with all parameter values and produces a new Slice object as an output:

myoffsetslice = myoriginalslice:createoffset(10); --optional parameters: ,true,30 for inner offset and a roundness of 30°, respectively

In contrast, the SliceInput object is set up first and is then used itself in a Slice object's method to produce the output:

mysliceinput = system:createsliceinput("SLICEFILETYPE_OFFSET");
mysliceinput.offset = 10; --negative numbers produce outer offsets
mysliceinput.roundness = 89;

myoffsetslice = myoriginalslice:createbyinput(mysliceinput);

This may seem needlessly verbose or roundabout but has several benefits. For example:

  • SliceInput object properties are named. Instead of having to remember or look up what the n-th parameter of some Slice method is, they can be addressed directly by name and in any order. For operations with a lot of parameters, this saves significant tedium.
  • Since the values used to configure the operation are stored in properties of the SliceInput object itself, using helper variables with the respective Slice method to replicate a similar behavior is not necessary.
  • The object can be reused. It can be kept around without having to worry about keeping track of the configuration values.
  • A Slice object created from a SliceInput object retains the history of operations. Adding the Slice object to the project tree makes this history manually accessible and modifiable, enabling experimentation with values on a script-generated set of slice stacks without needing to modify the script with intermediate values for every iteration.

Back to top

Properties

The properties of the slice operation to perform extend the SliceInput object.

Property Read/write Type Description
slice_type read String Returns type of the SliceInput. The type determines the slice operation.
slice_caption read String Returns caption of the slice operation as it appears in the UI in the current language
count read Integer Returns number of options of the slice operation that should be created

Back to top

Methods

Name Syntax Description
getoption sliceInput:getoption (index:Number) Returns OptionItem of the slice operation at given index
findoption sliceInput:findoption (identifier:String) Returns OptionItem of the slice operation of given identifier

Back to top

Example

List available SliceInput object types

message = "Available SliceInput object types with index, type, and caption\n"
for i = 0, system.slicetypecount-1, 1 do
    sliceInput = system:createsliceinputbyindex(i);
    message = message .. i .. " - " .. sliceInput.slice_type .. " (" .. sliceInput.slice_caption .. ")\n";
end
system:messagedlg(message);

Result:

0 - SLICECOMMANDER_POINTREDUCTION_TITLE (Reduce points)
1 - SLICEFILETYPE_OFFSET (Offset)
2 - NTC_OPT_DOWNSKIN (Downskin)
3 - SLICEFILETYPE_MULTILASERSPLIT (Multilaser split)
4 - SLICEFILETYPE_MULTILASERREGIONSPLIT (Multilaser region split)
5 - SLICEFILETYPE_MULTILASERQUADRANTSPLIT (Multilaser quadrant split)
6 - SLICEFILETYPE_LASEREXTRACTION (Laser extraction)
7 - SLICEFILETYPE_FILLING_QUADISLANDS (Quad islands)
8 - SLICEFILETYPE_SIMPLEHATCHES (Simple hatching)
9 - SLICEFILETYPE_FILLING_STRIPES (Stripe filling)
10 - SLICEFILETYPE_FILLING_RADIALHATCHING (Radial hatching)
11 - SLICEFILETYPE_HATCHCONVERSION (Hatch conversion)
12 - SLICEFILETYPE_CONTOURSEGMENTATION (Contour segmentation)
13 - SLICEFILETYPE_FLOWSEGMENTATION (Flow segmentation)
14 - SLICEFILETYPE_HATCHEXTENSION (Hatch extension)
15 - SLICEFILETYPE_FILLING_CHECKERBOARD (Checkerboard hatching)
16 - SLICEFILETYPE_SORTED (Sort contours)
17 - SLICEFILETYPE_LAYERDUPLICATION (Layer duplication)
18 - SLICEFILETYPE_THINWALLS (Thin wall detection)
19 - SLICEFILETYPE_THINWALLS_MEDIAL (Thin wall detection)
20 - SLICEFILETYPE_MIRROREDXY (Mirrored slice)
21 - SLICEFILETYPE_TOOLPATHOPT (Toolpath optimization)

Back to top

Was this information helpful?