Netfabb Lua Scripting API Reference-1
Netfabb Lua Scripting API Reference-1
Documentation
Reference.docx
Copyright by Autodesk
1 / 107
Netfabb Lua Scripting API
Documentation
Reference.docx
Table of Content
2 / 107
Netfabb Lua Scripting API
Documentation
Reference.docx
6 / 107
Netfabb Lua Scripting API
Documentation
Reference.docx
9 / 107
Netfabb Lua Scripting API
Documentation
Reference.docx
1 Lua in Netfabb
In the later API reference part, the different scope of the API calls will be
indicated by these tags:
[Desktop Automation]
and
1.1.1 [3S]
The 3S Lua implementation is accessible as the 3S “script” function and its API
only contain the functions documented in this chapter: 2.16. No other Netfabb
API calls are available in this implementation. Vice versa, the 3S API functionality
is only available in the 3S module and nowhere else.
The Slice Commander module has the option to load a Lua script file via a menu
option: Prepare->Run Lua Script. The API this Lua API interface provides is
nearly identical with the one for [Desktop Automation]. The only addition is a de-
fault “slice” object in the realm of the script, which provides convenient access to
the currently loaded slice stack.
10 / 107
Netfabb Lua Scripting API
Documentation
Reference.docx
From the Lua 5.1 standard Netfabb supports the core language specification
and some but not all the libraries.
11 / 107
Netfabb Lua Scripting API
Documentation
Reference.docx
The Lua Automation Module module can be found under -Prepare-Execute Lua
Script. In the Lua Automation module, a Lua script can be loaded, saved and
manually edited. The syntax can be checked before the script is executed. All the
main Lua commands can be accessed within the script. This excludes the special
Lua commands for the 3S Module. The Lua Automation module can be used
without any connections to the current content of the Desktop application by load-
ing, manipulation and saving again an arbitrary FABBPROJECT. However, in
most cases one wants to manipulate the content of the current project opened in
Autodesk Netfabb. Therefore, the variable “tray” is predefined with the current
platform (and its LUATray object). This allows a direct and fast access to all
meshes in the platform and allows to manipulate them. Several example scripts
are availiable. In addition, the global variable “netfabbapplication” allows access
to the trays of the current running netfabb application.
[Slice Commander]
In the slice commander a right click on the Slice opens the Pop-Up menue. Under
Extended the entry “Execute Lua script” can be found. Here an script can be
directly loaded and immediately executed. The variable “slice” is predefined and
corresponds to the selected slice(s). For each selected slice the script is exe-
cuted. Please note that any changes needs to returned with a new slice using
system:addslicetotree . The “script SliceCommanderLUAScript_example1_Off-
set” demonstrate this.
12 / 107
Netfabb Lua Scripting API
Documentation
Reference.docx
2 Scripting Reference
2.2.1 Properties
[Desktop Automation]
Property Read / Write Type Description
buildnumber read only string Build number (e.g. 396)
corecount read only number Number of processor cores
exitcode read only number Exit code
isquiet read only Boolean returns if the logging to stdout is disabled
linebreak read only string Line break characters
majorversion read only number returns the major version of Netfabb (e.g. 5)
minorversion read only number returns the minor version of Netfabb (e.g. 2)
officialversion read only string Returns the official number version (e.g. 2019)
13 / 107
Netfabb Lua Scripting API
Documentation
Reference.docx
paramcount read only number returns the number of command line parameters
result read only Mesh Resulting Mesh object
returns the number of milliseconds since the Lua
timer read only number
script has started
returns the version string of the system (e.g.
versionstring read only String
'5.2.1')
unixtime read only number returns the current time as unix timestamp
[Desktop Automation]
Property Read / Write Type Description
Returns the conversion factor of the current set
areaunitfactor read only number area unit to the internal area unit (cm2): 100 or
25.4*25.4
Returns the string representing the currently set
areaunitstring read only String
area unit: cm2 or in2
Returns the conversion factor of the current set
lengthunitfactor read only number length unit to the internal length unit (mm): 1 or
25.4
Returns the string representing the currently set
lengthunitstring read only String
length unit: mm or in
Returns the conversion factor of the current set
volumeunitfactor read only number volume unit to the internal volume unit (cm3):
1000 or 25.4*25.4*25.4
Returns the string representing the currently set
volumeunitstring read only String
volume unit: cm3 or in3
[Desktop Automation]
Name Syntax Description
Calculates MD5 hash sum of
calculatemd5 Md5 = system:calculatemd5(filename:string);
a file
checklibrary Result = system:checklibrary(libname:string); Checks for the desired library
cleargarbage system:cleargarbage(); Calls the garbage collector
Create an importer for 3mf
AImporter = system: files. The second paratemeter
create3mfimporter(AFileName: String; specifies whether a single
create3mfimporter
ASplitMeshed: Boolean; AName: String; ATray: mesh should be imported.
TLUATray); See Error! Reference source
not found. for details
Create a new 3mf exporter
create3mfexporter AExporter = system:create3mfexporter(); object. See 3mfExporter for
details
14 / 107
Netfabb Lua Scripting API
Documentation
Reference.docx
15 / 107
Netfabb Lua Scripting API
Documentation
Reference.docx
- show_horizontalruler
- show_verticalruler
- show_labels
- show_viewcube
- show_coordsystem
- show_platform
- show_textures
- show_colors
system:createscreenshot(AWidth: Number; - zoom
createscreenshot
AHeight: Number; AOptions: JsonObject) - camera: a json object
with 3 optional mem-
bers “eye”, “up” and
“center” defining the
position, view target
and up vector of the
camera as array with
3 float elements
16 / 107
Netfabb Lua Scripting API
Documentation
Reference.docx
17 / 107
Netfabb Lua Scripting API
Documentation
Reference.docx
18 / 107
Netfabb Lua Scripting API
Documentation
Reference.docx
19 / 107
Netfabb Lua Scripting API
Documentation
Reference.docx
Examples
Name Example Return value
log system:log(“Hello World”); -
logtofile system:logtofile(“my_file.log”); -
string: string containing the
getparam filename_to_process = system:getparam(0);
desired parameter
system:shellexecute(“mail”, -s subject
shellexecute -
“hello@mail.com”)
checklibrary system:checklibrary(“mysql”); -
20 / 107
Netfabb Lua Scripting API
Documentation
Reference.docx
21 / 107
Netfabb Lua Scripting API
Documentation
Reference.docx
Examples
Name Example Return value
mesh object: an empty mesh
createmesh mesh = system:createmesh();
object
mesh object: a mesh object of
load3ds system:loadgts("test.3ds"); the "Autodesk 3D Modeling
Format" file
mesh object: a mesh object of
load3mf system:load3mf("test.3mf");
the "3MF Basic Microsoft" file
mesh object: a mesh object of
loadamf system:loadamf("test.amf"); the "Additive Manufacturing
File"
mesh object: a mesh object of
loadgts system:loadgts("test.gts"); the "Gnu Tesselated Surfaces"
file
mesh object: a mesh object of
loadncm system:loadncm("test.ncm"); the "Netfabb Compressed
Mesh" file
mesh object: a mesh object of
loadobj system:loadobj("test.obj");
the "Wave Front OBJ" file
mesh object: a mesh object of
loadply system:loadply("test.ply");
the "Stanford Polygon" file
mesh object: a mesh object of
loadstl system:loadstl("test.stl"); the "Surface Tesselation
Language" file
mesh object: a mesh object of
loadvoxel system:loadvoxel("test.svx");
the "Simple Voxels" file
mesh object: a mesh object of
loadvrml system:loavrml("test.vrml"); the "Virtual Reality Modeling
Language" file
mesh object: a mesh object of
loadx3d system:loadx3d("test.x3d");
the "Extensible 3D-ASCII" file
22 / 107
Netfabb Lua Scripting API
Documentation
Reference.docx
Examples
Name Example Return value
XML object: XML file object for
createxml system:createxml();
further processing
XML object: XML file object for
loadxml system:loadxml("input.xml");
further processing
DB Object: Database object for
connecttoodbc system:connecttoodbc("netfabb", "user", "pw");
further processing
2.2.3 Constants
2.2.4.1 GL Context
[Desktop Automation]
Name Syntax Description
Creates GL Context with xidth x
GLContext = system:createoglcontext(width:
createoglcontext height size. AXServer is an
integer; heigth: integer; AXServer: string)
optional argument
23 / 107
Netfabb Lua Scripting API
Documentation
Reference.docx
2.2.4.3 Slicing
2.2.4.3.2 Properties
None.
2.2.4.4 CadImport
[Desktop Automation]
Name Syntax Description
Creates a new Importer for CAD
createtecadimport cadimporter = system:createcadimport()
Files
2.2.4.5 Fabbproject
[Desktop Automation]
24 / 107
Netfabb Lua Scripting API
Documentation
Reference.docx
2.2.5 3mfExporter
[Desktop Automation]
This class can be used to export .3mf files from a Lua script. An instance is cre-
ated with the call “system:create3mfexporter();”.
2.2.5.1 Properties
Read /
Property Type Description
Write
writetextures Read / Write Boolean Flag to switch export textures to the 3mf on or off
writematerials Read / Write Boolean Flag to switch export materials to the 3mf on or off
writecolors Read / Write Boolean Flag to switch export colors to the 3mf on or off
2.2.6 CollisionDetector
[Desktop Automation]
This class is used to detect collisions between two meshes of the build room. It
is created with the call “Detector = system:createcollisiondetector(RasterSize);”.
2.2.6.1 Properties
None.
25 / 107
Netfabb Lua Scripting API
Documentation
Reference.docx
2.3 Netfabbtrayhandler
[Desktop Automation]
The “netfabbtrayhandler” is not a LUA object which can be created and released.
It is a global variable, which is only available in the Desktop Automation Module.
It allows access to the trays and to create a new tray in the application.
2.3.1 Properties
Read /
Property Type Description
Write
traycount Read Number Gives the current number of trays
26 / 107
Netfabb Lua Scripting API
Documentation
Reference.docx
2.4 Application
[Desktop Automation]
The “application” is not a LUA object which can be created and released. It is a
global variable, which is only avalible in the Desktop Automation Module. It allows
more access to the current running netfabb desktop application. In addition, it
also can create a GUI out of a dialog. The dialog is the same object as described
in Chapter 2.7.
2.4.1 Properties
Read /
Property Type Description
Write
lengthunitstring Read String Returns the current unit as string
showcolortexture Write Boolean Set if color/texture should be displayed
tier Read Number Gives the current tier
27 / 107
Netfabb Lua Scripting API
Documentation
Reference.docx
2.5.1 Properties
Property Read / Write Type Description
area read only Number Returns the area
Get the number of bad edges
badedgecount read Number
of the mesh
Get the number of boundary
boundaryedgecount read Number
edges of the mesh
Get the length of the boundary
boundarylength read Number
of the mesh
Returns whether the last
calculationerror read only Boolean
calculation has failed
Returns the message for a
calculationfailed read only String
failed calculation
edgecount read only Number Returns the number of edges
28 / 107
Netfabb Lua Scripting API
Documentation
Reference.docx
29 / 107
Netfabb Lua Scripting API
Documentation
Reference.docx
Examples
Name Syntax Return value
savetostl mesh:savetostl("my_mesh_fixed.stl"); TRUE if successful
mesh:savetoasciistl("my_fixed_ascii.stl", "My
savetoasciistl TRUE if successful
fixed ASCII STL");
savetox3d mesh:savetox3d("my_mesh_fixed.x3d", true); TRUE if successful
savetogts mesh:savetogts("my_mesh_fixed.gts"); TRUE if successful
savetoobj mesh:savetoobj("my_mesh_fixed.obj"); TRUE if successful
savetoncm mesh:savetoncm("my_mesh_fixed.ncm"); TRUE if successful
30 / 107
Netfabb Lua Scripting API
Documentation
Reference.docx
Examples
Name Example Return value
movetoorigin mesh:movetoorigin(); -
move mesh:move(200, 50, -100); -
mesh:scale(0.01);
scale -
[if y and z are not specified, x value is taken]
rotate mesh:rotate(1, 2, 0.5, 90); -
Outbox object: object
calcoutbox my_outbos = mesh:calcoutbox(); representing the outbox of the
mesh
invert mesh:invert(); -
release mesh:release(); -
31 / 107
Netfabb Lua Scripting API
Documentation
Reference.docx
32 / 107
Netfabb Lua Scripting API
Documentation
Reference.docx
Examples
Name Example Return value
boolean: returns true if
the area which has a
thinner wallthickness as
wallThicknessPassed = criticaldistance [mm] is
wallthicknesstest
mesh:wallthicknesstest(0.4, 20); less than criticalsurface
[%] of
the total area.
integer : For each point
of mesh the closest
distance to mesh2 is
calculated.
This distribution of
distances is afterward
analysed.
The distribution is used
for two tests. Test1:
If only distance is larger
testresult = than distance test1
comparewith mesh:comparewith(mesh2, 0.4, 0.1, 10); fails.
Test2:
if a fraction of the
distance distribution is
larger than
threshold test2 fails.
Return 0 if meshes are
equal, returns
2 if test1 fails, returns 4
if test2 fails, and returns
6 is both test fails.
number: For each point
of the mesh the closest
distance to mesh2 is
hasudorffdistance = calculated. The
calculatehausdorffdistanceto
mesh:calculatehausdorffdistanceto(mesh2); maximum of these
distances, which called
Hausdorffdistance, is
returned.
34 / 107
Netfabb Lua Scripting API
Documentation
Reference.docx
Examples
Name Example Return value
boolean: returns if any self-
intersections have been found
(or if they have been
disregarded due to the epsilon
value). Dependent on the
unify found_self_intersections = mesh:unify(0.05);
mesh geometry, this function
could create a lot of sall
shells, which should be
cleared by
”removeghostshells”
intersect found_self_intersections = mesh:intersect(); boolean: Similar to unify
boolean: returns if any self-
intersections have been found
(or if they have been
disregarded due to the epsilon
found_self_intersections =
insertselfintersections value). Attention: This
mesh:insertselfintersections(0.05);
function may create a lot of
shells, but it is capable of
orienting not-orienable
surfaces.
wrap mesh:wrap() -
35 / 107
Netfabb Lua Scripting API
Documentation
Reference.docx
36 / 107
Netfabb Lua Scripting API
Documentation
Reference.docx
Reduces number of
trianglesFrom Netfabb Pro:
mesh:reducelod(target:number,
reducelod
deformation:number, edgelength:number);
mesh:reducelodadvanced(count:number,
reducelodadvanced
deformation:number, edgelength:number);
37 / 107
Netfabb Lua Scripting API
Documentation
Reference.docx
Examples
Name Example Return value
integer: Returns how many
triangles have been
removed. Two triangles are
”double” if they share
exactly the same corners. If
removed_count =
removedoublefaces they share slightly the same
mesh:removedoublefaces();
corners, this function does
not harm them. Stitching
and degenerate face
removal couldalign these
cases.
integer: Returns the
number of trivially closed
holes of the mesh, i.e. all
missing triangles or
closetrivialholes trivial_hole_count = mesh:closetrivialholes();
quadrangles. This function
does not alter the mesh in
any other way and is safe
to call anytime.
integer: Returns the
number of closed holes of
the mesh, i.e. all nontrivial
closeallholes hole_count = mesh:closeallholes(); and non-bad holes. This
function can be dangerous
to call and add unwanted
walls into the mesh.
boolean: returns if the full
mesh has been made
mesh_is_orientable = oriented. This does not
fixflippedtriangles
mesh:fixflippedtriangles(); mean that the shell as a
whole has a positive
volume.
negative _shell_count = integer: number of shells
invertnegativeshells
mesh:invertnegativeshells(); inverted
removedegeneratefaces mesh:removedegeneratefaces(0.02); -
integer numbers of edges
stitch mesh:stitch(0.01, true);
having been stitched
38 / 107
Netfabb Lua Scripting API
Documentation
Reference.docx
Example:
stl = system:loadstl('file.stl')
support = stl:createsupport('support.xml')
support:savetostl('support.stl')
TLUAMeshObject
[Desktop Automation]
The TLUAMeshObject is the Lua representation of the "TNGM_Mesh_Advanced"
class. All modification functions are applied directly to the mesh
TLUATrayMesh
[Desktop Automation]
The TLUATrayMesh is the Lua representation of the "TNGM_MeshTreeMesh"
class. It contains a TLUAMeshObject as member "FLUAMesh" published in the
property "TLUATrayMesh.Mesh" and exported to Lua with the member "LU-
ATrayMesh.mesh". Please note that the "LUATrayMesh.mesh is only a copy of
39 / 107
Netfabb Lua Scripting API
Documentation
Reference.docx
the original LUAMesh in the Lua Automation module. All modification functions of
the LUATrayMesh do not modify the mesh but only its properties in the tree.
"TLUATrayMesh" is used in Lua Automation Module
The fabbproject API allows to create, load, modify and save fabbproject files used
by Netfabb.
This is the central class of the fabbproject API. It holds references to the trays
within the project and allows saving. The methods "System:loadfabbproject" and
"System:newfabbproject" (Fabbproject) create instances of the class.
2.6.1.1 Properties
Property Read / Write Type Description
Name of the fabbproject's filename. Is empty when a
name Read / write String new fabbproject is created and filled in load/save
operations
Options that were not saved. Will be updated in save
root read String
operations
traycount read number Number of trays within the fabbproject
40 / 107
Netfabb Lua Scripting API
Documentation
Reference.docx
2.6.2 LUATray
[Desktop Automation]
A fabbproject can contain more than one tray. The trays can be obtained with
the method "LUAFabbproject:gettray", the number of trays with the member
"LUAFabbproject.traycount". Each tray has a property "root" which is the main
LUAMeshGroup of the tray
2.6.2.1 Properties
Read /
Property Type Description
Write
Error message for tray actions, at the
errormessage Read String
moment only used by “Packing3d”
Calculates the percentage of the tray that is
filled with the parts currently inside the tray.
Note: parts that are outside or partly outside
the tray will not be included in the calculation
filling_degree Read number
Note: the filling degree is only calculated to
the maximum Z-Value of the parts in the tray.
The vertical size of the machine is not taken
into consideration.
Calculates the maximum height of the parts
filling_height Read number
loaded in the tray
root read LUAMeshGroup Get the root of the tray
machinesize_x Read / write number X-Size of the machine
machinesize_y Read / write number Y-Size of the machine
machinesize_z Read / write number Z-Size of the machine
name Read / write String Name of the tray
Constant id for the 2d packer. Used for
packingid_2d Read number
“LUATray: createpacker ”
Constant id for the 3d packer. Used for
packingid_3d Read number
“LUATray: createpacker ”
Constant id for the monte carlo packer. Used
packingid_montecarlo Read number
for “LUATray: createpacker ”
Constant id for the outbox packer. Used for
packingid_outbox Read number
“LUATray:pack”
41 / 107
Netfabb Lua Scripting API
Documentation
Reference.docx
exportforsimulation(file:
string; material: string;
laser_spot_mm: number; Generate a 3mf file that contains all parts of the tray with
exportforsimul
unify_support: Boolean; attached support and hulled support for process
ation
workspace_uuid: string; simulation.
workspace_name: string;
laser_Count: number)
getuuid Uuid = tray:getuuid() Retrieve the UUID of the tray
The Netfabb LUA tray object also contains some constant members
Name Type Description
packingid_2d Number Constant for the 2d packer, see “tray:createpacker”
packingid_3d Number Constant for the 3d packer, see “tray:createpacker”
packingid_montecarlo Number Constant for the monte carlo packer, see “tray:createpacker”
packingid_null Number Constant for the null packer, see “tray:createpacker”
packingid_outbox Number Constant for the outbox packer, see “tray:createpacker”
2.6.3 LUAMeshGroup
[Desktop Automation]
LUAMeshGroups are used to organize the meshes within a tray. Each
LUAMeshGroup can contain meshes and subgroups. The root group of a tray is
stored in "LUATray:root"
2.6.3.1 Properties
Property Read / Write Type Description
meshcount read Number Get the number of meshes within the group
name Read / write String Name of the meshgroup
parent read LUAMeshGroup The parent meshgroup
outbox Read LuaOutbox The outbox of the mesh group
42 / 107
Netfabb Lua Scripting API
Documentation
Reference.docx
2.6.4 LUATrayMesh
[Desktop Automation]
The LUATrayMesh object contains the data of the actual meshes of a
fabbproject, i.e. an instance of LUAMesh (Reference: Mesh Objects) and its
position, scale and rotation
2.6.4.1 Properties
Read /
Property Type Description
Write
Get the area of the tray mesh (including
area read Number
transformation, in mm^2)
Set or get the color, (only the color used to
color Read/Write Number display the mesh, not the mesh color
information)
matrix read LUAMatrix4f Get the transformation matrix of the mesh
Get the mesh of the traymesh. Please note that
mesh read LUAMesh this is only a copy of the LUAMesh in the Lua
Automation module.
name Read / write String Name of the mesh
Get the outbox base area of the tray mesh
outboxbasearea read Number
(including tansformation, in mm^2)
Get the outbox height of the tray mesh
outboxheight read Number
(including transformation, in mm)
Get the outbox volume of the tray mesh
outboxvolume read Number
(including transformation, in mm^3)
parent Read / write LUAMeshGroup Get or Set the group the mesh belongs to
uuid read String UUID of the mesh
selected read / write Boolean If the mesh is selected in the tray
Get the volume of the tray mesh (including
volume read Number
transformation, in mm^3)
43 / 107
Netfabb Lua Scripting API
Documentation
Reference.docx
44 / 107
Netfabb Lua Scripting API
Documentation
Reference.docx
2.6.5 LUACollisionResult
[Desktop Automation]
An instance of this object is returned by the “checkforcollisions” function of the
LUATray object (Reference: LUATray). It contains information about the
collisions within a tray.
2.6.5.1 Properties
Property Read / Write Type Description
45 / 107
Netfabb Lua Scripting API
Documentation
Reference.docx
2.6.6 LUAPacker
[Desktop Automation]
An instance of this object is returned by the “createpacker” function of the
LUATray (Reference: LUATray). It can be used to pack the content of the tray.
Please note, that the packer gets a snapshot of the current tray at creation time.
If you add meshes afterwards to the packer, they are not packed.
2.6.6.1 Properties
Property Read / Write Type Description
46 / 107
Netfabb Lua Scripting API
Documentation
Reference.docx
47 / 107
Netfabb Lua Scripting API
Documentation
Reference.docx
2.6.7.1 Properties
This section describes packer-specific properties of the Monte Carlo packer.
Property Read / Write Type Description
Is an integer number ranging from -8
(corresponding to the lowest packing density)
to +8 (corresponding to the highest packing
packing_quality Read/Write Number
density). The higher the packing quality the
more time is needed for the packing process.
The default value is packing_quality=0
z_limit is the height in mm of the platform
space that is allowed to contain the parts (the
distance from the platform floor to the upper
point of the packable region). It is a
nonnegative real number which should not
z_limit Read/Write Number exceed the platform height:
z_limit<=MachineSizeZ. If the parameter value
does not satisfy these conditions, the default
value is used instead.
The default value is the platform height
MachineSizeZ
48 / 107
Netfabb Lua Scripting API
Documentation
Reference.docx
2.6.8.1 Properties
The 3d scanline packer is also using borderspacingxy, borderspacingz, but not
defaultpartrotation and minimaldistance of the general properties. This section
describes packer-specific properties of the Scanline packer.
49 / 107
Netfabb Lua Scripting API
Documentation
Reference.docx
note that this packer is only available in the Lua Automation Module of the
Desktop version
2.6.9.1 Properties
The 2d packer is also using borderspacingxy, but not defaultpartrotation,
borderspacingz, and minimaldistance of the general properties. This section describes
packer-specific properties of the 2d packer.
51 / 107
Netfabb Lua Scripting API
Documentation
Reference.docx
2.6.10.1 Properties
This section describes packer-specific properties of the outbox packer.
[Desktop Automation]
Descendents of this class are:
• Groupbox
• Splitter
• TabSheet
• Dialog
52 / 107
Netfabb Lua Scripting API
Documentation
Reference.docx
The control container is the base class for all GUI elements that can contain other
GUI elements and provides the following methods to add the corresponding ele-
ments:
2.7.1.1 Properties
None.
2.7.2 Button
[Desktop Automation]
53 / 107
Netfabb Lua Scripting API
Documentation
Reference.docx
2.7.2.1 Properties
Property Read / Write Type Description
bold read / write boolean shall the button text be bold?
caption read / write string Caption of the button
enabled read / write boolean shall the button be enabled?
height read / write number height in pixels
hint read / write string Hint / Tooltip for the button
onclick read / write string callback function for a click event
translate read / write boolean if true, 'caption' has to be String Identifier
visible read / write boolean shall the button be visible?
None.
2.7.3 Picturebutton
[Desktop Automation]
2.7.3.1 Properties
Property Read / Write Type Description
bold read / write boolean shall the caption be bold?
caption read / write string caption of the picturebutton
enabled read / write boolean shall the button be enabled?
height read / write number height in pixels
hint read / write string Hint / Tooltip for the button
onclick read / write string callback function for a click event
picture read / write string small picture on the button
translate read / write boolean if true, 'caption' must be String Identifier
visible read / write boolean shall the button be visible?
None.
2.7.4 Checkbox
[Desktop Automation]
54 / 107
Netfabb Lua Scripting API
Documentation
Reference.docx
2.7.4.1 Properties
Property Read / Write Type Description
caption read / write string caption of the checkbox
checked read / write boolean if true, Checkbox is checked
enabled read / write boolean if true, Checkbox is enabled
hint read / write string Hint / Tooltip for the button
leftspacing read / write number spacing on the left in pixels
onclick read / write string callback function for a click event
topspacing read / write number spacing on the top in pixels
translate read / write boolean if true, 'caption' has to be String Identifier
visible read / write string Shall the ckeckbox be visible?
None.
2.7.5 Groupbox
[Desktop Automation]
Descendent of ControlContainer Base class providing all functions of this base class
2.7.5.1 Properties
Property Read / Write Type Description
borderstyle read / write number style of the border (0, 1, 2 or 3)
caption read / write string caption of the groupbox
enabled read / write boolean Shall the groupbox be enabled?
hint read / write string Hint / Tooltip for the button
horizontalpadding read / write number left and right padding in pixels
minheight read / write number minimum height of the groupbox in pixels
verticalpadding read / write number top and bottom padding in pixels
visible read / write boolean Shall the groubox be visible?
2.7.6 Dropdown
[Desktop Automation]
55 / 107
Netfabb Lua Scripting API
Documentation
Reference.docx
Tips:
• Always create them with id = priority as an ascending integer
• Don’t use the write property of selectedindex to change the control’s selected
item – it doesn’t work. Use selecteditem (which references the “id” field of addi-
tem()) instead.
2.7.6.1 Properties
Property Read / Write Type Description
Gives the Background color as a string.
backgroundcolor Read/write String
Format is ‘$BBGGRR’
caption read / write string caption of the dropdown
captionwidth read / write number width of the caption in pixels
captionwidthpercentage Read / write Number Width of the catpion in percentage
Enable custom drawing of dropdown items
(parameters “style”, “fontcolor” of method
customdraw Read / write boolean “additem” has no effect if this member is
remains “false” (default)), also
“backgroundcolor” as no effect
count read number Number of items in the dropdown
enabled read / write boolean Shall the dropdown be enabled?
hint read / write string Hint / Tooltip for the button
onchange read / write string callback function for a change event
The id of the selected item (see method
selecteditem read / write number
“additem”)
selectedindex read / write number The index of the selected item (0-based)
spacing read / write number spacing of the dropdown
translatecaption read / write boolean if true, 'caption' has to be String Identifier
visible read / write boolean Shall the dropdown be visible?
56 / 107
Netfabb Lua Scripting API
Documentation
Reference.docx
2.7.7 Edit
[Desktop Automation]
2.7.7.1 Properties
Property Read / Write Type Description
caption read / write string caption of the edit
captionwidth read / write number width of the caption in pixels
captionwidthpercentage Read / write Number Width of the catpion in percentage
Custom background color for the edit.
customcolor read / write string
Format is ‘$BBGGRR’
enabled read / write boolean Shall the edit be enabled?
hint read / write string Hint / Tooltip for the button
should be read out in a key up/down
key read / write string
callback
Flag to specify whether or not only
numbersonly read / write boolean numeric characters are valid for the edit
field
onchange read / write string callback function for a change event
onkeydown read / write string callback function for a key-down event
onkeyup read / write string callback function for a key-up event
readonly read / write boolean Shall the edit be readonly?
spacing read / write number spacing of the edit in pixels
text read / write string text content of the edit
topspacing read / write number top spacing og the edit in pixels
translate read / write boolean if true, 'caption' has to be String Identifier
visible read / write boolean Shall the edit be visible?
2.7.8 Label
[Desktop Automation]
2.7.8.1 Properties
Property Read / Write Type Description
caption read / write string caption of the label
fontcolor gives color of the text. Format is
fontcolor Read/write string
‘$BBGGRR’
hint read / write string Hint / Tooltip for the button
57 / 107
Netfabb Lua Scripting API
Documentation
Reference.docx
None.
2.7.9 Scrollbar
[Desktop Automation]
2.7.9.1 Properties
Property Read / Write Type Description
enabled read / write boolean Shall the scrollbar be enabled?
height read / write number height of the scrollbar in pixels
hint read / write string Hint / Tooltip for the button
max read / write number maximum value of the scrollbar
onchange read / write string callback function for a change event
orientation read / write number 0: vertical 1: horizontal
position read / write number position of the bar that can be tracked
spacing read / write number spacing of the scrollbar in pixels
visible read / write boolean Shall the scrollbar be visible?
None.
2.7.10 Slider
[Desktop Automation]
Notes: you cannot set the units. Units are always integer between “min” and
“max”. You need to implement some more calculation if you need other units.
Example:
function SetupUI()
GEditSlider = interface_main_frame:addedit()
GEditSlider.caption = "Position"
GEditSlider.translate = false
GSlider = interface_main_frame:addslider()
GSlider.caption = "Slider"
GSlider.captionwidth = 120
GSlider.min = 46
GSlider.max = 93
58 / 107
Netfabb Lua Scripting API
Documentation
Reference.docx
GSlider.position = 69
GSlider.onchange = "SliderCallback"
SliderCallback()
end
function SliderCallback()
GEditSlider.text = "Position: " .. GSlider.position
End
2.7.10.1 Properties
Property Read / Write Type Description
caption read / write string caption of the slider
captionspacing read / write number spacing of the caption in pixels
captionwidth read / write number width of the caption in pixels
captionwidthpercentage Read / write Number Width of the catpion in percentage
enabled read / write boolean Shall the slider be enabled?
height read / write number height of the slider in pixels
hint read / write string Hint / Tooltip for the button
max read / write number maximum value of the slider
onchange read / write string callback function for a change event
position read / write number position of the slider
spacing read / write number spacing of the slider in pixels
topspacing read / write number top spacing of the slider in pixels
translate read / write boolean if true, 'caption' is String Identifier
visible read / write boolean Shall the slider be visible?
None.
2.7.11 Memo
[Desktop Automation]
2.7.11.1 Properties
Property Read / Write Type Description
caption read / write string caption of the memo
captionwidth read / write number width of the caption in pixels
captionwidthpercentage Read / write Number Width of the catpion in percentage
59 / 107
Netfabb Lua Scripting API
Documentation
Reference.docx
2.7.12 Spacer
[Desktop Automation]
2.7.12.1 Properties
Property Read / Write Type Description
height read / write number height of the spacer in pixels
visible read / write boolean Shall the spacer be visible?
2.7.13 Splitter
[Desktop Automation]
Descendent of ControlContainer Base class providing all functions of this base class
2.7.13.1 Properties
Property Read / Write Type Description
spacing read / write number spacing of the splitter in pixels
0: default 1: left split is smaller 2: right split is
splittype read / write number
smaller
visible read / write boolean Shall the splitter be visible?
width read / write number width of the splitter in pixels
60 / 107
Netfabb Lua Scripting API
Documentation
Reference.docx
2.7.14 Dialog
[Desktop Automation]
Descendent of ControlContainer Base class providing all functions of this base class
2.7.14.1 Properties
Property Read / Write Type Description
caption read / write string caption of the dialog
translatecaption read / write boolean if true, caption is String Identifier
width read / write number width of the dialog in pixels
2.7.15 TableObject
[Desktop Automation]
The table object is a GUI object that allows you to represent data in a column-
row grid. It is created using the ":addtable" method of a GUI container (e.g.
Dialog).
2.7.15.1 Properties
Property Read / Write Type Description
columncount Read / Write number Get the number of columns of the table
Get the number of fixed (headline) columns of
fixedcolumncount Read / Write number
the table
Get the number of fixed (headline) rows of the
fixedrowcount Read / Write number
table
height Read / Write number Get the height of the table
ondoubleclick Read / Write String Lua callback method for double click event
61 / 107
Netfabb Lua Scripting API
Documentation
Reference.docx
rowcount Read / Write number Get the number of rows of the table
See whether or not the headlines are
translateheadline Read / Write boolean
translated automatically
2.7.16 TabControl
[Desktop Automation]
With the tab control you can arrange dialogs in multiple tabs. Use “addtabcontrol”
to add such an element
2.7.16.1 Properties
Property Read / Write Type Description
activepage Read / Write number Get and set the currently active page
pagecount Read number Get the number of pages of the control
2.7.17 TabSheet
[Desktop Automation]
A TabSheet represents a tab of the TabControl object. It can be created using
TabControl:addtabsheet(). Descendent of ControlContainer Base class providing
all functions of this base class
2.7.17.1 Properties
Property Read / Write Type Description
caption Read / Write string The caption of the tabsheet
translate Read / Write Boolean Should the caption be translated?
62 / 107
Netfabb Lua Scripting API
Documentation
Reference.docx
2.7.18 Image
[Desktop Automation]
2.7.18.1 Properties
Property Read / Write Type Description
height Read / Write Number Height of the image UI element
hint read / write string Hint / Tooltip for the button
Keep the aspect ratio. This will only have an
keepratio Read / Write Boolean effect if only either width or height are set and
if the “stretch” parameter is set to true
The image to be shown in the UI element.
picture Read / Write String / Object Can either be a string referencing an image
file or an Image Object
Onclick listener to handle Onclick event of the
onclick Read / Write String
image
X-Position of the mouse, usefull after onclick
mousex Read Number
event
Y-Position of the mouse, usefull after onclick
mousey Read Number
event
Should the image be stretched to the size
stretch Read / Write Boolean
defined by “width” and “height”?
width Read / Write Number Width of the image UI element
2.7.19 FloatSpinEdit
[Desktop Automation]
A Spin Edit UI element that allows modification of Float numbers using up and
downd buttons. It is created by “controlcontainer:addfloatspinedit()
63 / 107
Netfabb Lua Scripting API
Documentation
Reference.docx
2.7.19.1 Properties
Property Read / Write Type Description
caption Read / Write String The caption that is placed in front of the edit
captionwidth Read / Write Number Width of the edit’s caption
captionwidthpercentage Read / write Number Width of the catpion in percentage
Custom background color for the edit.
customcolor Read / Write String
Format is ‘$BBGGRR’
decimalplaces Read / Write Number Number of decimal places shown
enabled Read / Write Boolean Flag to enable and disable the edit
height Read / Write Number Height of the edit field
hint Read / Write String Hint to be shown
max Read / Write Number Maximum value
min Read / Write Number Minimum value
Flag to specify whether or not the edit field
readonly Read / Write Boolean
is read only
spacing Read / Write Number Spacing of the spin edit in pixels
Size of the steps applied using the up and
step Read / Write Number
down buttons
topspacing Read / Write Number Top spacing of the spin edit in pixels
Flag to specify whether or not the caption
translate Read / Write Boolean
and the hint should be translated
value Read / Write Number Value of the spin edit.
None.
[Desktop Automation]
The Histogram Object allows the user to plot any values into an histogram or
graph. It is created by “system:createhistogram()”.
2.7.20.1 Properties
64 / 107
Netfabb Lua Scripting API
Documentation
Reference.docx
[Desktop Automation]
Image UI element. It is created by “system:creategraph()”.
2.7.21.1 Properties
None.
65 / 107
Netfabb Lua Scripting API
Documentation
Reference.docx
2.8.1.1 Properties
Property Read / Write Type Description
contourcount read number returns the number of contours of a slice layer
contourlength read number returns the contourlength a slice layer
hatchcount read number returns the number of hatches of a slice layer
hatchlength read number returns the hatchlength a slice layer
maxx read number maximum X of a slice layer
maxy read number maximum Y of a slice layer
minx read number minimum X of a slice layer
miny read number minimum Y of a slice layer
66 / 107
Netfabb Lua Scripting API
Documentation
Reference.docx
begincontour slice:begincontour();
endcontour slice:endcontour();
extractcontour slice:extractcontour(?:number);
2.8.2.1 Properties
Property Read / Write Type Description
backgroundcolor read / write number color of the background
basefilename read / write string base file name of the images
closedcontourcolor read / write number color of the closed contours
closedcontourwidth read / write number width of the closed contours in mm
dpix read / write number dpi in X
dpiy read / write number dpi in Y
dofillingbooled read / write boolean
exportmonochromeimages read / write boolean Shall monochrome images be exported?
fillclosedcontours read / write boolean Shall the closed contours be filled?
fillcolor read / write number color of the filling
hatchcolor read / write number color of the hatches
hatchwidth read / write number width of the hatch in mm
height read / write number height of image in pixels
left read / write number left space of the image in pixels
maxx read number maximum X of the image
maxy read number maximum Y of the image
maxz read number maximum Z of the image
minx read number minimum X of the image
miny read number minimum Y of the image
minz read number minimum Z of the image
opencontourcolor read / write number color of the open colours
opencontourwidth read / write number width of the open contours in mm
67 / 107
Netfabb Lua Scripting API
Documentation
Reference.docx
2.8.3.1 Properties
Property Read / Write Type Description
layercount read number returns count of layers
returns thickness of the layers (if consistent
layersize read number
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 number returns / sets name of the slice
68 / 107
Netfabb Lua Scripting API
Documentation
Reference.docx
resultsliceobject = slice:
conversion_filtercontoursbyarea conversion_filtercontoursbyarea
(MinContourArea : number)
resultsliceobject = slice:
conversion_hatchestocontour(Accuracy :
conversion_hatchestocontour Number; DoMergeHatches : Boolean;
KeepMergeOrder : Boolean )
resultsliceobject = slice:
conversion_hatchpermutation conversion_hatchpermutation
(PermuteEveryNthHatch : integer);
resultsliceobject = slice:
conversion_randomizeseam
conversion_randomizeseam();
resultsliceobject =
slice:conversion_revertdirection
conversion_revertdirection (RevertEveryNthLayer: integer;
RevertLayerOffset : integer)
Create an
slice:createaggregation(Offset[mm]:float, aggregation; returns
createaggregation
Accuracy:float); the result as new slice
object
resultsliceobject = slice:
createcontoursegmentation( Length := Number;
Count :.Integer; Overlap : NumberValue = 0;
createcontoursegmentation RandomizeSeam : Boolean = false;
IncludeHatches : Boolean = false);
Creates a downskin;
createdownskin slice:createdownskin(); returns the result as
new slice object
resultsliceobject = slice:
createflowsegmentation( AAngle :
createflowsegmentation Number;ADirectionTolerance : Number;
AInvertNegatives: Boolean; AIncludeHatches :
Boolean);
69 / 107
Netfabb Lua Scripting API
Documentation
Reference.docx
Creates an offset
(inner or outer given
slice:createoffset(offset[mm]: float, by is_inner_offset)
createoffset is_inner_offset:boolean, roundness with a given
[degree]:float = 30); roundness; ; returns
the result as new slice
object
slice:createquadfilling(HatchDistance:float,
Angle :float = 0 , AngleIncrement :float =0,
createquadfilling OnlyEachLayer : int = 1, HatchOriginIncrement Create a quad filling
:float = 0, QuadSizeX:float =20 ,
QuadSizeY:float =20)
createrenderer slice:createrenderer(layerfactor:int);
Creates a rotated
slice, rotated, by an
createrotatedslice slice:createrotatedslice (rotationfactor:int);
angle of
‘rotationfactor’
Creates a scaled
slice, if called with
slice: createscaledslice (factorx:int [,
createscaledslice only one parameter
factory:int]);
the scaling factorx is
used for x and y.
Creates a hatching on
the sliceobject; you
can increment the
angle at each layer by
setting
angleincrement;
slice:createsimplehatching(hatchdistance:float,
hatches are created
angle:float =0, angleincrement:float = 0,
createsimplehatching only at ech layer by
onlyeachlayer:int = 1,
setting onlyeachlayer;
hatchoriginincrement:float = 0);
with the parameter
hatchoriginincrement
the hatchs can be
shifted at each layer;
returns the result as
new slice object
slice:createstripfilling(HatchDistance:float,
StripeWidth:float = 10, StripeGap:float,
createstripefilling Create a strip filling
Angle:float = 0, AngleIncrement:float = 0,
OnlyEachLayer:int = 1, SortType:int )
Creates slice
slice: createtranslatedslice (factorx:int , trlanlated by the
createtranslatedslice
factory:int); factors factorx and
factory.
Creates an upskinr;
createupskin slice:createupskin(); returns the result as
new slice object
Duplicate the slice
duplicate slice:duplicate
object;
slice:executecalculation(debugmessage:string, Really executes all
executecalculation
layerthickness:number); calculations
Returns the Z height
getlayerz slice:getlayerz(layerindex:int);
of a layer
70 / 107
Netfabb Lua Scripting API
Documentation
Reference.docx
resultsliceobject = slice:hatchextension(
FixedDistance1, AngleFactorA1,
AngleFactorB1, AngleFactorC1,
AnglePowerA1, AnglePowerB1,
hatchextension AnglePowerC1, FixedDistance2,
AngleFactorA2, AngleFactorB2,
AngleFactorC2, AnglePowerA2, AnglePowerB2
, AnglePowerC2: number);
71 / 107
Netfabb Lua Scripting API
Documentation
Reference.docx
Example:
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
slicelist = slice:multilasersplit (lcount, -- Shift per layer 2.5
acc,.mbsize, mdist, perlayershift,
multilasersplit gflow, overlap, overlapa); -- 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);
slice: pointreduction
pointreduction Applies point reduction on slice
(ATolerance:number);
72 / 107
Netfabb Lua Scripting API
Documentation
Reference.docx
2.9.1.1 Properties
Property Read / Write Type Description
Returns the number of xml nodes of the root
childcount read only Number
entry
root read Object Query the root node as XMLNode object
rootname read / write String Section name of the root entry
useattributesaschildren Read / write Boolean Should attributes be treated as child nodes?
73 / 107
Netfabb Lua Scripting API
Documentation
Reference.docx
Examples
Name Syntax Description
boolean: returns true if the
childexists xmlfile:childexists("parameters/fixingmode", 2);
desired node exists
addvalue xmlfile:addvalue("parameters/fixingmode", 2); -
savetofile xmlfile:savetofile("var/log/test.xml"); -
dump xmlfile:dump() -
2.9.2.1 Properties
Property Read / Write Type Description
Returns the number of xml nodes of the root
childcount read only Number
entry
section Read / write String Section name of the root entry
value Read only String Value of the node
74 / 107
Netfabb Lua Scripting API
Documentation
Reference.docx
2.9.3.1 Properties
None.
75 / 107
Netfabb Lua Scripting API
Documentation
Reference.docx
2.9.4.1 Properties
Property Read / Write Type Description
rowlength read only Number Returns the number of fields
tablelength read only Number Returns the number of lines
76 / 107
Netfabb Lua Scripting API
Documentation
Reference.docx
2.9.5.1 Properties
Property Read / Write Type Description
linecount read only Number Returns the number of lines
[Desktop Automation]
Database connection and query handler.
2.10.1.1 Properties
Property Read / Write Type Description
Returns TRUE, if the DB connection is
connected read only Boolean
established
lasterror Read only String The last DB error
77 / 107
Netfabb Lua Scripting API
Documentation
Reference.docx
2.10.2.1 Properties
None.
[Desktop Automation]
A render context for previews. The OGLRendering Object is created by calling "
system:createoglcontext". The rendering object itself works with:
• models: individual meshes
• scenes: arrangements of models
2.11.1.1 Properties
None.
78 / 107
Netfabb Lua Scripting API
Documentation
Reference.docx
79 / 107
Netfabb Lua Scripting API
Documentation
Reference.docx
DEBUG ONLY:
Releases the
release oglcontext:release (); current oglcontext
(allowing to create a
new one)
releaserawbuffer oglcontext:releaserawbuffer (); DEBUG ONLY
render oglcontext:Render (); Renders the scene
Rotates the model
across the camera
oglcontext:Rotate (Modelid:integer, angle: vector (needs to be
rotate
integer); set up first with
Lookatmodelfromsur
roundingsphere)
Saves current scene
to BMP file as
'filename'.
oglcontext:Savetobmp (filename:string,
savetobmp Threaded: optional
threaded: boolean);
parameter, when
true the export runs
in a separate thread
Saves current scene
to JPEG file as
'filename'.
Quality: JPEG
oglcontext:savetojpeg (filename:string,
savetojpeg quality, default: 90
quality: integer, threaded: boolean);
Threaded: optional
parameter, when
true the export runs
in a separate thread
Saves current scene
to PNG file as
'filename'.
oglcontext:savetopng (filename:string,
savetopng Threaded: optional
threaded: boolean);
parameter, when
true the export runs
in a separate thread
scale oglcontext:Scale (x,y,z:all float); Scales the context
oglcontext:SetBackgroundColor (r, g, b: all Sets background
setBackgroundColor
integer); colour to RGB value
Background
gradient map: RBG
values for the points
oglcontext:SetBackgroundGradient (ar, ag, a, b, c and d.
setBackgroundGradient ab, br, bg, bb, cr, cg, cb, dr, dg, db: all A = bottom left
integer);
B = bottom right
C = top right
D = top left
oglcontext:Setenvironmentmodel Sets the
setenvironmentmodel
(modelid:integer); environment model
Changes the
uniform color of a
model. In order to
oglcontext:setmodelcolor(modelid: integer, r,
setModelColor usethis method
g, b, a: float)
vertex colors need
to be disabled in the
createmodel call.
oglcontext:setmodeltextureenabled(textureen Changes the
setModelTextureEnabled
abled: boolean) textureendabled flag
80 / 107
Netfabb Lua Scripting API
Documentation
Reference.docx
2.11.2.1 Properties
None.
[Desktop Automation]
All colors are encoded as Integer 0xBBGGRR
2.11.3.1 Properties
Property Read / Write Type Description
height read only Number Height of the image
width read only Number Width of the image
81 / 107
Netfabb Lua Scripting API
Documentation
Reference.docx
[Desktop Automation]
2.12.1.1 Properties
None.
82 / 107
Netfabb Lua Scripting API
Documentation
Reference.docx
[Desktop Automation]
Sometimes a CAD File consists of several single files. You can access the
number of single entities by the property entitycount and get an entity’s name by
the method getentityname(Index). You can create a mesh with all entities using
the method createmesh or you can create a mesh with a single entity using the
property createsinglemesh.
2.12.2.1 Properties
Name Syntax Description
Holds the number of entities of
entitycount entities = cadmodel.entitycount
the cadmodel
Holds the number of triangles of
trianglecount triangles = cadmodel.trianglecount
the cadmodel
83 / 107
Netfabb Lua Scripting API
Documentation
Reference.docx
name = cadmodel:getentityname(EntityIndex:
getentityname Returns the entity’s name
Number);
2.13.1 LUAVector3
The LUA representation of a vector with 3 components (x, y, z)
2.13.1.1 Properties
Read /
Property Type Description
Write
x Read / write Number X-Component of the vector
y Read / write Number Y-Component of the vector
z Read / write Number Z-Component of the vector
2.13.1.2 Methods
None.
2.13.2 LUAArray
2.13.2.1 Properties
Property Read / Write Type Description
length Read Integer Length of the array
2.13.2.2 Methods
Name Syntax Description
get array:get(index: integer) Get the array value at index
set array:set(index: integer; value: number) Set the array value at index
2.13.3 LUAStringMap
The LUA representation of a map of strings (key / value pairs)
84 / 107
Netfabb Lua Scripting API
Documentation
Reference.docx
2.13.3.1 Properties
Property Read / Write Type Description
count Read Integer Number of items in the map
2.13.3.2 Methods
Name Syntax Description
setitem Map:setitem(AKey: String; Avalue: String) Set an Item (add or replace)
getitem Item = Map:getitem(AKey: String) Get an Item by key
deleteitem Map:deleteitem(AKey: String) Delete an item with a key
KeyItem = Map:getitembyindex(AIndex: Get an item with key by index
getitembyindex
Integer) (Format: “Key”=”Value”)
2.13.4 LUAMatrix4f
The Lua representation of a 4x4 Matrix.
2.13.4.1 Properties
None
2.13.4.2 Methods
Name Syntax Description
get matrix:get(x: integer; y: integer) Get the matrix value at x and y
matrix:set(x: integer; y: integer; value:
set Set the matrix value at x and y
number)
2.13.5 LUAAlignment
2.13.5.1 Properties
Read /
Property Type Description
Write
First principal axis designating the shortest
firstaxis Read TLUAVector3f axis of the reference mesh. Can be used to
set up the camera for rendering
A new model to world matrix for the
newmodeltoworldmatrix Read TLUAMatrix4f
mesh/model to be transformed
Second principal axis designating the longest
secondaxis Read TLUAVector3f axis of the reference mesh. Can be used to
set up the camera for rendering
Third principal axis designating the remaining
thirdaxis Read TLUAVector3f axis of the reference mesh. Can be used to
set up the camera for rendering
The matrix that needs to be multiplied with
the model to world matrix to align the
transformationmatrix Read TLUAMatrix4f
mesh/model to be aligned with the reference
mesh/model
85 / 107
Netfabb Lua Scripting API
Documentation
Reference.docx
2.13.5.2 Methods
None
2.13.6.1 Properties
Property Read / Write Type Description
minx Read/write Number Returns the min_x (in mm)
miny Read/write Number Returns the min_y (in mm)
minz Read/write Number Returns the min_z (in mm)
maxx Read/write Number Returns the max_x (in mm)
maxy Read/write Number Returns the max_y (in mm)
maxz Read/write Number Returns the max_z (in mm)
None.
2.14.1.1 Properties
Read /
Property Type Description
Write
The description of the last error, that has
lasterror Read String
occured
86 / 107
Netfabb Lua Scripting API
Documentation
Reference.docx
2.14.2.1 Properties
Read /
Property Type Description
Write
The description of the last error, that has
lasterror Read String
occured
parametercount Read Number Number of parameters of the task
resultcount Read Number Number of results for the task
A status string. One of:
SUCCESS
ERROR
RETURNED
CANCELED
status Read String NEW
INPROCESS
“NEW” and “INPROCESS” can’t be set
by the Netfabb Client API, this is only
done by the Taskserver itself.
taskname Read String Name of the task
uuid Read String UUID of the task
87 / 107
Netfabb Lua Scripting API
Documentation
Reference.docx
[Desktop Automation]
Hublist objects are created from these methods of the Application object:
- loadappserverhublist and
- loadforgehublist
Both calls return a list of hubs from the respective context, either the Autodesk
Forge Cloud system or the Netfabb Application Server local storage definition.
2.14.3.1 Properties
Read /
Property Type Description
Write
count Read String Number of hubs in this list
[Desktop Automation]
88 / 107
Netfabb Lua Scripting API
Documentation
Reference.docx
2.14.4.1 Properties
Read /
Property Type Description
Write
id Read String ID of this hub
name Read String Name of this hub
A projectlist is a list of projects from a hub, either from Autodesk Forge or from
the Netfabb Application Server.
2.14.5.1 Properties
Read /
Property Type Description
Write
count Read String Number of projects in this list
[Desktop Automation]
A project is a collection of folders from a hub, either from Autodesk Forge or from
the Netfabb Application Server.
2.14.6.1 Properties
Read /
Property Type Description
Write
89 / 107
Netfabb Lua Scripting API
Documentation
Reference.docx
A folderlist is a list of folders from a project, either from Autodesk Forge or from
the Netfabb Application Server.
2.14.7.1 Properties
Read /
Property Type Description
Write
count Read Integer Number of folders in this list
[Desktop Automation]
A folder is an object from a project, either from Autodesk Forge or from the Net-
fabb Application Server.
2.14.8.1 Properties
Read /
Property Type Description
Write
contenthasbeenreceived Read Boolean Has content been received?
forcehidden Read Boolean Hide the folder
id Read String Id of folder
ishidden Read Boolean Is the folder hidden?
name Read String Name of folder
projectid Read String ProjectID to this folder
90 / 107
Netfabb Lua Scripting API
Documentation
Reference.docx
[Desktop Automation]
An itemlist is a list of items from a projectfolder, either from Autodesk Forge or
from the Netfabb Application Server.
2.14.9.1 Properties
Read /
Property Type Description
Write
count Read Integer Number of items in list
[Desktop Automation]
An item is a content element from a projectfolder, either from Autodesk Forge or
from the Netfabb Application Server.
2.14.10.1 Properties
Read /
Property Type Description
Write
createuser Read String User, who has created the item
folderid Read String Id of the folder
id Read String Id of the item
lastmodifier Read String User, who has last modified the item
91 / 107
Netfabb Lua Scripting API
Documentation
Reference.docx
2.15.1 LUAStamper
[Desktop Automation]
This Lua objects allows to label meshes. A text is stamped on the meshes. The
position of the text, the estimated plane of the text, and the direction where is up
needs to be given. Please note that the example script
Script17_LabelMeshes.lua has some helper functions for setting the position,
normal, and upvector.
2.15.1.1 Properties
Read /
Property Type Description
Write
depth Read /write number The depth of the label.
The height of the label in mm. The width is
height Read /write number
scaled to match the original ratio.
isinverted Read /write boolean If true the text is inverted
If false, the label is added to meshes, otherwise
issubtracted Read /write boolean
is subtracted
pos Read TLUAVector3f The position of the label.
normal Read TLUAVector3f The normal of the plane of the label.
upvector Read TLUAVector3f The defines, what is up and down.
2.15.1.2 Methods
Name Syntax Description
92 / 107
Netfabb Lua Scripting API
Documentation
Reference.docx
2.15.2 LUAReportgenerator
[Desktop Automation]
2.15.2.1 Properties
None
2.15.2.2 Methods
Name Syntax Description
Takes a TrayMesh and
generates a report based on
the given template. The report
reportgenerator:createreportformesh (Mesh: is saved in file called
createreportformesh LUATrayMesh, template : string; reportname : reportname. For optimal output
string) the template type should
correspond to a tray.
[Desktop Automation]
The Lua test framework provides functionality for uniform test suites and
convenient result file formats.
2.15.3.1 Properties
Property Read / Write Type Description
childcount read only Number Number of direct sub test suites
errormessage read / write String Errormessage of this test on failure
93 / 107
Netfabb Lua Scripting API
Documentation
Reference.docx
94 / 107
Netfabb Lua Scripting API
Documentation
Reference.docx
2.15.4 ZipObject
[Desktop Automation]
This object is used for creating/managing ZIP files.
2.15.4.1 Properties
Property Read / Write Type Description
Number of files in the open ZIP archive. Only
count read only Number
available in archives opened for reading
Flag indicating wether or not the archive can
canread read only Boolean be read from. Only functions marked in green
are available if this flag is set
Flag indicating wether or not the archive can
canwrite read only Boolean be written to. Only functions marked in yellow
are available if this flag is set
password read / write String Password of the ZIP archive.
Please not that the “add*” and the “exportfile” methods are only available in ZIP
files opened for writing using “system:createzip” whereas the “load*” and “get*”
methods are only available when the file was opened for reading using either
“system:openzip”.
Availability of the functions is marked by colors for archives open for reading and
writing.
Name Syntax Description
Zipobject:addstring(stringtoadd:string, Adds stringtoadd to zipobject as
addstring
zipname:string); zipname
Adds filetoadd to zipobject as
addfile Zipobject:addfile(filetoadd:string, zipname:string);
zipname
Zipobject:addtext(texttoadd:Lua Textfile object, Adds texttoadd (a Lua textfile
addtext
zipname:string); object) to zipobject as zipname
Zipobject:addxml(xmltoadd:Lua XML object, Adds xmltoadd (a Lua XML
addxml
zipname:string); object) to zipobject as zipname
Exports the ZIPfile as filename.
File cannot be changed
exportfile Zipobject:exportfile(filename:string); afterwards by API. This function
is only available if a ZIP is
created using the LUA API
Saves the file “filename” from
Zipobject:extractfile(filename: String; targetname:
extractfile the archive to the file
String)
“targetname” on the file system
Returns the name of the file
getfilename Zipobject:getfilename(index: number) with the index <index> of the
open zip file
Returns the index of the file
getfileindex Zipobject:getfileindex(filename: String) with the name <filename> of
the zip file
95 / 107
Netfabb Lua Scripting API
Documentation
Reference.docx
2.15.5 PartOrienter
[Desktop Automation]
This object allows to orient a part with several options. The orienter calculates
several solutions with its criteria values.
2.15.5.1 Properties
Read /
Property Type Description
Write
96 / 107
Netfabb Lua Scripting API
Documentation
Reference.docx
An orientation solution is a lua_json object. The json object has the the following
attributes:
Attribute Description
outbox_volume Outbox volume of the part
part_height Part height
support_area Support area of the part
support_volume Support volume of the part
center_of_gravity_x Center of Gravity x
center_of_gravity_y Center of Gravity y
center_of_gravity_z Center of Gravity z
rotation_axis_x Rotation axis in x for this orientation
rotation_axis_y Rotation axis in y for this orientation
rotation_axis_z Rotation axis in z for this orientation
rotation_radian Rotation angle in radian this orientation
rotation_degree Rotation angle in degree this orientation
rotation_matrix Rotation 4*4 matrix as string. The matrix is colum-major.
97 / 107
Netfabb Lua Scripting API
Documentation
Reference.docx
2.15.6 PartAnalysis
[Desktop Automation]
This object is used to run analyses on the underlying mesh. Those include the
default, center of gravity, wall thickness, support volume, shadow area and up-
skin/downskin analyses. The available methods run the analyses, the properties
can then be used to get results, with each analysis having a property to indicate
successful calculation. The object is created from a mesh object by:
2.15.6.1 Properties
Read /
Property
Write
Type Description Analysis
Center of
Returns the x value of the
centerofgravityx Read Number Gravity
mesh’s center of gravity
Analysis
Center of
Returns the y value of the
centerofgravityy Read Number Gravity
mesh’s center of gravity
Analysis
Center of
Returns the z value of the
centerofgravityz Read Number Gravity
mesh’s center of gravity
Analysis
Upskin
Returns the total area of all
downskinarea Read Number Downskin
downskin triangles
Analysis
Upskin
Returns the number of
downskincomponentcount Read Number Downskin
downskin components
Analysis
98 / 107
Netfabb Lua Scripting API
Documentation
Reference.docx
Default
edgecount Read Number Returns the number of edges
Analysis
Default
holecount Read Number Returns the number of holes
Analysis
Default
nodecoount Read Number Returns the number of nodes
Analysis
99 / 107
Netfabb Lua Scripting API
Documentation
Reference.docx
Support
Returns the volume of the
supportvolume Read Number Volume
support shells
Analysis
Upskin
Returns the total area of all
upskinarea Read Number Downskin
upskin triangles
Analysis
Upskin
Returns the number of
upskincomponentcount Read Number Downskin
upskin components
Analysis
100 / 107
Netfabb Lua Scripting API
Documentation
Reference.docx
[Desktop Automation]
This object is used for creating meshes. Created by system (list =
system:createprimitivelist)
2.15.7.1 Properties
Property Read / Write Type Description
count read only Number Number of primitives in the list
2.15.8.1 Properties
Property Read / Write Type Description
settingcount read only Number Number of settings of this primitive
Read and write any setting of the primitive by
[generic setting name] Read / write [Number, String] the specific name. The list of available
properties depends on the primitive.
The 3S Lua implementation is accessible as the 3S “script” function and its API
only contain the functions documented in this chapter. No other Netfabb API calls
are available in this implementation. Vice versa, the 3S API functionality is only
available in the 3S module and nowhere else.
2.16.1 LUAStructure
Commands for the Lua Structure class
102 / 107
Netfabb Lua Scripting API
Documentation
Reference.docx
2.16.1.1 Properties
Property Read / Write Type Description
cellcount read only number cell.cellcount
simulateafterexecution read / write boolean structure.simulateafterexecution=true;
surfacedatacount read only number surface.surfacedatacount
volumedatacount read only number volume.volumedatacount
2.16.2.1 Properties
Property Read / Write Type Description
fragmentcount read only number volume.fragment
groupcount read only number volume.groupcount
name read only string volume.name=”volume”;
originx read only number volume.originx
originy read only number volume.originy
originz read only number volume.originz
rastersizex read only number volume.rastersizex
rastersizey read only number volume.rastersizey
rastersizez read only number volume.rastersizez
sizex read only number volume.sizex
sizey read only number volume.sizey
sizez read only number volume.sizez
visible read / write boolean volume.visible=true/false;
103 / 107
Netfabb Lua Scripting API
Documentation
Reference.docx
2.16.3 LUAVolumeDataFragment
Commands for the LUAVolumeDataFragment class
2.16.3.1 Properties
Property Read / Write Type Description
cell read / write object part.cell;
color read / write number 49906=part.color; part.color=49906;
name read / write string “part1”=part.name; part.name=”part1”;
rastercount read only number part.rastercount;
104 / 107
Netfabb Lua Scripting API
Documentation
Reference.docx
part1: LUAVolumeDataFragment =
part2:generatechessboard(blocksizex:Number,
generatechessboard blocksizey:Number, blocksizez:Number, translationx:
Number, translation: Number, translationz:Number)
Ret:Boolean =
movetogroup
volume:movetogroup(group1:LUAVolumeDataGroup);
part1: LUAVolumeDataFragment =
part2:randomize(blocksizex:Number,
blocksizey:Number, blocksizez:Number, translationx:
randomize Number, translation: Number, translationz:Number,
probability:Number)
remove part:remove();
2.16.4 LUAVolumeDataGroup
Commands for the LUAVolumeDataGroup class.
2.16.4.1 Properties
Property Read / Write Type Description
fragmentcount read only number volume.fragmentcount
105 / 107
Netfabb Lua Scripting API
Documentation
Reference.docx
2.16.5 LUASurfaceData
Commands for the LUASurfaceData class.
2.16.5.1 Properties
Property Read / Write Type Description
fragmentcount read only number surface.fragmentcount
groupcount read only number surface.groupcount
name read only string “surface”=surface.name;
visible read / write boolean surface.visible=true/false
2.16.6 LUASurfaceDataFragment
Commands for the LUASurfaceDataFragment class
2.16.6.1 Properties
Property Read / Write Type Description
49906=surface.color;
color read / write number
surface.color=49906;
106 / 107
Netfabb Lua Scripting API
Documentation
Reference.docx
2.16.7 LUASurfaceDataGroup
Commands for the LUASurfaceDataGroup class
2.16.7.1 Properties
Property Read / Write Type Description
fragmentcount read only number surface.fragmentcount
2.16.8 LUABaseCell
Commands for the LUABaseCell class
2.16.8.1 Properties
Property Read / Write Type Description
name read only string “cell”=cell.name;
sizex read only number cell.sizex
sizey read only number cell.sizey
sizez read only number cell.sizez
None.
107 / 107