This example demonstrates how conditions, operators, and read-only values can be used in a script.
volumedata = structure:getvolumedata(0); fragment = volumedata:getfragment(0); cell = structure:findcell("Cell 1"0; supportcell = structure:findcell("Cell 2"); fragement.cell = cell; if volumedata.orginz > 0 then volumedata:resize(0,0,0,0,0,volumedata.orginz/volumedata.rastersizez); supportfragment = fragment:createprojection(6); supportfragment.name = "Support"; supportfragment.cell = supportcell; end if volumedata.orginz > 0 then volumedata:resize(0,0,0,0,0,1); supportfragment = fragment:createprojection(6,true); supportfragment.name = "Support"; supportfragment.cell = supportcell; end
The script adds a support for the construction of a part consisting of one fragment. The support is implemented as projection in minus-Z direction and reaches from the bottom of the part to the bottom of the platform.
After the volume data, the fragment and two cells are loaded into the script and the first cell is assigned to the fragment. The conditional if determines that the following block of orders is only executed, if the origin of the grid has a higher Z-value than 0, which means that the part is not placed at the bottom of the platform.
For the enlargement of the grid (volumedata:resize), the parameter 0 is given for all directions except the minus-Z direction. For this last parameter, the lowest Z-value of the grid, which is measured in mm, is divided by the grid cell size. This results in the number of grid cells between the base of the part and the bottom of the platform. This step has to be done, because the enlargement is measured by the number of grid cells.
Thus the grid is enlarged far enough that a projection fragment can be inserted (fragment:createprojection), reaching to the bottom of the platform. This projection is then given the name "Support" in the 3S Executor and is filled with the cell supportcell.
The second conditional block of orders needs to be inserted for the case that the enlargement of the grid does not reach to the bottom of the platform. This can occur when the result of the division of the origin by the cell size of the grid has been rounded down in the first block of orders. In this case, a further enlargement of the grid by one grid cell in minus-Z direction is conducted and a new projection fragment is inserted. The true parameter is added to overwrite the first projection fragment. As before, the new projection fragment is given the name "Support" in the 3S Executor and is filled with the cell supportcell.