0% found this document useful (0 votes)
52 views

Netfabb Lua Scripting API Reference-1

Uploaded by

rykennelly1
Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
52 views

Netfabb Lua Scripting API Reference-1

Uploaded by

rykennelly1
Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 107

Netfabb Lua Scripting API

Documentation
Reference.docx

Netfabb Lua Scripting


API Reference

Version: December 2019

Copyright by Autodesk

This document shall not be distributed without the permission of Autodesk

1 / 107
Netfabb Lua Scripting API
Documentation
Reference.docx

Table of Content

1 Lua in Netfabb ................................................................................ 10


1.1 API scopes ....................................................................................... 10
1.1.1 [3S]................................................................................................... 10
1.1.2 [Slice Commander]........................................................................... 10
1.1.3 [Desktop Automation] ....................................................................... 11
1.2 Supported Lua functionality.............................................................. 11
1.3 Lua Scripting in Autodesk Netfabb Ultimate ..................................... 12
1.3.1 Main Lua Automation Module .......................................................... 12
1.3.2 Lua Execution in Slice Commander ................................................. 12

2 Scripting Reference ....................................................................... 13


2.1 General Lua Syntax ......................................................................... 13
2.2 System object .................................................................................. 13
2.2.1 Properties ......................................................................................... 13
2.2.2 'system' Method Overview ............................................................... 14
2.2.2.1 System and file functions ............................................................ 14
2.2.2.2 Mesh Creation and Mesh Loading .............................................. 21
2.2.2.3 XML, Json, CSV, Text Handling and Database connections....... 22
2.2.3 Constants ......................................................................................... 23
2.2.4 Further functionality Methods ........................................................... 23
2.2.4.1 GL Context .................................................................................. 23
2.2.4.2 Testsuite Framework ................................................................... 23
2.2.4.3 Slicing.......................................................................................... 24
2.2.4.3.1 Method overview ......................................................................... 24
2.2.4.3.2 Properties .................................................................................... 24
2.2.4.4 CadImport ................................................................................... 24
2.2.4.5 Fabbproject ................................................................................. 24
2.2.5 3mfExporter ..................................................................................... 25
2.2.5.1 Properties .................................................................................... 25
2.2.5.2 Method Overview ........................................................................ 25
2.2.6 CollisionDetector .............................................................................. 25
2.2.6.1 Properties .................................................................................... 25
2.2.6.2 Method Overview ........................................................................ 25
2.3 Netfabbtrayhandler .......................................................................... 26
2.3.1 Properties ......................................................................................... 26
2.3.2 Method Overview ............................................................................. 26

2 / 107
Netfabb Lua Scripting API
Documentation
Reference.docx

2.4 Application ....................................................................................... 27


2.4.1 Properties ......................................................................................... 27
2.4.2 Method Overview ............................................................................. 27
2.5 Mesh Object (TLUAMesh)................................................................ 28
2.5.1 Properties ......................................................................................... 28
2.5.2 Method Overview ............................................................................. 29
2.5.2.1 Format conversion ...................................................................... 29
2.5.2.2 Mesh Transformation .................................................................. 30
2.5.2.3 Analyse meshes .......................................................................... 32
2.5.2.4 Boolean Operations .................................................................... 34
2.5.2.5 Mesh Repair ................................................................................ 35
2.5.2.6 Mesh Textures ............................................................................ 38
2.5.2.7 Model Package ........................................................................... 38
2.5.2.8 Mesh Support .............................................................................. 39
2.5.3 Relation to "LUAMeshObject" and "LUATrayMesh" ......................... 39
2.6 Fabbproject API ............................................................................... 40
2.6.1 Fabbproject Object ........................................................................... 40
2.6.1.1 Properties .................................................................................... 40
2.6.1.2 Method overview ......................................................................... 40
2.6.2 LUATray ........................................................................................... 41
2.6.2.1 Properties .................................................................................... 41
2.6.2.2 Method overview ......................................................................... 41
2.6.2.3 Constant Members ...................................................................... 42
2.6.3 LUAMeshGroup ............................................................................... 42
2.6.3.1 Properties .................................................................................... 42
2.6.3.2 Method overview ......................................................................... 42
2.6.4 LUATrayMesh .................................................................................. 43
2.6.4.1 Properties .................................................................................... 43
2.6.4.2 Method overview ......................................................................... 43
2.6.5 LUACollisionResult .......................................................................... 45
2.6.5.1 Properties .................................................................................... 45
2.6.5.2 Method overview ......................................................................... 46
2.6.6 LUAPacker ....................................................................................... 46
2.6.6.1 Properties .................................................................................... 46
2.6.6.2 Method overview ......................................................................... 47
2.6.7 LUAPacker – Monte Carlo packer .................................................... 48
2.6.7.1 Properties .................................................................................... 48
2.6.7.2 Method overview ......................................................................... 49
2.6.8 LUAPacker – 3d Scanline packer .................................................... 49
3 / 107
Netfabb Lua Scripting API
Documentation
Reference.docx

2.6.8.1 Properties .................................................................................... 49


2.6.8.2 Method overview ......................................................................... 50
2.6.9 LUAPacker – 2d packer ................................................................... 50
2.6.9.1 Properties .................................................................................... 51
2.6.9.2 Method overview ......................................................................... 51
2.6.10 LUAPacker – outbox packer ............................................................ 52
2.6.10.1 Properties .................................................................................... 52
2.6.10.2 Method overview ......................................................................... 52
2.7 GUI-specific Objects ........................................................................ 52
2.7.1 ControlContainer Base class............................................................ 52
2.7.1.1 Properties .................................................................................... 53
2.7.1.2 Method Overview ........................................................................ 53
2.7.2 Button............................................................................................... 53
2.7.2.1 Properties .................................................................................... 54
2.7.2.2 Method Overview ........................................................................ 54
2.7.3 Picturebutton .................................................................................... 54
2.7.3.1 Properties .................................................................................... 54
2.7.3.2 Method Overview ........................................................................ 54
2.7.4 Checkbox ......................................................................................... 54
2.7.4.1 Properties .................................................................................... 55
2.7.4.2 Method Overview ........................................................................ 55
2.7.5 Groupbox ......................................................................................... 55
2.7.5.1 Properties .................................................................................... 55
2.7.5.2 Method Overview ........................................................................ 55
2.7.6 Dropdown......................................................................................... 55
2.7.6.1 Properties .................................................................................... 56
2.7.6.2 Method Overview ........................................................................ 56
2.7.7 Edit ................................................................................................... 57
2.7.7.1 Properties .................................................................................... 57
2.7.7.2 Method Overview ........................................................................ 57
2.7.8 Label ................................................................................................ 57
2.7.8.1 Properties .................................................................................... 57
2.7.8.2 Method Overview ........................................................................ 58
2.7.9 Scrollbar ........................................................................................... 58
2.7.9.1 Properties .................................................................................... 58
2.7.9.2 Method Overview ........................................................................ 58
2.7.10 Slider ................................................................................................ 58
2.7.10.1 Properties .................................................................................... 59
2.7.10.2 Method Overview ........................................................................ 59
4 / 107
Netfabb Lua Scripting API
Documentation
Reference.docx

2.7.11 Memo ............................................................................................... 59


2.7.11.1 Properties .................................................................................... 59
2.7.11.2 Method Overview ........................................................................ 60
2.7.12 Spacer.............................................................................................. 60
2.7.12.1 Properties .................................................................................... 60
2.7.12.2 Method Overview ........................................................................ 60
2.7.13 Splitter .............................................................................................. 60
2.7.13.1 Properties .................................................................................... 60
2.7.13.2 Method Overview ........................................................................ 60
2.7.14 Dialog ............................................................................................... 61
2.7.14.1 Properties .................................................................................... 61
2.7.14.2 Method Overview ........................................................................ 61
2.7.15 TableObject ...................................................................................... 61
2.7.15.1 Properties .................................................................................... 61
2.7.15.2 Method Overview ........................................................................ 62
2.7.16 TabControl ....................................................................................... 62
2.7.16.1 Properties .................................................................................... 62
2.7.16.2 Method Overview ........................................................................ 62
2.7.17 TabSheet ......................................................................................... 62
2.7.17.1 Properties .................................................................................... 62
2.7.17.2 Method Overview ........................................................................ 63
2.7.18 Image ............................................................................................... 63
2.7.18.1 Properties .................................................................................... 63
2.7.18.2 Method Overview ........................................................................ 63
2.7.19 FloatSpinEdit .................................................................................... 63
2.7.19.1 Properties .................................................................................... 64
2.7.19.2 Method Overview ........................................................................ 64
2.7.20 Histogram Object ............................................................................. 64
2.7.20.1 Properties .................................................................................... 64
2.7.20.2 Method Overview ........................................................................ 65
2.7.21 Graph Object .................................................................................... 65
2.7.21.1 Properties .................................................................................... 65
2.7.21.2 Method Overview ........................................................................ 65
2.8 Slice related Objects ........................................................................ 66
2.8.1 Slice Layer ....................................................................................... 66
2.8.1.1 Properties .................................................................................... 66
2.8.1.2 Method Overview ........................................................................ 67
2.8.2 Slice Image Exporter ........................................................................ 67
2.8.2.1 Properties .................................................................................... 67
5 / 107
Netfabb Lua Scripting API
Documentation
Reference.docx

2.8.2.2 Method Overview ........................................................................ 68


2.8.3 Slice Object ...................................................................................... 68
2.8.3.1 Properties .................................................................................... 68
2.8.3.2 Method Overview ........................................................................ 68
2.9 Document related Object types ........................................................ 73
2.9.1 XML file Object ................................................................................. 73
2.9.1.1 Properties .................................................................................... 73
2.9.1.2 Method Overview ........................................................................ 73
2.9.2 XML node Object ............................................................................. 74
2.9.2.1 Properties .................................................................................... 74
2.9.2.2 Method Overview ........................................................................ 75
2.9.3 Json file Object ................................................................................ 75
2.9.3.1 Properties .................................................................................... 75
2.9.3.2 Method Overview ........................................................................ 75
2.9.4 CSV file Object ................................................................................. 76
2.9.4.1 Properties .................................................................................... 76
2.9.4.2 Method Overview ........................................................................ 76
2.9.5 Text File Object ................................................................................ 77
2.9.5.1 Properties .................................................................................... 77
2.9.5.2 Method Overview ........................................................................ 77
2.10 Database related Objects................................................................. 77
2.10.1 Database Connection Object ........................................................... 77
2.10.1.1 Properties .................................................................................... 77
2.10.1.2 Method Overview ........................................................................ 77
2.10.2 Query Result Object ......................................................................... 78
2.10.2.1 Properties .................................................................................... 78
2.10.2.2 Method Overview ........................................................................ 78
2.11 Image and Display related Objects .................................................. 78
2.11.1 OGLRendering Object...................................................................... 78
2.11.1.1 Properties .................................................................................... 78
2.11.1.2 Method Overview ........................................................................ 78
2.11.2 Image Processing ............................................................................ 81
2.11.2.1 Properties .................................................................................... 81
2.11.2.2 Method Overview ........................................................................ 81
2.11.3 Image Object .................................................................................... 81
2.11.3.1 Properties .................................................................................... 81
2.11.3.2 Method Overview ........................................................................ 81
2.12 CAD Import related Objects ............................................................. 82

6 / 107
Netfabb Lua Scripting API
Documentation
Reference.docx

2.12.1 CadImporter Object .......................................................................... 82


2.12.1.1 Properties .................................................................................... 82
2.12.1.2 Method Overview ........................................................................ 83
2.12.2 CADImportModel Object .................................................................. 83
2.12.2.1 Properties .................................................................................... 83
2.12.2.2 Method Overview ........................................................................ 83
2.13 Utility Data Objects........................................................................... 84
2.13.1 LUAVector3 ...................................................................................... 84
2.13.1.1 Properties .................................................................................... 84
2.13.1.2 Methods ...................................................................................... 84
2.13.2 LUAArray ......................................................................................... 84
2.13.2.1 Properties .................................................................................... 84
2.13.2.2 Methods ...................................................................................... 84
2.13.3 LUAStringMap .................................................................................. 84
2.13.3.1 Properties .................................................................................... 85
2.13.3.2 Methods ...................................................................................... 85
2.13.4 LUAMatrix4f ..................................................................................... 85
2.13.4.1 Properties .................................................................................... 85
2.13.4.2 Methods ...................................................................................... 85
2.13.5 LUAAlignment .................................................................................. 85
2.13.5.1 Properties .................................................................................... 85
2.13.5.2 Methods ...................................................................................... 86
2.13.6 Outbox Object .................................................................................. 86
2.13.6.1 Properties .................................................................................... 86
2.13.6.2 Method Overview ........................................................................ 86
2.14 Webservices related Objects ........................................................... 86
2.14.1 Netfabb Taskserver Object .............................................................. 86
2.14.1.1 Properties .................................................................................... 86
2.14.1.2 Method Overview ........................................................................ 86
2.14.2 Netfabb Task Object ........................................................................ 87
2.14.2.1 Properties .................................................................................... 87
2.14.2.2 Method Overview ........................................................................ 87
2.14.3 Hublist Object ................................................................................... 88
2.14.3.1 Properties .................................................................................... 88
2.14.3.2 Method Overview ........................................................................ 88
2.14.4 Hub Object ....................................................................................... 88
2.14.4.1 Properties .................................................................................... 89
2.14.4.2 Method Overview ........................................................................ 89
2.14.5 Projectlist Object .............................................................................. 89
7 / 107
Netfabb Lua Scripting API
Documentation
Reference.docx

2.14.5.1 Properties .................................................................................... 89


2.14.5.2 Method Overview ........................................................................ 89
2.14.6 Project Object .................................................................................. 89
2.14.6.1 Properties .................................................................................... 89
2.14.6.2 Method Overview ........................................................................ 90
2.14.7 Folderlist Object ............................................................................... 90
2.14.7.1 Properties .................................................................................... 90
2.14.7.2 Method Overview ........................................................................ 90
2.14.8 Folder Object ................................................................................... 90
2.14.8.1 Properties .................................................................................... 90
2.14.8.2 Method Overview ........................................................................ 91
2.14.9 Itemlist Object .................................................................................. 91
2.14.9.1 Properties .................................................................................... 91
2.14.9.2 Method Overview ........................................................................ 91
2.14.10 Item Object .................................................................................. 91
2.14.10.1Properties .................................................................................... 91
2.14.10.2Method Overview ........................................................................ 92
2.15 Miscellaneous Objects ..................................................................... 92
2.15.1 LUAStamper .................................................................................... 92
2.15.1.1 Properties .................................................................................... 92
2.15.1.2 Methods ...................................................................................... 92
2.15.2 LUAReportgenerator ........................................................................ 93
2.15.2.1 Properties .................................................................................... 93
2.15.2.2 Methods ...................................................................................... 93
2.15.3 Test framework interface.................................................................. 93
2.15.3.1 Properties .................................................................................... 93
2.15.3.2 Method overview ......................................................................... 94
2.15.4 ZipObject .......................................................................................... 95
2.15.4.1 Properties .................................................................................... 95
2.15.4.2 Method Overview ........................................................................ 95
2.15.5 PartOrienter ..................................................................................... 96
2.15.5.1 Properties .................................................................................... 96
2.15.5.2 Method Overview ........................................................................ 97
2.15.6 PartAnalysis ..................................................................................... 98
2.15.6.1 Properties .................................................................................... 98
2.15.6.2 Method Overview ...................................................................... 100
2.15.7 Primitive List ................................................................................... 101
2.15.7.1 Properties .................................................................................. 101
2.15.7.2 Method Overview ...................................................................... 101
8 / 107
Netfabb Lua Scripting API
Documentation
Reference.docx

2.15.8 Primitive Object .............................................................................. 102


2.15.8.1 Properties .................................................................................. 102
2.15.8.2 Method Overview ...................................................................... 102
2.16 3S Script Objects ........................................................................... 102
2.16.1 LUAStructure ................................................................................. 102
2.16.1.1 Properties .................................................................................. 103
2.16.1.2 Method Overview ...................................................................... 103
2.16.2 LUAVolume Data ........................................................................... 103
2.16.2.1 Properties .................................................................................. 103
2.16.2.2 Method Overview ...................................................................... 104
2.16.3 LUAVolumeDataFragment ............................................................. 104
2.16.3.1 Properties .................................................................................. 104
2.16.3.2 Method Overview ...................................................................... 104
2.16.4 LUAVolumeDataGroup .................................................................. 105
2.16.4.1 Properties .................................................................................. 105
2.16.4.2 Method Overview ...................................................................... 105
2.16.5 LUASurfaceData ............................................................................ 106
2.16.5.1 Properties .................................................................................. 106
2.16.5.2 Method Overview ...................................................................... 106
2.16.6 LUASurfaceDataFragment ............................................................. 106
2.16.6.1 Properties .................................................................................. 106
2.16.6.2 Method Overview ...................................................................... 106
2.16.7 LUASurfaceDataGroup .................................................................. 107
2.16.7.1 Properties .................................................................................. 107
2.16.7.2 Method Overview ...................................................................... 107
2.16.8 LUABaseCell .................................................................................. 107
2.16.8.1 Properties .................................................................................. 107
2.16.8.2 Method Overview ...................................................................... 107

9 / 107
Netfabb Lua Scripting API
Documentation
Reference.docx

1 Lua in Netfabb

Lua is Netfabb's method of choice to facilitate automation tasks inside the


software. Lua is currently available inside Netfabb’s range of software products:

- As scripting language for Autodesk Netfabb Ultimate


o As “Desktop Automation” module
o Specific to the Slice Commander
o Specific to the 3S module

1.1 API scopes

In the later API reference part, the different scope of the API calls will be
indicated by these tags:

[Desktop Automation]
and

[3S] [Slice Commander]

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.

1.1.2 [Slice Commander]

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

1.1.3 [Desktop Automation]


This framework is accessible in Netfabb Ultimate via the ‘Lua Script Library’ under
Prepare->Run LUA Script. It targets people, who want to automate repeatable
jobs inside Netfabb. The API also allows functionality extending the out-of-the-
box features of Netfabb by more custom workflows. One can also start Netfabb
Ultimate with a commandline parameter( “/startluascript=<Scriptfile>”), which al-
lows to execute the given lua script after the start of netfabb.

1.2 Supported Lua functionality


Netfabb supports generally the version 5.1 of the Lua language definition, see:
http://www.lua.org/manual/5.1/

From the Lua 5.1 standard Netfabb supports the core language specification
and some but not all the libraries.

Lua Library Supported Comment


Some exeptions:
Yes, with • dofile:no – use
Base
exceptions system:executescriptfile()
• print: no: use system:log()
Coroutine Manipulation Yes
Modules No Use system:executescriptfile()
String manipulation Yes
Table manipulation Yes
Mathematical Functions Yes
Input and output
No
Facilities
Operating System
No
Facilities
[Desktop Automation] provides a debugger
The Debug library No
GUI.

11 / 107
Netfabb Lua Scripting API
Documentation
Reference.docx

1.3 Lua Scripting in Autodesk Netfabb Ultimate


One can access the scripting cababilities of Autodesk Netfabb only in the Ultimate
Edition. One can execute general Lua scripts in the main Lua Automation Module
in the default module Autodesk Netfabb ([Desktop Automation]) and special
scripts working on slices in the [Slice Commander] of Autodesk Netfabb. In addi-
tion, the [3S] Module can also execute Lua scripts. However, we refer to the Man-
ual for a description of that feature.

1.3.1 Main Lua Automation Module


[Desktop Automation]

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.

1.3.2 Lua Execution in Slice Commander

[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.1 General Lua Syntax


The Lua Scripting Language is a compact bytecode programming language,
capable of most common language constructions. While including a variety of
functionally for example for mathematical calculations or string manipulations,
its automatic conversion of data-types guarantees a shallow learning curve and
quick results. Therefore, it is also widely used in a lot of applications (e.g.
Apache HTTP Server, Adobe Photoshop, Video Lan Client) and especially in
commercial games (e.g. Baldur’s Gate, World of Warcraft, Crysis). A detailed
reference and a general introduction can be found on the Lua website
(http://www.lua.org). A very comprehensive and recommended book is
”Programming in Lua”, which is also available on the Web
(http://www.lua.org). There is also a vivid community, which provides a large
source for information and examples.
Netfabb’s functions are included by Lua’s basic object interface. While not
delivering many sophisticated techniques like creating inheritances of classes,
there is enough functionality to create a good interface for three-dimensional
mesh handling. As a rule, all occurring properties of object instances can be
used like generic variables in the code. A simple access by ”object.property” is
sufficient. Object methods are handled somehow uncommon, since they are
characterized by a colon, so the general syntax is always like
result = object:method (param1, param2, param3); - - generic method call

2.2 System object


The central connection between Netfabb and the executed Lua script is the
system object. As a global variable, it is accessible from anywhere in the script
and is the starting point for the creation of all other objects - like meshes, xml
files or database connections.

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

2.2.2 'system' Method Overview

2.2.2.1 System and file functions

[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

ADetector = Create a Lua collision detector


createcollisiondetector system:createcollisiondetector(gridsize: object. See CollisionDetector
Number); for details
createdirectory Result = system:createdirectory(dirname:string); Creates a directory
createformatteduuid UUID = system:createuuid(); Returns a UUID, formatted
Creates a Graph object.
Graphs is the number of
creategraph Graph = system:creategraph(graphs:integer)
individual graphs to be
painted.
Creates a Histogram object.
createhistogram Histogram = system:createhistogram()
See histogram section.
Create a list-object that
contains all available
createprimitivelist List = system:createprimitivelist()
primitives. See primitive
section.
Creates a hex baseplate
mesh with a given number of
ABaseplateMesh = system: holes in X- and Y-Direction
createhexbaseplate(AHoleCountX: Number, and with a Hole Radius. The
createhexbaseplate
AHoleCountY: Number, ARadius: Number; Height Parameter defines how
AHeight: Number; AWallThickness: Number); high the baseplate should be,
the last parameter defines the
used wall thickness
Creates an image processing
createimageprocessing Ip = system:createimageprocessing();
object.
Create a baseplate with
ABaseplateMesh = system: rectangles. The first two
createrectbaseplate(AHoleCountX: Number, parameters define the number
createrectbaseplate AHoleCountY: Number; ACellSizeX: Number; of holes, the next two the size
ACellSizeY: Number; AHeight: Number; of the holes and the last two
AWallThickness: Number); the height of the baseplate
and the wall thickness
Creates a
LUAReportgenerator, function
Result = system:createreportgenerator(Snapshot call needs to have a
createreportgenerator
: LUAsnapshotcreator); snapshotcreator as an
argument
[Desktop Automation]

15 / 107
Netfabb Lua Scripting API
Documentation
Reference.docx

Create a screenshot of the


current camera position and
returns an Image Object. The
“AOptions” object can contain
the following keys with “true” /
“false” values:

- 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

With these values you can


control the Netfabb UI ele-
ments to be visible or invisible
in the generated image
[Desktop Automation]
Creates a
LUASnapshotcreator. This is
createsnapshotcreator Result = system:createsnapshotcreator(); used by other objects to
create a snapshot.
[Desktop Automation]
Create a LUAStamper, which
createstamper Result = system:createstamper(); allows to label meshes
[Desktop Automation]
Create a string map for key /
createstringmap Map = system:createstringmap()
value pairs
createuuid UUID = system:createuuid(); Returns a UUID
Creates a new zipfile object. If
used without zifile parameter,
createzip zipobject = system:createzip(zipfile: string)
it creates the object in
memory only. See Zipobject.
boolean = Returns TRUE, when
directoryexists
system:directoryexists(dirname:string); directory exists
Tries to download a file via HTTP
Result:boolean = System:downloadurl(URL: GET from ‘URL’ and saves it as
downloadurl ‘name’. Returns TRUE if
string, name: string);
successful.
Returns string excluding the
String =
excludepathdelimiter system-specific path delimiter
system:excludepathdelimiter(inputstring:string);
(at the end)

16 / 107
Netfabb Lua Scripting API
Documentation
Reference.docx

Starts ‘app’ application and


waits until application ends
(blocking). ‘options’ are
separated by blank. The
system:executeapplication(app:string
executeapplication optional “wait” parameter
[;options:string; wait: boolean]);
defined whether or not
Netfabb will wait (true, default)
for the external application to
finish execution
Execute a string as a lua
script. The scriptname is the
system:executescript(script: string, scriptname : name of the script, which
executescript
string ); should be associated with the
script (needed for the lua
debugger)
Executes another Lua Script.
executescriptfile system:executescriptfile(scriptname:string); Scriptname is the name of the
lua script on the filesystem.
Filenameext = Returns the file name
extractfileext
system:extractfilenameext(inputstring:string); extension from a string
Filename = Returns the filename only
extractfilename
system:extractfilename(inputstring:string); from a string
Returns a string with the file
String = system:extractfilepath(inputstring; path. If trailingpathdelimiter is
extractfilepath
trailingpathdelimiter: bool) true the trailing path delimiter
are included, otherwise not
Returns TRUE, when file
fileexists boolean = system:fileexists(filename:string);
exists
Returns ‘numval’, formatted
Result:string =
with number of ’digits’ and
formatarea system:formatarea(numval:number
trailing currently set area unit
[,digits:integer]);
[Desktop Automation]
Returns ‘numval’, formatted
Result:string = with number of ’digits’ and
formatlength system:formatlength(numval:number trailing currently set length
[,digits:integer]); unit
[Desktop Automation]
Returns ‘numval’ as formatted
Result:string = byte string, e.g.: 3.4 kB
formattraffic
system:formatraffic(numval:number); [Desktop Automation]
Returns ‘numval’, formatted
Result:string = with number of ’digits’ and
formatvolume system:formatarea(numval:number trailing currently set volume
[,digits:integer]); unit
[Desktop Automation]
Returns a xml file with all files
xmlfilelist = system:getallfilesindirectory
getallfilesindirectory in a directory [Desktop
(dirname:string);
Automation]
Returns current date as a
getdatestring date = system:getdatestring();
string
getfilesize Size = system:getfilesize(filename:string); Returns the size of a file
Returns current time as a
gettimestring time = system:gettimestring();
string

17 / 107
Netfabb Lua Scripting API
Documentation
Reference.docx

Hides the progress dialog


created by
hideprogressdlg System: hideprogressdlg();
system:showprogressdlg
[Desktop Automation]
Returns string with system-
String =
includepathdelimiter specific path delimiter (at the
system:includepathdelimiter(inputstring:string);
end)
Creates a generic dialog for
input of one (text) field as well
as an OK and a Cancel
button. OK returns whatever is
system:inputdlg(Title:string,Label:string,Defaultv currently written in the field
inputdlg
alue:string); (including the default value),
Cancel always returns the
default value. All fields are
mandatory but can be empty.
[Desktop Automation]
Logs logstring to current log
log system:log(logsting:string); output channel. See also:
setloggingtooglwindow
Log Standard Output to file. If
system:logtofile(filename:string; timestamp: timestamp is false to time
logtofile
Boolean = true); information is printed. The
default value is true.
Show a message dialog
messagedlg system:messagedlg(message: String);
[Desktop Automation]
Open a URL in the default
openurl system:openurl(url: string) browser
[Desktop Automation]
Open an existing ZIP file for
reading. Returns an instance
of ZipObject. The password
openzip system:openzip(file: String; password: String) parmeter is optional and is
used to decrypt password
protected archives.
[Desktop Automation]
Creates a dialog for inputting
system:passworddlg(Label:string,password:strin
passworddlg a password, hiding the input
g);
[Desktop Automation]
Register a new extension to
Netfabb. Extension is the
extension without the . (“stl”).
system:registerextension(Extension: String,
LocalizationId is the translated
registerextension LocalizationId: String, Filter: String,
string describing the filter
DescriptionLocalizationId: String)
(“STL File”). Filter is the filter
to actually apply (“*.stl”)
[Desktop Automation]
Checks and returns a string
Result = for standard alphanumeric
safealphanumeric system:safealphanumeric(inputstring:string;withp signs. Boolean flag = TRUE
unctuationsigns:18oolean); allows also punctuation signs
(‘.’,’,’,-‘)
Available for the Lua
Automation module. Allows
setloggingtooglwindow system:setloggingtooglwindow(value); that all output is piped to the
OGL warning window. Value
is a boolean

18 / 107
Netfabb Lua Scripting API
Documentation
Reference.docx

Set the progress dialog with a


progress value and a
message. The third parameter
system:setprogress(Percent, Message,
setprogress (optional) selects whether or
[translate]);
not the message should be
translated (true = default)
[Desktop Automation]
Executes a shell command
“cmd” with the shell
parameters “param”
doWait: if TRUE, waits until
the command has finished
Show: set to “true” if you want
system:shellexecute(cmd:string, param:string,
the launched application to be
shellexecute doWait:19oolean, Show:19oolean,
shown. “False” is default
directory:string)
directory: change to this
directory for command
execution
Example/note for windows:
system:shellexecute(“cmd”,
“/c copy cube.stl test.stl”,1, 1);
Opens a directory selection
dialog. Parameters:
bAllowcreate: An edit box
allows the user to type in the
name of a directory that does
not exist. This option does not
create a directory: the
application must read the
name of the selected directory
and create it if desired.
bPerformCreate: Used only
in combination with
bAllowCreate. If the user
enters a directory name that
does not exist, the directory
selection dialog creates it.
Directorystring = system: bPrompt: Used only in
showdirectoryselectdial
showdirectoryselectdialog(bAllowcreate:19oolea combination with
og
n, bPerformCreate:19oolean, bPrompt:19oolean) bAllowCreate. Displays a
message box that informs the
user when the entered
directory does not exist and
asks if the directory should be
created. If the user chooses
OK, the directory is created if
the option set includes
bPerformCreate. If the option
set does not include
bPerformCreate, the directory
is not created: the application
must read the directory name
and create it.
Returns string with directory
name or empty, if nothing
selected
[Desktop Automation]

19 / 107
Netfabb Lua Scripting API
Documentation
Reference.docx

Shows a file open dialog. Only


one extension kann be
passed. If the extension is
unknown to Netfabb it can be
Filename = system:showopendialog(Aextension: registered using
showopendialog
String) “system:registerextension”. If
a file was selected its name is
returned, otherwise an empty
string is returned.
[Desktop Automation]
system:showprogressdlg(defaultcallback: Shows the progress dialog
showprogressdlg
Boolean); [Desktop Automation]
Open file save dialog with
parameter for the file
extension, returns filename.
The second, optional
filename_to_save =
showsavedialog parameter defines the
system:showsavedialog(ext:string, [ext2: string]);
possible extensions for the
save file, the first the default
ending.
[Desktop Automation]
Open file save dialog with
parameter for the file
extension, returns filename.
The 2nd parameter defines the
filename_to_save =
possible extensions of the
showsavedialogex system:showsavedialogex(ext:string, ext2: string,
filename, the 1st the
[name: string]);
default.The third, optional
parameter suggests a
filename for the save.
[Desktop Automation]
Slices a mesh with the given
system:slicemesh(mesh, layersize, fromZ, toZ,
slicemesh parameters. Function returns
createInMemory:20oolean);
a LUASlice Object
Registers “name” as global
system:tonumber_save(value:string, variable and stores “value” as
tonumber_safe
name:string); float in it.
[Desktop Automation]
Displays a “Yes/No” dialog
with “message” as text. The
optional “withCancel option
determines, whether also a
Result = system:yesnodlg(message: String, “Cancel” option should be
yesnodlg
[withCancel: 20oolean]); shown.
Result: 1 for Yes, 0 for No, -1
for other.
[Desktop Automation]

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

String: with the file name, or


showsavedialog local filename = system:showsavedialog (“wrl”);
empty string
shotJson=”{“show_verticalruler”:true,
“show_labels”:true, “show_colors”:true,
“show_viewcube”:true, “show_platform”:true,
“show_coordsystem”:true,
createscreenshot “show_horizontalruler”:true, Image object
“show_textures”:true, “camera”:{“zoom”:1,
“eye”:[0,1,0], “center”:[0,0,0], “up”:[0,0,1]}}”
local shot=system:createscreenshot(400, 300,
shotJson)
local userinput = system:inputdlg("Rename the
inputdlg string
part","New name:","");

2.2.2.2 Mesh Creation and Mesh Loading


[Desktop Automation]
Name Syntax Description
Creates a mesh from a JPG,
PNG or BMP heightmapfile
Mesh = in the defined dimension.
system:createheightmapmesh(filename:string; The mingray defines the
createheightmapmesh
width:integer, height:integer; depth:integer; minimal grey value between
invert:boolean; mingray:integer); 0 and 255. Invert defines,
whether the image should
be inverted
Creates a mesh from a JPG,
PNG or BMP file in the
Mesh = system:createimagemesh(filename:string;
defined dimension. The
createimagemesh width:integer, height:integer; depth:integer;
threshold is the defined grey
treshhold:integer);
value for separation
between 0 and 255.

Creates a mesh from a


Mesh=system:createtextmesh(text : string, string. The x,y,z size is
createtextmesh width:integer, height:integer; depth:integer) given by width, height and
depth.

Creates a mesh with no


createmesh system:createmesh();
triangles
load3ds system:load3ds(filename:string); Loads an 3DS file
load3mf system:load3mf(filename:string); Loads an 3MF file
loadamf system:loadamf(filename:string); Loads an AMF file
loadgts system:loadgts(filename:string); Loads an GTS file
loadncm system:loadncm(filename:string); Loads an NCM file
loadobj system:loadobj(filename:string); Loads an OBJ file
loadply system:loadply(filename:string); Loads an PLY file
loadstl system:loadstl(filename:string); Loads an STL file
loadvoxel system:loadvoxel(filename:string); Loads an SVX file
loadvrml system:loadvrml(filename:string); Loads an VRML file
loadx3d system:loadx3d(filename:string); Loads an X3D file
loadzpr system:loadzpr(filename:string); Loads an ZPR file

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

2.2.2.3 XML, Json, CSV, Text Handling and Database connections


[Desktop Automation]
Name Syntax Description
DBConnection = Connects to an ODBC
connecttoodbc system:connecttoodbc(connectionstring (DSN), datasource
login, password : all strings); [Desktop Automation]
Creates a CSVObject, if flag is
CSVObject =
createcsv TRUE, a subsequent write will
system:createcsv(clearexisting:boolean)
overwrite any existing file.
createjson Jsonfile = system:createjson(); Creates an empty Json file
createtextfile textfile = system:createtextfile(); Creates an empty text file
createxml Xmlfile = system:createxml(); Creates an empty XML file
loadjson Jsonfile = system:loadjson(filename:String); Loads a Json file from a file
loadjsonfromurl Jsonfile = system:loadjsonfromurl(URL:String); Loads a Json file from a URL
loadtextfile textfile = system:loadtextfile(filename:string); Loads a text file from disk

22 / 107
Netfabb Lua Scripting API
Documentation
Reference.docx

Loads an XML file from disk. If


Xmlfile = system:loadxml(filename:string; AUseAttributesAsChildren is true,
loadxml
AUseAttributesAsChildren: Boolean); attributes are used as children.
The default value is true.
loadxmlfromstring Loads an XML file from an String
loadxmlfromurl Xmlfile = system:loadxml(URL:string); Loads an XML file from an URL

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

The Netfabb LUA system object contains some constants:


Name Type Description
stCLI Number Constant for the “sliceobject:savetofile” type parameter for CLI slice files
stCLS Number Constant for the “sliceobject:savetofile” type parameter for CLS slice files
stSLC Number Constant for the “sliceobject:savetofile” type parameter for SLC slice files
stSLI Number Constant for the “sliceobject:savetofile” type parameter for SLI slice files
stUSF Number Constant for the “sliceobject:savetofile” type parameter for USF slice files

2.2.4 Further functionality Methods

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

2.2.4.2 Testsuite Framework


[Desktop Automation]
Name Syntax Description
subsuite = system:createtestsuite(suitename: Creates a new testsuite with
createtestsuite
string) specified name.

23 / 107
Netfabb Lua Scripting API
Documentation
Reference.docx

2.2.4.3 Slicing

2.2.4.3.1 Method overview


[Desktop Automation]
Name Syntax Description
Adds a slice to the current
addslicetotree system: addslicetotree(slice:SliceObject); stack
Returns an empty slicelayer
createemptylayer SliceLayer = system:createemptylayer();
object
SliceExporter = system: Creates a SliceExporter
createsliceexporter
createsliceexporter(type:String) object. Type must be: “cls”.
Creates a new empty
createslicelist SliceListObject = system: createslicelist();
SliceListOject
Takes a variable list of either
Slice = system:creategroupedslice( Slice or SliceList Objects and
creategroupedslice
SliceObject|SliceListObject, …); returns a combined Slice
object
SliceBuilder = system:
createslicebuilder createslicebuilder(layercount:Integer, Creates a Slicebuilder Object
Layersize:Number, MinZ: Number);
Creates an intersection of
Slice = system:createsliceintersection
createsliceintersection Slice or SliceList objects and
(SliceObject|SliceListObject, …);
returns a slice object
Intersects Slice or SliceList
Slice = system: intersectslices
intersectslices objects and returns a single
(SliceObject|SliceListObject, …);
object
Loads a slice from file. Types
are the following:
0 = USF
Slice = system:loadslice(filename:string; 1 = CLI
loadslice
type: integer) 2 = SLI
3 = CLS
4 = SLC
Unifies Slice or SliceList
Slice = system:unifyslices
unifyslices objects and returns a slice
(SliceObject|SliceListObject, …);
object

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

Name Syntax Description


fabbproject = system:loadfabbproject(filename:
loadfabbproject() Open Fabbproject
String);
Create new and empty
newfabbproject() Newfabbproject = system:newfabbproject()
Fabbproject

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.5.2 Method Overview


Name Syntax Description
Exporter:addattachment(Name: String; Sets the attachment of the
addattachment
Content: String; Namespace: String) 3mf to be exported
exporttofile Exporter:exporttofile(Name: String) Exports the content to a file
Exporter:setscenethumbnail(Thumbnail: Sets an Image Object as
setscenethumbnail
Object) thumbnail for the 3mf

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.

2.2.6.2 Method Overview


Name Syntax Description
CollisionDetector:checkmeshcollision(Mesh1: Checks the collision between
checkmeshcollision
Object; Mesh2: Object) 2 LUATrayMesh objects,

25 / 107
Netfabb Lua Scripting API
Documentation
Reference.docx

returns “0” if now collision


was found, a value bigger
than 0 otherwise

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

2.3.2 Method Overview

Name Syntax Description


Adds a new tray to the
netfabbtrayhandler:addtray(name: String, netfabbapplication. “Name”
machinesize_x: Number, is the name of the tray,
addtray machinesize_x, _y, and _z
machinesize_y: Number,
machinesize_z: Number) are the sizes of the tray.

Retrieve a tray from a


gettray netfabbtrayhandler:gettray(index: Integer)
netfabbapplication
Removes the tray with the
corresponding index.
Workspace trays, and the
main tray cannot be
removed. Also the tray
needs to be empty. Function
Netfabbtrayhandler:removetray(index: returns 0, if the tray was
removetray
Integer) successfully removed.
Otherwise 1 (index not
valid), 2 (main tray was tried
to be removed), 3
(workspace tray was tried to
be removed, 4 (tray was not
empty), 5 (internal error).

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

2.4.2 Method Overview

Name Syntax Description


createdialog dialog = application:createdialog(); Create a DialogObject.
Creates a Netfabb taskhandler
taskhandler =
object. URL is e.g.:
system:createtaskhandler (URL: String,
createtaskhandler http://localhost:8651/tasks/”, name
name:String, userid:String, serverkey:
is the worker displayname, userid
String)
to be used and the server key
Result = application:
Returns a environment variable as
getenvironmentvariable getenvironmentvariable(Variable :
a string
string)
Returns a lua script as a string
Result =
from the lua library. The name
getluascriptfromlibrary application:getluascriptfromlibrary(scrip
must match the name in the lua
tname: string);
library.
Gets current time in seconds since
gettimestamp application:gettimestamp();
1.1.1970.
Loads the list of available hubs for
the current (logged-in) user from
the Netfabb Application Server.
URL is the server connect string,
Hublist = application: default: 'http://127.0.0.1:8650/',
loadappserverhublist loadappserverhublist(URL:String, respective the setting:
key:String);

Key ist the option passphrase,


default is empty

27 / 107
Netfabb Lua Scripting API
Documentation
Reference.docx

Loads a project from a local server


Result:boolean =
into the application. This removes
application:loadappserverproject(URL:
any previously loaded project.
loadappserverproject String, projectid:String, folderid:String,
Userid and passphrase are
itemid:String, [userid:String,
optional parameters. Returns true
passphrase:String]);
is successful.
Loads the list of available hubs for
loadforgehublist Hublist = application:loadforgehublist() the current (logged-in) user from
Autodesk Forge.
Return:Boolean = application:
Saves the current application
overwriteexistingappserverproject(Url:
overwriteexistingappserverpr project on local server, overwrites
String, projectid:String,folderid:string,
oject an exsiting project. Returns true if
itemname:string, [userid:string,
successful.
passphrase:string]);
Result:boolean Saves the current project in the
application:savenewappserverproject(U application onto a local server.
savenewappserverproject rl: String, projectid:String,folderid:string, Returns true if successful.
itemname:string, [userid:string, Itemname is the name, the project
passphrase:string]); should have.
Saves the current project in the
Return:boolean =
savecurrentproject application, returns true when
Application:savecurrentproject();
done.
Saves the current state of netfabb
Result:Boolean = application:
savefabbproject as fabbproject. The filename gives
savefabbproject (AFilename : string)
the saved name of the file.
Triggers a event. The event
application: triggerdesktopevent
triggerdesktopevent ‘updateparts’ triggers an update of
(‘updateparts’);
the displayed meshes in netfabb

2.5 Mesh Object (TLUAMesh)


[Desktop Automation]
A mesh object contains the full information about a triangulated mesh, and may
be used for altering, transforming and exporting the mesh data.

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

Returns the number of


facecount read only Number
triangles
Get the number of flipped
flippedtriangles read Number
triangles of the mesh
holecount read only Number Returns the number of holes
True, if the mesh has a closed
ismanifold read only Boolean
surface
Calculates if the mesh is
isnice read only Boolean
manifold (Deprecated)
True, if the mesh is a)
isok read only Boolean 'ismanifold', b) 'isoriented' and
c) has a positive volume
True, if flipped triangles can be
isorientable read only Boolean
repaired
True, if the mesh has no
isoriented read only Boolean
flipped triangles
Returns, whether a load has
loadingfailed read only Boolean
failed
loadingerror read only String Returns the loading error
Returns the number of
nodecount read only Number
nodes/points
Returns the mesh outbox
outboxvolume read only Number
volume (in mm^3)
Returns the mesh outbox base
outboxbasearea read only Number area
(in mm^2)
Returns the mesh outbox
outboxheight read only Number
height (in mm)
Get the shadow area of the
shadowarea read Number
mesh
shellcount read only Number Returns the number of shells
volume read only Number Returns the volume (in mm^3)

2.5.2 Method Overview

2.5.2.1 Format conversion


Name Syntax Description
saveto3ds mesh:saveto3ds(filename:string); Saves the mesh as a 3DS file
saveto3mf mesh:saveto3mf(filename:string); Saves the mesh as a 3MF file
Saves the mesh as a AMF
savetoamf mesh:savetoamf(filename:string;binary:boolean);
file
Saves the mesh as a ASCII
savetoasciistl mesh:savetoasciistl(filname:string, name:string);
STL file
Saves the mesh as a GTS
savetogts mesh:savetogts(filename:string);
file
Saves the mesh as a NCM
savetoncm mesh:savetoncm(filename:string);
file

29 / 107
Netfabb Lua Scripting API
Documentation
Reference.docx

savetoobj mesh:savetoobj(filename:string); Saves the mesh as a OBJ file


savetoply mesh:savetoply(filename:string); Saves the mesh as a PLY file
Saves the mesh as a binary
savetostl mesh:savetostl(filename:string);
STL file
Saves the mesh as a Voxel
savetovoxel mesh:savetovoxel(filename:string);
file
mesh:savetovrml(filename:string;fixlengtheachrow:boolean; Saves the mesh as a VRML
savetovrml
endmarkeachrow:boolean); file
savetox3d mesh:savetox3d(filename:string, binary:boolean); Saves the mesh as a X3D file
savetozpr mesh:saveto3ds(filename:string); Saves the mesh as a ZPR file
Extract a shell as new mesh
object. Same as
“LUATrayMesh.shellasmesh”
shellasmesh Newmesh = mesh:shellasmesh(shellnumber: Number) but without the matrix of a
traymesh. See
“LUAMeshObject.shellcount”
for the number of meshes

All routines return TRUE if successful.

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

2.5.2.2 Mesh Transformation


Name Syntax Description
Mesh:addtriangle(P1_X, P1_Y, P1_Z, P2_X,
addtriangle Adds a triangle to a mesh
P2_Y, P2_Z, P3_X, P3_Y, P3_Z: all number);
Applies a 4 times 4
transformation matrix to a
applymatrix mesh:applymatrix(matrix : LUAMatrix4f);
mesh. The matrix is passed as
LUAMatrix4f object.
Calculates the outbox of a
calcoutbox Outbox = mesh:calcoutbox();
mesh, return Outbox object.
Creates and returns new
create_partorienter orienter = mesh:create_partorienter() orienter object for this mesh,
see PartOrienter
dupe Newmesh = mesh:dupe(); Creates a copy of the mesh
Inverts the orientation of all
invert mesh:invert();
triangles

30 / 107
Netfabb Lua Scripting API
Documentation
Reference.docx

Adds another mesh into the


merge mesh:merge(anothermesh:string);
mesh
Translates the mesh by a given
move mesh:move(x:number, y: number, z: number);
vector
Translates the mesh to the
movetoorigin mesh:movetoorigin();
origin

Rotates the mesh to minimize


the volume or the height and
the base area of the mesh
outbox.
Permitted values of the
parameter
mode are
Volume – the volume of the
outbox is minimized;
minimizeoutbox Mesh:minimizeoutbox(mode : string); VolumeFlat - the volume of the
outbox is minimized and the
mesh is oriented in such a way
that the shortest edges of the
outbox are parallel to the axis z.
HeightBase – the height of the
outbox is minimized then the
outbox base area is minimized
at the constant outbox height
(i.e. by a rotation around the
axis z).

Releases the memory of a


release mesh:release(); mesh. It cannot be accessed
after this method
Rotates the mesh by a given
mesh:rotate(x: number, y: number, z: number,
rotate angle [degree] around a given
angle: number);
axis
Scales the mesh by a given
scale mesh:scale(x: number, y: number, z:number); factor. Center is the point of
origin
Applies Z-Compensation to
zcompensation Mesh:zcompensation(value : integer);
Mesh, Value in mm.

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

Mesh object: returns a copy of


dupe mesh:dupe(); the mesh. Attention: may use a
lot of memory
merge mesh:merge(mesh_of_inner_shell); -

2.5.2.3 Analyse meshes


Name Syntax Description
Returns the
calculatehausdorffdistanceto mesh:calculatehausdorffdistanceto(mesh2:string);
Hausdorffdistance
Returns TRUE if the mesh
checksanity mesh:checksanity(mesh2:string);
is sane
Checks if the mesh is
different to mesh2. This is
done in two steps: if the
haussdorffdistance is
mesh:comparewith(mesh2:string,
larger than the given
comparewith hausdorffdistancethreshold:number,
hausdorffdistancethreshold
distancethreshold:number, fraction:number in %);
the tests fail or a given
fraction of the measured
distances is larger the
distancethreshold
Creates a new
partanalysis object which
TLUAPartAnalysis analysis = mesh:
createanalyzer allows to run different
createanalyzer ()
analyses and stores their
results
Creates a new alignment
object which stores the
principal axes and the
resulting matrix. See 4.28
for a detailed property list
TLUAAlignment alignment = mesh2: the mesh that can
createalignment mesh:createalignment(mesh2:meshobject, matrix1, be transformed with the
matrix2: luamatrix) resulting matrix to overlap
the given mesh.
Matrix1, matrix2: optional
parameters, used as
modeltoword matrices
when set
Checks the wallthickness
of a mesh, as above, but
stops after fail condition is
Boolean result =
recognized. If colormesh is
fastwallthicknesstest mesh:fastwallthicknesstest(criticaldistance:number,
true, the results of the
criticalsurface:number in %;colormesh: boolean);
wallthickness will be
written into the color
information of the mesh.
Returns the value of the
inner buildvolume in mm³.
The parameter offset gives
getbuildvolume mesh:getBuildVolume(offset:number)
the thickness of the
surface. If the calculation
fails, -1 is returned.
Returns the center of
getcenterofgravity Center = mesh:getcenterofgravity(); gravity of the mesh as
LUAVector3

32 / 107
Netfabb Lua Scripting API
Documentation
Reference.docx

Calculates the downskin


area. Downskinangle is
given in degree (90 -
Areasum = mesh:getdownskinarea(downskinangle: support angle as specified
getdownskinarea
number); in the Analysis/Up-
/Downskin analysis
dialog). Units are mm^2
(=cm^2*100)
Returns the volume of the
support in mm³. The area,
which needs support, is
calculated using the
parameter criticalangle.
The normal of a triangle
getsupportvolume mesh:getsupportvolume(criticleangle:number); with respect to the z-axis
defines the critical angle,
i.e. a small critical angle
means that only a small
area needs support. If the
calculation fails, -1 is
returned.
Returns the value of the
length of all outer
contourlengts in mm. The
gettotalcontourlength mesh:gettotalcontourlength(layersize) parameter layersize gives
the thickness of the
layersize. If the calculation
fails, -1 is returned.
Areasum = mesh:getupskinarea(downskinangle:
getupskinarea Calculates the upskin area
number);
Returns true if powder
would be trapped.
Holesize gives the sizes of
holes which are not large
result = mesh:trappedpowderanalysis(Holesize:
trappedpowderanalysis enough to remove the
number)
powder, e.g. all holes
smaller than this size are
ignored. The default value
is 0.
Checks the wallthickness
of a mesh. Returns true if
the wallthickness is not
smaller than
criticaldistance for more
Boolean result = than the criticalsurface
mesh:wallthicknesstest(criticaldistance:number,
wallthicknesstest
criticalsurface:number in %; colormesh: Boolean; area. If colormesh is true,
AMulticore: Boolean); the results of the
wallthickness will be
written into the color
information of the mesh. If
AMulticore is true,
multithreading is used.
The parameters are the
same as in
wallthicknesstest, however
TLuaXML result = here a xml is returned with
mesh:wallthicknesstestwithoutput the following informations:
wallthicknesstestwithoutput
(criticaldistance:number, criticalsurface:number in ‘testpassed’, ‘totalarea’,
%; colormesh: Boolean; AMulticore: Boolean); ‘testprob’,
‘areabelowthreshold’,
‘numberofclusters’,
’areaoflargestcluster’
33 / 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.

2.5.2.4 Boolean Operations


Name Syntax Description
Bools the current mesh with
Result = mesh:bool(asecondmesh: TLUAMesh; a second. If operationtype is
bool
operationtype: number); 0 the mesh is added, if it is 1
the mesh is subtracted.
Splits up a mesh along its
self intersections, same as:
insertselfintersections mesh:insertselfintersections(epsilon:number); Self-intersections: Split off in
Netfabb Professionals
Repair actions
Works similar to the unify
function only that it builds the
intersect mesh:intersect();
intersect of 2 merged
meshes

34 / 107
Netfabb Lua Scripting API
Documentation
Reference.docx

Unifies shells of a nice


mesh. This is actually the 3d
boolean function of Netfabb.
This does the actual
operation of fusing 2
meshes. As an "add"
function, if you just merge 2
meshes, as a "substract"
operation, when you invert
unify mesh:unify(epsilon:number); one mesh before.
The epsilon parameter is
syntactically required, but
internally ignored (this was
originally a precision
parameter, but that has been
changed with a scaling
algorithm. The syntax is for
backward compatibility)
Wraps a mesh. Only the
outer part of a mesh is left.
wrap mesh:wrap();
Uses a parallel multicore
algorithm
Wraps a mesh. Only the
outer part of a mesh is left.
wrapsinglecore mesh:wrapsinglecore();
Uses the old singlecore
algorithm

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() -

2.5.2.5 Mesh Repair


Name Syntax Description
closetrivialholes mesh:closetrivialholes(); Close trivial holes
Closes all non-trivial holes.
closeallholes mesh:closeallholes(timeout:number); Timout is an optional timeout
parameter (in seconds)

35 / 107
Netfabb Lua Scripting API
Documentation
Reference.docx

Cuts the mesh enlong the


x,y, or z plane. Plane 0
corresponds to the z-y plane,
1 to the z-x plane and 2 to
the x-y plane. The height
Newmesh= gives the position of the
cut mesh:cut(plane:number;height:number;topbott plane, topbottom can be
om:number); either 1, then the top mesh
will be returned or 2, then the
bottom mesh will be
returned. Topbottom is
optional, default is that the
top mesh is returned.
Tries to create a uniform
fixflippedtriangles mesh:fixflippedtriangles();
mesh orientation
Inverts all shells with
invertnegativeshells mesh:invertnegativeshells();
negative volumes
Returns a mesh, which is by
the offset smaller than the
original mesh. The rastersize
is the resolution. The
smoothing only occurs at the
resolution limit. Offset and
Newmesh = mesh:hollow(offset:number,
hollow rastersize should both be
rastersize:number, smoothen:boolean);
positive (in mm). The newly
created part has the right
orientation to allow the
hollowing: in order to hollow
an actual part the meshes
still have to be merged.
If the mesh consists of two
open shells, which contours
are nearby by the mesh is
connected. The feature is
called “Join contours” in the
Join nesh:join();
mesh repair module. Please
note that the selection of
triangles is done
automatically and may not
not be correct.
makeorientable mesh:makeorientable(); Makes Mesh orientable
meshnodesparsificati mesh:meshnodesparsification(Epsilon:number, Sparsificated nodes of a
on DegenerationUnits:number); mesh
Returns a mesh, which is by
the offset smaller/larger than
the original mesh. The
rastersize is the resolution.
Newmesh = mesh:offset(offset:number, The smoothing only occurs
offset rastersize:number, smoothen:Boolean; at the resolution limit. Offset
inneroffset: boolean); and rastersize should both
be positive (in mm). If
innerset is true, an
inneroffset will be generated,
otherwise an outer offset.
preparetopologyforex Prepares topology for STL
mesh:preparetopologyforexport();
port export

36 / 107
Netfabb Lua Scripting API
Documentation
Reference.docx

Reduces number of
trianglesFrom Netfabb Pro:

mesh:reducelod(target:number,
reducelod
deformation:number, edgelength:number);

Target: Target Triangle count


Deformation: Max.
Deformation (cm3)
edgelength: Max. Collapsed
edge length
Reduces number of triangles
From Netfabb Desktop:

mesh:reducelodadvanced(count:number,
reducelodadvanced
deformation:number, edgelength:number);

Target: Target Triangle count


Deformation: Max.
Deformation (cm3)
edgelength: Max. Collapsed
edge length
removedegeneratefac
mesh:removedegeneratefaces(tol:number); Removes degenerated faces
es
Removes double triangles
removedoublefaces mesh:removedoublefaces();
from the mesh
removeghostshells mesh:removeghostshells(epsilon:number); Remove small shells
Remove shells with negative
removenegativeshells mesh:removenegativeshells();
volume
Removes tiny faces which
removeproblemareas mesh:removeproblemareas(); are causing many self-
intersections
Same as the Netfabb
repairenhanced mesh:repairenhanced(); Professional "default" repair
makro script
Same as the Netfabb
repairextended mesh:repairextended(); Professional "extended"
repair makro script
Same as the Netfabb
repairsimple mesh:repairsimple(); Professional "simple" repair
makro script
mesh:stitch(tol:number, Stitches open triangle
stitch
preserveorientation:boolean); borders

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

2.5.2.6 Mesh Textures


Name Syntax Description

Returns a Boolean value, if a


hastexture mesh:hastexture();
mesh has a texture.

Saves the texture of a mesh into


a jpg file. Attention:
savetexturetofile mesh:savetexturetofile(filepath: string) Fileextension is not needed in
the filepath as it will be added
automatically.

2.5.2.7 Model Package


Name Syntax Description

38 / 107
Netfabb Lua Scripting API
Documentation
Reference.docx

Creates a model package for


the current mesh. The text is
printed on the package. The
mesh:createmodelpackage(barwidth, default values 0.8 mm for bar
createmodelpackage barthickness, partspacing, gridsizexy, gridsizez: width, 0.8 mm for
number; text: string); barthickness, 1.2mm for part
spacing, 10 mm for gridsizexy,
and 10 mm for gridsizez. The
result is the package mesh.

2.5.2.8 Mesh Support


The API has only one method, which uses an automated support definition, which
can be generated by the Netfabb Desktop software.
Name Syntax Description
Creates automatic Support
createsupport support = stl:createsupport(xmlfile: string) based on instructions in XML
parameter file.

Example:
stl = system:loadstl('file.stl')
support = stl:createsupport('support.xml')
support:savetostl('support.stl')

2.5.3 Relation to "LUAMeshObject" and "LUATrayMesh"

TLUAMeshObject
[Desktop Automation]
The TLUAMeshObject is the Lua representation of the "TNGM_Mesh_Advanced"
class. All modification functions are applied directly to the mesh

"TLUAMeshObject" is used in the Desktop Automation (through "TLU-


ATrayMesh").

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

2.6 Fabbproject API


[Desktop Automation]

The fabbproject API allows to create, load, modify and save fabbproject files used
by Netfabb.

2.6.1 Fabbproject Object


[Desktop Automation]

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

2.6.1.2 Method overview


Name Syntax Description
fabbproject:addtray(name: String, Adds a new tray to the
machinesize_x: Number, fabbproject. “Name” is the name
addtray of the tray, machinesize_x, _y,
machinesize_y: Number, and _z are the sizes of the tray.
machinesize_z: Number)

gettray fabbproject:gettray(index: Integer) Retrieve a tray from a fabbproject


savetofile fabbproject:savetofile(filename: String) Saves a fabbproject to a file
The sum of heights of all trays
totalheight fabbproject:totalheight() (only the height of the space that
is occupied by parts is included)

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”

2.6.2.2 Method overview


Name Syntax Description
Result =
checkforcollisi Checks the tray for collisions. Returns an instance of
checkforcollisions(ARast
ons "LUACollisionResult" (Reference: LUACollisionResult)
erSize: Number)
Create an object of type “LUAPacker” using the
implementation defined in “packer_id”. See constants
“packingid_null”, “packingid_outbox”, “packingid_2d”,
Packer = “packingid_3d”, “packingid_montecarlo” for the correct id.
createpacker tray:createpacker(packer Please note that the createpacker command creates a
_id: Number); snapeshoot of the tray with its current parts. If parts are
removed or added afterwards you need to create a new
packer

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

2.6.2.3 Constant Members

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

2.6.3.2 Method overview


Name Syntax Description
Add a LUAMesh to the group
Newtraymesh = Tray:addmesh(Mesh:
addmesh with the given name and color.
LUAMesh; AName: String; AColor: Integer)
Returns the new traymesh
Add a new subgroup to the
addsubgroup Subgroup = tray:addsubgroup(Name: String)
group

42 / 107
Netfabb Lua Scripting API
Documentation
Reference.docx

Remove and delete a subgroup.


Removes as well subgroups of
deletesubgroup Tray:deletesubgroup(Subgroup: LUASubgroup)
this group and meshes in these
groups.
Get a TLUATrayMesh from the
getmesh Mesh = tray:getmesh(Index: Integer)
group
getsubgroup Subgroup = tray:getsubgroup(Index: Integer) Get a subgroup by index
removemesh Tray:removemesh(Mesh: TLUATrayMesh) Removes a mesh from the group

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)

2.6.4.2 Method overview


Name Syntax Description

43 / 107
Netfabb Lua Scripting API
Documentation
Reference.docx

Assigns a mesh as a support to a


tray. Releavtive Coordinates
Mesh:assignsupport(mesh : LuaMesh; indicates if the coordinates are
assignsupport ReleativeCoordinates: Boolean) given in respect to the main mesh. If
traymesh:assignsupport() ‘assignsupport’ is called without
parameters, the existing support is
detached.
Returns the support of the mesh.
Boolean values specifies what
mesh:createsupportedmesh(mergepart,
meshes should be in the result. The
createsupportedmesh mergeopensupport, mergeclosedsupport:
thickening parameter allows the
Boolean; openthickening);
user to extrude open support so it
gets closed.
Get/set a packing option of the
mesh

Note: the following read/write


options are available:
- ‘priority’ (number, 1-10)
- ‘restriction‘ (‘locked’, ‘norestriction’)
- ‘rotate‘ (‘arbitrary’, ‘zaxis’ ,
‘forbidden’)
These options have to be set before
the start of the packing. All packer
respect ‘priority‘ and ‘restriction‘.
‘Rotate’ is only respected by the
montecarlo packer.

The following read-only option is


available:
- ‘state‘ ('packed', 'leftover',
'not_packable', ‘colliding', 'excluded',
Option = 'ignored', 'indefinite')
Mesh:getpackingoption(AOptionIdentifier: It describes the state of the part
getpackingoption/ String) after the packing process:
setpackingoptions Mesh:setpackingoption(AOptionIdentifier: ‘packed’ – the part is packed
String; AOptionValue: String) normally;
‘leftover’ – the part could not be
packed because the number of the
parts was too large for the given
tray;
'not_packable' – the part is too large
for the given tray;
‘colliding' – the part in its initial
position was colliding with a tray
wall or with another part, while it
was ‘locked’ or the packer option
‘start_from_current_positions’ was
chosen.
'excluded' – the part was excluded
from the packing process by the
user;
‘ignored’ – the part was ignored by
the packer (for instance, because its
mesh was empty or invisible)
‘Indefinite’ – the packing process
has not been started yet or was
aborted.
getuuid Uuid = mesh:getuuid() Get the UUID of a mesh

44 / 107
Netfabb Lua Scripting API
Documentation
Reference.docx

Rotate a mesh by a defined angle


Mesh: rotate(axis_x, axis_y, axis_z, angle: (angle) around a defined axis
rotate
Number) (axis_x, axis_y, axis_z); Rotate
angle is in radians.
Export the mesh including all
saveto3ds Mesh:saveto3ds(AFileName: String)
transformations to 3ds
Export the mesh including all
saveto3mf Mesh:saveto3mf(AFileName: String)
transformations to 3mf
Export the mesh including all
savetoamf Mesh:savetoamf(AFileName: String)
transformations to amf
Export the mesh including all
savetoasciistl Mesh:savetoasciistl(AFileName: String)
transformations to ascii stl
Export the mesh including all
savetogts Mesh:savetogts(AFileName: String)
transformations to gts
Export the mesh including all
savetoncm Mesh:savetoncm(AFileName: String)
transformations to ncm
Export the mesh including all
savetoobj Mesh:savetoobj(AFileName: String)
transformations to obj
Export the mesh including all
savetoply Mesh:savetoply(AFileName: String)
transformations to ply
Export the mesh including all
savetostl Mesh:savetostl(AFileName: String)
transformations to stl
Export the mesh including all
savetovrml Mesh:savetovrml(AFileName: String)
transformations to VRML
Export the mesh including all
savetox3d Mesh:savetox3d(AFileName: String)
transformations to x3d
Export the mesh including all
savetozpr Mesh:savetozpr(AFileName: String)
transformations to ZPR
scale Mesh:scale(x, y, z: Number) Scale a mesh
setmatrix Mesh:setmatrix(matrix: LUAMatrix4) Set the matrix of the mesh
Mesh:setpackingoption(AOption: String;
setpackingoption Add a packing option to the mesh
Avalue: String)
Extract a shell as new mesh object.
Same as
“LUAMeshObject.shellasmesh” but
Newmesh =
shellasmesh takes the matrix in the fabbproject
mesh:shellasmesh(shellnumber: Number)
into account. See
“LUATrayMesh.mesh.shellcount” for
the number of meshes
translate Mesh:translate(x, y, z: Number) Translate a mesh

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

Number of colliding meshes in the list


meshcount Read Number Note: both colliding meshes are inserted into the list, so
a meshcount of "2" means there is 1 collision

2.6.5.2 Method overview


Name Syntax Description
Returns a colliding mesh.
Note: if a collision is detected
the two collising meshes are
inserted into the list one by one,
i.e. Mesh at index 0 collides
getcollisionmesh Mesh = collisionresult:getcollisionmesh(0)
with mesh at index 1 and so on
Note: if a single mesh is more
often than once in the list
means that the mesh collides
with more than one other mesh

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

The desired minimal distance from the border of the


borderspacingxy Read/Write Number
tray. The default value is 0 mm;

The desired minimal distance from the build platform


borderspacingz Read/Write Number
of the tray. The default value is 0 mm;

Sets the global rotation behauviour. The values can


be 0 (Arbitrary), 1 (z-Axis), 2 (no rotation), Default
defaultpartrotation Read/Write Integer
value is 0. Note that this property is overwritten by the
packing property of the single tray meshes.

The desired minimal distance between the object in


minimaldistance Read/Write Number
the tray. The default value is 1 mm.

46 / 107
Netfabb Lua Scripting API
Documentation
Reference.docx

optInteger Read Number Constant for parameter type “Integer”

optFloat Read Number Constant for parameter type “Float”

optBoolean Read Number Constant for parameter type “Boolean”

The number of parameters of the packer. Use the


parametercount Read Number methods “tray:getparameter…” to get details about
any parameters.

Read or write the packer-specific parameters. Please


[Additional
Read/Write Number refer to the documentation of the packer
Parameter Name]
implementations for details.

2.6.6.2 Method overview


Name Syntax Description
Returns the dimensions of the
current tray as a TLUAOutbox.
getoutbox Result = Packer:getoutbox() The minx,miny, maxy, maxy
coordinates of gives the start and
end point of the tray.
Returns the name of the
Result = packer:getparemetername(Index: parameter with the given index.
getparametername
Number) See tray.parametercount for the
number of parameters available.
Returns the type of the parameter
with the given index as string
Result = packer: getparametertype(Index:
getparametertype (“integer”,”float”, “boolean”). See
Number)
tray.parametercount for the
number of parameters available.
Returns the name of the
parameter with the given index as
constant (see
Result = packer: getparametertypeid(Index: LUAPacker.optInteger,
getparametertypeid
Number) LUAPacker.optFloat,
LUAPacker.optBoolean). See
tray.parametercount for the
number of parameters available.

47 / 107
Netfabb Lua Scripting API
Documentation
Reference.docx

Returns the value of the


parameter with the given index.
Note that the type of the returned
Result = packer: getparametervalue(Index:
getparametervalue value differs depending on the
Number)
type of the paramter. See
tray.parametercount for the
number of parameters available.
Pack the tray with the desired
algorithm. Returns a packer-
pack Result = packer:pack()
specific error code (general: 0 =
no error)
Sets the dimension of the tray,
which should be packed. This can
setoutbox Packer:setoutbox(Outbox : TLUAOutbox);
be used to pack only a fraction of
the tray.

2.6.7 LUAPacker – Monte Carlo packer


[Desktop Automation]
An instance of this object is returned by the function of the LUATray: object
packer = tray:createpacker(tray.packingid_montecarlo); (Reference: LUATray)

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

Determines if the packing shoud be started


from the current positions of the items (true) or
start_from_current_positions Read/Write Boolean an initial placement procedure has to be run
before the packing begins (false). The default
value is false.

48 / 107
Netfabb Lua Scripting API
Documentation
Reference.docx

2.6.7.2 Method overview


Name Syntax Description
Pack the tray with the desired
algorithm. Returns an error code that
has the following meaning:
0 the packing is done. No problem
has been detected.
1 the packing is done. There was not
enough space in the tray to fit all
items.
2 the packing is done. Some items
are too large and cannot be fitted
in the tray.
3 all the items are too large. None
can be fitted into the tray.
pack Result = packer:pack() 4 there were no items to pack
5 starting the packing from the
current item positions was not
possible. Possible solutions:
a) increase the packing quality
b) try smaller values of the
parameters min_dist and/or
border_spacing_xy;
c) do not start from current
positions
(set start_from_current_positions
to false or drop this parameter)
13 unspecified error. Please contact
the support team.

2.6.8 LUAPacker – 3d Scanline packer


[Desktop Automation]
An instance of this object is returned by the function of the LUATray: object
packer = tray:createpacker(tray.packingid_3d); (Reference: LUATray)

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.

Property Read / Write Type Description

Boolean, if true the parts will be rotated around


allowrotationaxis Read/Write Number
the z-axis. The default value is false.

49 / 107
Netfabb Lua Scripting API
Documentation
Reference.docx

Integer, which gives the number of rotation,


e.g. 4 means that 0, 90, 180 and 270 Degrees
anglecount Read/Write Number
are tried. Values between 0,7 are allowed. The
default value is 0.

Integer, increases the rastersize. Values


coarsening Read/Write Number between 1 and 9 are allowed. The default
value is 1.

Boolean, enables the interlocking protection.


interlockingprotection Read/Write Number
The default value is false.

Boolean, if true, the outboxes of the meshes


minimizeoutbox Read/Write Number
will be minimized. The default value is false.

Boolean, if true parts are moved outside the


placeoutside Read/Write Number tray, if there could not be moved. The default
value is false.

Integer, gives the rastersize of the raster.


rastersize Read/Write Number Values between 1 mm and 5 mm are allowed.
The default value is 1 mm.

2.6.8.2 Method overview


Name Syntax Description
Pack the tray with the desired
algorithm. Returns an error code
that has the following meaning:
0 the packing is done. No problem
pack Result = packer:pack() has been detected. All parts
could be packed.
1 Error occurred, please check the
indivual mesh pack results

2.6.9 LUAPacker – 2d packer


[Desktop Automation]
An instance of this object is returned by the function of the LUATray: object
packer = tray:createpacker(tray.packingid_2d); (Reference: LUATray). Please
50 / 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.

Property Read / Write Type Description


Integer, which gives the number of rotation,
e.g. 4 means that 0, 90, 180 and 270 Degrees
anglecount Read/Write Integer are tried. Values between 0,7 are allowed.
Named “Z-Rotation” in the Desktop GUI for the
2dpacker. The default value is 0.

Integer, increases the rastersize. Values


coarsening Read/Write Integer between 1 and 9 are allowed. The default
value is 0.

Boolean, if true only parts are packed, which


packeonlyselected Read/Write Boolean have been selected in the Desktop application.
The default value is false.

Boolean, if true parts are moved outside the


placeoutside Read/Write Boolean tray, if there could not be moved. The default
value is false.

Ranges between 0.1 and 10 mm. Gives the


voxelsize which is internally used for the
rastersize Read/Write Number
algorithm. Named “voxelsize” in the Desktop
GUI for the 2dpacker. The default value is 1.

The 2d-Packer packs every part individually in


a sequentiell order. The packing starts in one
corner and is stopped if either all parts are
packed or no more space is available. The
sorttype Read/Write Integer parts are sorted before the packing. The sorting
can either by size (sorttype =0) or by height
(sorttype =1). The size refers to the effective 2d
raster size of the corresponding object. The
defaullt value is 0.

2.6.9.2 Method overview


Name Syntax Description
Pack the tray with the desired
pack Result = packer:pack() algorithm

51 / 107
Netfabb Lua Scripting API
Documentation
Reference.docx

2.6.10 LUAPacker – outbox packer


[Desktop Automation]
An instance of this object is returned by the function of the LUATray: object
packer = tray:createpacker(tray. packingid_outbox); (Reference: LUATray).

2.6.10.1 Properties
This section describes packer-specific properties of the outbox packer.

Property Read / Write Type Description

If true, only planar packing is used, i.e. the parts


pack2D Read/Write Boolean are not packed in z. The default value is false.

Float number, ranges between 0.1 and 10 mm.


Gives the voxelsize which is internally for the
rastersize Read/Write Number algorithm. Named “voxelsize” in the Desktop
GUI for the 2dpacker. The default value is 1
mm.

2.6.10.2 Method overview


Name Syntax Description

Pack the tray with the desired


pack Result = packer:pack() algorithm

2.7 GUI-specific Objects


[Desktop Automation]

2.7.1 ControlContainer Base class

[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.1.2 Method Overview


Name Syntax Description
addbutton controlcontainer:(); Add a Button GUI element
addcheckbox controlcontainer:addcheckbox(); Add a Checkbox GUI element
adddropdown controlcontainer:adddropdown(); Add a Dropdown GUI element
addedit controlcontainer:addedit(); Add a Edit GUI element
addfloatspinedit controlcontainer:addfloatspinedit() Add a FloatSpinEdit GUI element
addgroupbox controlcontainer:addgroupbox(); Add a Groupbox GUI element
addimage controlcontainer:addimage(); Add an Image GUI element
addlabel controlcontainer:addlabel(); Add a Label GUI element
addmemo controlcontainer:addmemo(); Add a Memo GUI element
Add a PicturebuttonGUI
addpicturebutton controlcontainer:addpicturebutton();
element
addscrollbar controlcontainer:addscrollbar(); Add a Scrollbar GUI element
addspacer controlcontainer:addspacer(); Add a Spacer GUI element
addslider controlcontainer:addslider(); Add a Slider GUI element
Add a Splitter GUI element.
Optionam parameter “Name”
specifies the name of the
element, “ThreeSections”
controlcontainer:addsplitter([Name: String, decides whether or not the
addsplitter
ThreeSections: Boolean]); splitter shall include 3 splits.
Use an empty string as name if
you want to use three sections
but don’t want to specify a
name.
addtabcontrol controlcontainer:addtabcontrol(); Add a TabControl GUI element
addtable controlcontainer:addtable(); Add a TableObject GUI element
disabletimer Controlcontainer:disabletimer() Disables a timer.
Set up a callback function for a
Controlcontainer:enabletimer(interval:Number,
enabletimer timer that is called all interval
call:String)
milliseconds.

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?

2.7.2.2 Method Overview

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?

2.7.3.2 Method Overview

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?

2.7.4.2 Method Overview

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.5.2 Method Overview


None.

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?

2.7.6.2 Method Overview


Name Syntax Description
Adds an item with a 'caption'
and 'id', sorted by 'priority'
number ascending. Translate
is a boolean. Style is an
dropdown:additem (caption, id, [priority, translate,
additem integer bitfield for the item's
style, fontcolor]);
draw style (1=bold, 2=italic,
4=strikeout, 8=underline),
fontcolor is the font color.
Format is ‘$BBGGRR’
Clears the items in dropdown
clear dropdown:clear();
list.
Parameter = dropdown: getitemparameter(Index: Get the Parameter (id) of an
getitemparameter
Integer); item at a specific position
Get the text of an item at a
getitemtext Text = dropdown:getitemtext(Index: Integer);
specific position

56 / 107
Netfabb Lua Scripting API
Documentation
Reference.docx

removeitem dropdown:removeitem(id); removes an item


Updates all the items added
updateitems dropdown:updateitems();
or removed in the list.

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.7.2 Method Overview


None.

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

leftspacing read / write number left spacing of the label in pixels


topspacing read / write number top spacing of the label in pixels
translate read / write boolean if true, 'caption' has to be String Identifier
visible read / write boolean Shall the label be visible?

2.7.8.2 Method Overview

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?

2.7.9.2 Method Overview

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

Figure 1 - the result of the slider example code

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?

2.7.10.2 Method Overview

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

height read / write number height of the memo in pixels


hint read / write string Hint / Tooltip for the button
onchange read / write string callback function for a change event
readonly read / write boolean Shall the memo be readonly?
text read / write string text content of the memo
translate read / write boolean if true, 'caption' is String Identifier
visible read / write boolean Shall the memo be visible?

2.7.11.2 Method Overview


Name Syntax Description
Adds a text line to the memo
addline memo:addline(text:String)
field

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.12.2 Method Overview


None.

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

2.7.13.2 Method Overview


Name Syntax Description

60 / 107
Netfabb Lua Scripting API
Documentation
Reference.docx

Sets the active split side to


the center one (only available
if the “ThreeSections”
settocenter splitter:settocenter parameter was set to “true”
when creating the splitter
(See ControlContainer Base
class for details)
sets the active split side to
settoleft splitter:settoleft();
the left one
sets the active split side to
settoright splitter:settoright();
the right one

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.14.2 Method Overview


Name Syntax Description
close dialog:close(); closes the dialog
rebuild dialog:rebuild(); rebuilds the dialog
show dialog:show(); shows the dialog

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.15.2 Method Overview


Name Syntax Description
Retrieve the text of a table
getcelltext Table:getcelltext(column: integer; row: integer);
cell
Table:setcelltext(column: integer; row: integer; text:
setcelltext Modify the text of a table cell
string);
Table:setcolumnwidth(column: integer; width: Modify the width of a column
setcolumnwidth
integer); of the table

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.16.2 Method Overview


Name Syntax Description
Add a new sheet to the tab
control. If you add a new
addtabsheet Tabcontrol:addtabsheet(); sheet at runtime make sure
you call the “rebuild” function
of the containing dialog.

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.17.2 Method Overview


It has no methods of its own but supports all methods of the other ControlCon-
tainer, e.g. Addbutton.

2.7.18 Image
[Desktop Automation]

Image UI element. It is created by “controlcontainer:addimage()”.

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.18.2 Method Overview


Name Syntax Description
Sets a Graphobject as the
setgraph image:setgraph(graphobject); image. (Set image height and
width first!)
Sets an image-object as
setimage Image:setimage(imageobject); content. See image-
processing section

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.

2.7.19.2 Method Overview

None.

2.7.20 Histogram Object

[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

Colors are encoded as Integers ‘$BBGGRR’


Property Read / Write Type Description

bar_count Read / Write Number Number of bars of the histogram

color_bar Read / Write Number Color of the bar

color_bar_border Read / write Number Color of the bar border

color_background Read / Write Number Color of the background


color_caption Read / Write Number Color of the caption

64 / 107
Netfabb Lua Scripting API
Documentation
Reference.docx

color_selection Read / Write Number Color of selection

caption_x Read / Write String Horizontal caption string

caption_y Read / Write String Vertical caption string

selection Read / Write Number Current selected bar or graph-section

unit Read / Write String Unit string

2.7.20.2 Method Overview


Name Syntax Description
addvalue histogram:addvalue(value: number) Add new value
getvalue Histogram:getvalue(index: number) Return the value at given index.
Draw the histogram that contains
Img = histogram:drawhistogram(width, grouped values. The graphic is drawn
drawhistogram
height: number) into an image with given dimensions.
The result is an image object.
Draw the orderd values. The graphic is
Img = histogram:drawgraph(width, height: drawn into an image with given
drawgraph
number) dimensions. The result is an image
object.
Override min and max of added values
histogram:setcustomminmax(min, max:
setcustomminmax and set custom min and max for
number
drawing.
Select current selected bar or graph-
histogram:selectatpixel(width, height, x, y: section. Select by given graphic (width
selectatpixel
number) and height) and by given pixel position
(x and y)

2.7.21 Graph Object

[Desktop Automation]
Image UI element. It is created by “system:creategraph()”.

2.7.21.1 Properties
None.

2.7.21.2 Method Overview


Name Syntax Description
Adds a row/key at the position (like the
addrow graph:addrow(key:float);
width (and index) of an Excel column)
Graph:addvalue(column:integer, row:integer,
addvalue Sets value in row (key) and column,
value:integer)

65 / 107
Netfabb Lua Scripting API
Documentation
Reference.docx

Sets color for graph. Graph is the index of


the graph (the number of graphs is set
during the creation. Color is a RGB value
setcolor Graph:setcolor(graph:integer, color:integer) encoded in one integer, like:
graph:setcolor (0, 256 * 128); -- Green
graph:setcolor (1, 65536 * 128); -- Blue
Graph:savetopng(name:string, width:integer, Saves the graph to the file:name in the
savetopng
height:integer) height and width dimensions.

2.8 Slice related Objects


[Slice Commander] [Desktop Automation]
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 namespace of the script, which provides convenient ac-
cess to the currently loaded slice stack.

There are three main objects regarding slices:


• Slice Layer
• Slice Image Exporter
• Slice Object
Slice object is the main object.

2.8.1 Slice Layer


[Slice Commander] [Desktop Automation]

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

2.8.1.2 Method Overview


Name Syntax Description
addpoint slice:addpoint(?:number, ?:number);

begincontour slice:begincontour();

endcontour slice:endcontour();

extractcontour slice:extractcontour(?:number);

move slice:move(?:number, ?:number);


returns the amount of points
getpointcount slice:getpointcount();
of a slice layer
getpointx slice:getpointx(?:number, ?:number);

getpointy slice:getpointy(?:number, ?:number);

sort slice:sort(?:number, ?:number);

2.8.2 Slice Image Exporter

[Slice Commander] [Desktop Automation]

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

Create separate slice images for part and


separatesupports Read / write boolean
support
Basename of the support images (only
supportbasename Read / write string
used if “separatesupports” is set to “true”)
writeopencontours read / write boolean Shall the open contours be written?

2.8.2.2 Method Overview


Name Syntax Description
exportbmp slice:exportbmp(identifier:string); export slices as bmp
exportpng slice:exportpng(identifier:string); export slices as png
export slices as png with
exportpngmulticore slice:exportpngmulticore(identifier:string); multicore support for faster
calculation

2.8.3 Slice Object


[Slice Commander] [Desktop Automation]

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

2.8.3.2 Method Overview


Name Syntax Description
Calculates the area of
a slice; slice is
calculateslicearea slice:calculateslicearea(sliceheight:float);
selected by its height;
return the value
Calculates the area of
a slice; slice is
calculateslicearealayerindex slice:calculateslicearea(sliceindex:int);
selected by its index;
return the value
Calculate the length
of a slice; slice is
calculateslicecontour slice:calculateslicecontour(sliceheight:float);
selected by its height;
return the value

68 / 107
Netfabb Lua Scripting API
Documentation
Reference.docx

Calculate the length


of a slice; slice is
calculateslicecontourlayerindex slice:calculateslicecontour(sliceindex:int);
selected by its index;
return the value
resultsliceobject = slice:
conversion_connectopencontours
conversion_connectopencontours();
resultsliceobject = slice:
conversion_contourtohatches
conversion_contourtohatches();
resultsliceobject = slice: conversion_filter(
PreserveHatches : Boolean;
conversion_filter PreserveOpenContours : Boolean;
PreserveClosedContours : Boolean);

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);

slice:createimagerenderer(layerindex:int, Create an image of


createimagerenderer
size:float); the slice
Combine all slice files
of the slice objects,
createlayerunification slice:createlayerunification(?:number);
starting with the
heighest slice

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);

hatchcutting resultsliceobject = slice:hatchcutting()


Returns the slice layer
at the given index;
loadlayer slice:loadlayer(index:int);
returns the result as
new slice layer object
Moves a slice by the
slice:moveslice(X[mm]:float, Y[mm]:float,
moveslice given values; returns
Z[mm]:float);
nothing

71 / 107
Netfabb Lua Scripting API
Documentation
Reference.docx

Sets up the slice for multi-laser


processing. Returns slice list.
Parameters:
lcount- Laser Count e.g. 2
acc- Accuracy, e.g. 0.25
mbsize - Max Blocksize,e.g. 500
mdist - Max Distance e.g. 20
perlayershift- Shift per layer e.g.
2.5
gflow - Gas flow Angle e.g. 45
overlap - overlap in flow: e.g. 0.3
overlapa - overlap against flow:
e.g. 1.2

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

Reduces the points of a slice;


reduce slice:reduce(tolerance[mm]: float); returns the result as new slice
object
Removes the self intersections;
removeselfintersections slice:removeselfintersections(); returns the result as new slice
object
Removes the self intersections
removeselfintersectionmulticore slice:removeselfintersections(); using multi cpu cores; returns the
result as new slice object
Exports a slice to a given slice
format; identifier gives the name;
slicetype gives the slice type;
returns nothing
slice:savetofile(identifier:string, Slice type global constants:
savetofile slycetype:int, layersize:float, • stCLI
minz:float, maxZ:float,);
• stCLS
• stSLC
• stSLI
• stUSF
Smoothes a slicer; returns the
smooth slice:smooth(value:number);
result as new slice object
Subtracts from slice the given
substractslice slice:subtractslice(sliceobject:object); slice sliceobject.; returns the
result as new slice object
slice:translate(X[mm]:float, Moves a slice by the given
translate
Y[mm]:float, Z[mm]:float); values; returns nothing

2.9 Document related Object types

2.9.1 XML file Object


[Desktop Automation]
An XML file object contains the full information of an XML file. It can be used to
read XML information from the disk as well as output information in the XML
format to disk or to stdout.

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?

2.9.1.2 Method Overview


Name Syntax Description

73 / 107
Netfabb Lua Scripting API
Documentation
Reference.docx

xmlfile:Addchild(childname:string, Adds child node, adddouble


addchild
adddouble:boolean); allows for duplicates
addvalue xmlfile:addvalue(nodename:string, value:string/int); Adds a value to the XML file
Returns if nodename in the
childexists xmlfile:childexists(nodename:string);
XML file exists
Dumps the XML file on
dump xmlfile:dump() stdout. Even if the cloud
utilities are in quiet mode
findchild Childnode = xmlfile:Findchild(childname:string); Finds child node
Gets the Integer value of child
getchildint ChildIntvalue = xmlfile:Getchildint(child:string);
node
Childvalue =
getchildindexed Returns child value by index
xmlfile:Getchildindexed(childindex:string);
ChildIntvalue = Gets the Integer value of child
getchildintdef
xmlfile:Getchildintdef(child:string;value:number); or value
getchildfloat ChildIntvalue = xmlfile:Getchildfloat(child:string); Gets Float value of child node
ChildIFloatvalue = Gets Float value of child node
getchildfloatdef
xmlfile:Getchildintdef(child:string;value:number); or value
Childvalue =
getchildvalue Returns child value
xmlfile:Getchildvalue(childname:string);
savetofile xmlfile:savetofile(filename:string); Writes the XML file to disk
Returns a string with the
writetostring Xmlfile:writetostring()
contents of the XML

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 XML node Object


[Desktop Automation]
An XML node object contains the full information of an XML node.

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.2.2 Method Overview


Name Syntax Description
node:Addchild(childname:string, Adds child node, adddouble
addchild
adddouble:boolean); allows for duplicates
addvalue node:addvalue(nodename:string, value:string/int); Adds a value to the XML file
Returns if nodename in the
childexists node:childexists(nodename:string);
XML file exists
findchild Childnode = node:Findchild(childname:string); Finds childnode
Gets string value of attribute
getattribut node:getattribute(nodename:string)
of a node
getattributeint IntValue = node:getattributeint(nodename:string); Gets integer value of node
FloatValue = Gets float value of attribute of
getattributefloat
node:getattributefloat(nodename:string); a node
Gets the Integer value of child
getchildint ChildIntvalue = node:Getchildint(child:string);
node
Childvalue =
getchildindexed Returns child value by index
node:Getchildindexed(childindex:string);
ChildIntvalue = Gets the Integer value of child
getchildintdef
node:Getchildintdef(child:string;value:number); or value
getchildfloat ChildIntvalue = node:Getchildfloat(child:string); Gets Float value of child node
ChildIFloatvalue = Gets Float value of child node
getchildfloatdef
node:Getchildintdef(child:string;value:number); or value
getchildvalue Childvalue = node:Getchildvalue(childname:string); Returns child value
Returns true if a node has a
Boolean Value =
hasattribute specific attribute, false
node:hasattribute(attribute_name: String)
otherwise

2.9.3 Json file Object


[Desktop Automation]
The Json file object represents a Json file.

2.9.3.1 Properties

None.

2.9.3.2 Method Overview


Name Syntax Description
Jsonfile:addboolean(name:String, Adds a Boolean value to a
addboolean
value:Boolean); name-value pair.
Jsonfile:addinteger(name:String, Adds an Integer value to a
addinteger
value:Integer); name-value pair.
Jsonfile:addfloat(name:String, Adds a Float value to a name-
addfloat
value:Float); value pair.

75 / 107
Netfabb Lua Scripting API
Documentation
Reference.docx

Jsonfile:addstring(name:String, Adds a String value to a name-


addstring
value:String); value pair.
Returns TRUE if in the Jsonfile
Ret:boolean =
childexists a name-value pair exists with
Jsonfile:childexists(name:String);
the name ‘name’.
Ret:boolean = Returns the boolean value of
getboolean
Jsonfile:getboolean(name:String); the ‘name’ name-value pair
Ret:Integer =
Returns the integer value of the
getinteger Jsonfile:getinteger(name:String,
‘name’ name-value pair
value:Integer);
Ret:Float = Jsonfile:getfloat(name:String, Returns the float value of the
getfloat
value:Float); ‘name’ name-value pair
Ret:String =
Returns the string value of the
getstring Jsonfile:getstring(name:String,
‘name’ name-value pair
value:String);
loadfromstring Jsonfile: loadfromstring (string:String); Loads Jsonfile from ‘string’
Saves the Jsonfile under the
savetofile Jsonfile:savetofile(filename:String);
‘filename’ name.
writetostring string:String = Jsonfile: writetostring (); Returns the Jsonfile as string.

2.9.4 CSV file Object


[Desktop Automation]
The text file object represents a CSV file. The file consists of string entries
inside a matrix of rows and colums (also known as fields) . The matrix entries
are called cells. The number of colums is defined by the first row. If you add a
new row with more columns than the first row a error is thrown.

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

2.9.4.2 Method Overview


Name Syntax Description
Appends one cell to the file. If
CSVfile:appendfilewithentry (cell:string [,
appendfilewithentry ‘lineending’ is TRUE, a newline
lineending:Boolean]);
is added at the end.
appendfilewithline CSVfile:appendfilewithline (line:string); Appends one line to the file.
Reads the cell at ‘row’ and
Field:string = CSVfile:getcell(row:number;
getcell ‘field’. If ‘replace’ is TRUE,
field:number [, replace:boolean]);
quotationsmarks are removed.
readfile CSVfile:readfile(filename:string); Reads the ‘filename’ from disk.
Saves the CSV file to ‘filename’,
overwrites an existing file
savetofile CSVfile:savetofile(filename:string);
depending on the Boolean value
at creation of the object.

76 / 107
Netfabb Lua Scripting API
Documentation
Reference.docx

2.9.5 Text File Object


[Desktop Automation]
The text file object represents a text file.

2.9.5.1 Properties
Property Read / Write Type Description
linecount read only Number Returns the number of lines

2.9.5.2 Method Overview


Name Syntax Description
clear Txtfile:clear(); Empties the textfile object
getline resultline = txtfile:getline(linenumber:number); Returns textline at linenumber
Loads text file from disk,
loadfromfile Result = txtfile:loadfromfile(filename:string);
returns TRUE when successful
Writes textfile, TRUE, when
savetofile Result = txtfile:savetofile(filename:string);
successful
Writes 'text' at line number:
Result = txtfile:setline(linenumber:number;
setline 'linenumber', TRUE when
text:string);
successful
writeline txtfile:writeline(text:string); Appends 'text' to text file

2.10 Database related Objects

2.10.1 Database Connection Object

[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

2.10.1.2 Method Overview


Name Syntax Description
Result = Returns TRUE, if table
checkiftableexists
dbconnection:checkiftableexists(tablename:string); with tablename exists
Result =
createttable Creates a new table
dbconnection:createttable(tablename:string);
disconnect dbconnection:disconnect(); Disconnects from the DB
getinsertid insertid = dbconnection:getinsertid(); Returns the last insert id
Returns the QueryResult
getresult Queryresult = dbconnection:getresult();
Object

77 / 107
Netfabb Lua Scripting API
Documentation
Reference.docx

getuniquestring uniquestring = dbconnection:getuniquestring(); Gets unique string


Returns TRUE when
successful, the query
sendquery Result = dbconnection:sendquery(query:string);
result can be evaluated
wuth "getresult".

2.10.2 Query Result Object


[Desktop Automation]
The result object of a database query.

2.10.2.1 Properties
None.

2.10.2.2 Method Overview


Name Syntax Description
IntResult = Returns the Integer value of
getintegerfield
queryresult:getintegerfield(fieldnumber:number); the field in fieldnumber
StringResult = Returns the String value of
getfield
queryresult:getfield(fieldnumber:number); the field in fieldnumber
Returns number of fields in
getfieldcount Result = queryresult:getfieldcount();
row

FloatResult = Returns the Float value of the


getfloatfield
queryresult:getintegerfield(fieldnumber:number); field in fieldnumber
Put the result pointer to the
nextrow queryresult:nextrow();
next row

2.11 Image and Display related Objects

2.11.1 OGLRendering Object

[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.

2.11.1.2 Method Overview


Name Syntax Description

78 / 107
Netfabb Lua Scripting API
Documentation
Reference.docx

Adds the model of


oglcontext:addmodeltoscene
addmodeltoscene 'modelID' to the
(modelid:integer);
current scene.
Puts a mesh object
into the oglrender
context, returns the
modelID.
loadcolors: optional
parameter, default is
true. Flag to allow
loading of vertex
colors.Setting the
flag to false allows
the setting of a
Modelid:integer = oglcontext:createmodel uniform color using
createmodel (mesh:mesh object, loadcolors: boolean, setmodelcolor.
loadtextures: boolean, matrix: tluamatrix) loadtextures:
optional parameter,
default is true. Flag
to allow loading of
vertex textures.
matrix: optional
parameter,
transforms the
model and sets the
transformed
bounding box when
set
Remoces model
freemodel oglcontext:Freemodel (modelid:integer); from scene and
deletes reference
DEBUG ONLY:
Load the OpenGL
identity oglcontext:identity ();
identity matrix
("glloadidentity()")
Sets the camera
position
eye (x,y,z) = eye
vector
up (x,y,z) = the UP
vector describes the
roll of the camera by
oglcontext:lookatmodelfromsurroundingspher
lookatmodelfromsurroundingsp saying which point is
e (modelid, eyex, eyey, eyez, upx, upy, upz,
here "up" in the camera's
offset: all integer);
orientation.
offset = distance to
mesh object
(for more
information: search
for opengl and eye
and up vector)
multmatrix oglcontext:multmatrix (modelid + 16 integer); DEBUG ONLY
popmodelmatrix oglcontext:popmodelmatrix (modelid:integer); DEBUG ONLY
pushimage oglcontext:pushimage (); DEBUG ONLY
oglcontext:pushmodelmatrix
pushmodelmatrix DEBUG ONLY
(modelid:integer);

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

Sets the position of


lightsource, type 1 =
setlightpos oglcontext:Setlightpos (x,y,z,type: all integer); point lightsource,
otherwise
unidirectional
Sets the reflectivity
oglcontext:Setreflectivity (modelid: integer,
setreflectivity factor (e.g. "0.6") for
reflectivity: float);
the model
OpenGL
swapbuffers oglcontext:swapbuffers (); glutswapbuffers
function
oglcontext:Removemodelfromscene Removes model
removemodelfromscene
(modelid:integer); from scene
DEBUG ONLY:
translate oglcontext:translate (x,y,z:all float); OpenGL translate
function

2.11.2 Image Processing


[Desktop Automation]
The Lua Image Processing Interface provides functionality for simple image
processing and algorithms.

2.11.2.1 Properties
None.

2.11.2.2 Method Overview


Name Syntax Description
Loads image from specified file
loadimage Imageobject = Ip:loadimage(file: string)
and returns a lua-image-object

2.11.3 Image Object

[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

2.11.3.2 Method Overview


Name Syntax Description
Converts given color to
colortotransparent img:colortotransparent(color: number)
transparency.

81 / 107
Netfabb Lua Scripting API
Documentation
Reference.docx

Compares the image to another


specified image pixel by pixel.
compareto img:compareto(img: object) The result ist the percentage of
equality (50% = random image,
100% = equal image).
Compares the image to another
specified image pixel by pixel.
Img:comparebyfiltercolor(img: object; color:
comparebyfiltercolor Just respect pixels with given
number)
mask-color The result ist the
percentage of equality
Calculates the difference
between the two images. Same
deltato img:deltato(img: object)
areas are black, difrerences are
higlighted white
Detects edges of the image by
the canny-algorithm. The
detectedges img:detectedges()
resulting image is black with
white one pixel wide edges.
Performs the gausssmoothing
gausssmoothing img:gausssmoothing(sigmar: number)
filter with specified sigmar value
Applies a mask operation on the
image where every pixel of the
img:colormask(mask: object; maskcolor: color; image is replaced by “newcolor”
colormask
newcolor: number) where the color of the “mask”
image is “maskcolor”
[Desktop Automation]
Applies a mask operation on the
image where every pixel of the
Img:imagemask(mask: object; maskcolor:
imagemask image is replaced by mask-pixel
number)
if the input-pixel equals
maskcolor.
invert img:invert() Inverts colors of the image
Performs the laplace filter on the
laplace img:laplace()
image
Draw a image over another
paint img:paint(img: object) image. Transparent areas in the
top image will be ignored.
saveto img:saveto(file: string) Saves image to specified file
Override the color of the entire
setcolor img:setcolor(color: number) image. Transparency will stay
the same.
Converts colored image to
tograyscale img:tograyscale()
grayscale

2.12 CAD Import related Objects

2.12.1 CadImporter Object

[Desktop Automation]

2.12.1.1 Properties
None.
82 / 107
Netfabb Lua Scripting API
Documentation
Reference.docx

2.12.1.2 Method Overview


Name Syntax Description
Syntax 1:
Load the model "handel.step"
with a maximum surface
deviation of 0.1 and a angle
tolerance and a maximal edge
length of 5 mm
Syntax 2:
cadmodel = importer:loadmodel('handle.step', loadmodel(filename, detaillevel)
loadmodel where detaillevel is a number 1-
0.1, 20, 5)
5 corresponding to the 5 Detail
settings of the UI in Netfabb:
1 = extra low
2 = low
3 = medium
4 = high
5 = Extra high

2.12.2 CADImportModel Object

[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

2.12.2.2 Method Overview


Name Syntax Description

mesh = cadmodel:createsinglemesh Creates a mesh with a single


createsinglemesh
(EntityIndex: Number); entity

createmesh mesh = cadmodel:createmesh() Creates a mesh with all entities

83 / 107
Netfabb Lua Scripting API
Documentation
Reference.docx

name = cadmodel:getentityname(EntityIndex:
getentityname Returns the entity’s name
Number);

2.13 Utility Data Objects


[Desktop Automation]

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 Outbox Object


Represents an outbox

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)

2.13.6.2 Method Overview

None.

2.14 Webservices related Objects

2.14.1 Netfabb Taskserver Object


[Desktop Automation]

The Netfabb Taskserver is an Addon service program, allowing to distribute tasks


to Netfab Ultimate Clients. The object allows to connect to this service and to act
as a client as well as a worker instance to a complete system. For details please
refer to the according separate documentation.

2.14.1.1 Properties
Read /
Property Type Description
Write
The description of the last error, that has
lasterror Read String
occured

2.14.1.2 Method Overview


Name Syntax Description
Ret:boolean = Authenticates the taskhandller
authenticate Taskhandler:authenticate(userid:String, with a userid and the serverkey
serverkey: String); (shared secret/passphrase)

86 / 107
Netfabb Lua Scripting API
Documentation
Reference.docx

Returns task object by


Task:Taskobject =
checktask “uuidstring”. Use to find “your”
Taskhandler:checktask(uuidstring:string);
task.
Task:taskobject = Creates a new task with the
createtask
Taskhandler:createtask(taskname:String) name “taskname”
Retrieves a task object by
Task:taskobject = name of “taskname”. To use by
retrievetask
taskhandler:retrievetask(taskname:String) a “worker” to find a task of a
certain “type” (name).

2.14.2 Netfabb Task Object


[Desktop Automation]

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

2.14.2.2 Method Overview


Name Syntax Description
Adds a parameter to the
addparameter Task:addparameter(key:String; value: String)
task as a key/value pair.
Adds a result to the task
addresult Task:addresult(key:String; value: String)
as a key/value pair.
Sets the status of the task
cancel Result:Boolean = Task: cancel ()
to “CANCELED”
Sets the status of the task
error Result:Boolean = Task: error()
to “ERROR”
Gets a parameter value
param:String =
getparameterbyindex from the task by the index
Task:getparameterbyindex(index:Number)
number of the parameter
Gets a parameter value
param:String = from the task by the name
getparameterbyname
task:getparameterbyname(keyname:String) of the key of the
parameter

87 / 107
Netfabb Lua Scripting API
Documentation
Reference.docx

Get the key name of a


param:String =
getparametername parameter by its index
task:getparametername(index:Number)
number
Gets a result value from
Result:String =
getresultbyindex the task by the index
task:getresultbyindex(index:Number)
number of the result
Gets a result value from
Result:String =
getresultbyname the task by the name of
task:getresultbyname(keyname:String)
the key of the result
Get the key name of a
getresultname result:String = task:getresultname(index:Number)
result by its index number
Sets the status of the task
giveback Result:Boolean = Task: giveback()
to “RETURNED”
Submits the task to the
submit Result:Boolean = Task:submit() Taskserver. Returns
TRUE if successful.
Sets the status of the task
success Result:Boolean = Task: success ()
to “SUCCESS”
Poll task for updated
updatestatus Result:Boolean = Task: updatestatus ()
status

2.14.3 Hublist Object

[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

2.14.3.2 Method Overview


Name Syntax Description
Returns hub object by “index”.
gethub Hub = Hublist:gethub(index:Integer)
Index list starts with 0.

2.14.4 Hub Object

[Desktop Automation]

88 / 107
Netfabb Lua Scripting API
Documentation
Reference.docx

A hub is a collection of projects, either on Autodesk Forge or in the Netfabb Ap-


plication Server.

2.14.4.1 Properties
Read /
Property Type Description
Write
id Read String ID of this hub
name Read String Name of this hub

2.14.4.2 Method Overview


Name Syntax Description
Create a new project with
createproject Project = Hub:createproject(name:String);
“name” on the hub
Returns the list of projects in
getprojectlist Projectlist = hub:getprojectlist();
this hub.

2.14.5 Projectlist Object


[Desktop Automation]

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

2.14.5.2 Method Overview


Name Syntax Description
Returns a project by its index
getproject Project = projectlist:getproject(index:Integer);
number.

2.14.6 Project Object

[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

hasavatar Read Boolean Whether this project has an avatar image


Id Read String Id of the project
name Read String Name of the project

2.14.6.2 Method Overview


Name Syntax Description
Returns the root folderlist of
getrootfolderlist folderlist = project:getrootfolderlist();
the project, nil if empty.

2.14.7 Folderlist Object


[Desktop Automation]

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

2.14.7.2 Method Overview


Name Syntax Description
Gets a folder from a folderlist
getfolder Folder = folderlist:getfolder(index:Integer); by index number. Numbers
start at 0.

2.14.8 Folder Object

[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

2.14.8.2 Method Overview


Name Syntax Description
Creates foldername as
createsubfolder Folder:createsubfolder(foldername:String);
subfolder in folder.
Returns list of items from folder
getitemlist Itemlist = Folder:getitemlist();
object, otherwise returns NIL
Returns list of subfolders from
getsubfolders Folderlist = Folder:getsubfolders(); folder object, otherwise returns
NIL.
Scans the folder for items and
subfolders. Has to be called
receivecontent Folder:receivecontent();
once before “getitemlist” or
“getsubfolders”

2.14.9 Itemlist Object

[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

2.14.9.2 Method Overview


Name Syntax Description
Item = Itemlist:finditembyname(name:String, Get item by name, optional
finditembyname
[Casesenitive:Boolean]); casesensitive.
getitem Item = Itemlist:getitem(index:Integer); Get an item by index number.

2.14.10 Item Object

[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

name Read String Name of item


projectid Read String Project id of item

2.14.10.2 Method Overview


None.

2.15 Miscellaneous Objects

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

newmesh = stamper:stamp(Mesh: LUAMesh, Labels the text on the mesh.


stamp
text : string ) Creates a new mesh as an
output.
stamper:setpos(APos1: number, APos2: Sets the positon. This is the
setpos
number, APos3: number) center of the text.
Sets the normal of the plane of
stamper:setnormal(APos1: number, APos2:
setnormal the label. For example Vec
number, APos3: number)
(0,0,1) would be the x,y plane.

92 / 107
Netfabb Lua Scripting API
Documentation
Reference.docx

If a plane is given for the label,


one needs to define what angle
the text should have in the plane,
i.e. in what direction the text is
stamper:setupvector(APos1: number, APos2: printed. ‘setupvector’ sets the
setupvector
number, APos3: number) upvector, which defines what
direction is defined as “up” for a
text. The Vector should to be
perdendicular to the normal
vector.

2.15.2 LUAReportgenerator
[Desktop Automation]

This Lua objects allows to generate reports.

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.

Takes a tray and generates a


report based on the given
template. The report is saved
stamper:setpos(APos1: number, APos2:
createreportfortray in file called reportname. For
number, APos2: number)
optimal output the template
type should correspond to a
tray.

2.15.3 Test framework interface

[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

duration read / write Number Duration of this test in seconds


failurecount read Number Number of failed sub tests
name read / write String Name of the test suite
success read / write Boolean True for success, false for failure
testcount read Number Number of all sub tests

2.15.3.2 Method overview


Name Syntax Description
Asserts for value =
suite:asserttrue(emassage: string; value: true. For false value,
asserttrue
boolean) the test fails and sets
the errormessage
Asserts for equal
geometry of the two
meshes with
suite:asserequalsmeshgeometry(emassage: meshcompare
assertequalsmeshgeometry string; mesh1, mesh2: MeshObject; accuracy: considering to the
Number) optional accuracy. For
not equal meshes, the
test fails and sets the
errormessage.
Asserts for equal
properties of the two
meshes: NodeCount,
suite:assertequalsmeshproperties(emassage: EdgeCont and
assertequalsmeshproperties
string; mesh1, mesh2: MeshObject) FaceCount. For not
equal meshes, the test
fails and sets the
errormessage.
Asserts for n1 = n2
with optional accuracy.
suite:assertequalsnumber(emassage: string; For not equal
assertequalsnumber
n1, n2, accuracy: Number) numbers, the test fails
and sets the
errormessage.
Creates a new sub test
createtestsuite subsuite = suite:createtestsuite(name: string) suite for the current
suite.
The test fails. The
parameter specifies
fails suite:fails(emassage: string)
the error message of
the failed test.
Finishes the current
test. This call
finishtest suite:finishtest()
calculates the duration
of the test.
Saves the test result
into specified file. The
savetocsv suite:savetocsv(file: string)
format is a comma
separated format.
Saves the test result
into specified file. The
savetojunitxml suite:savetojunitxml(file: string)
format is a junit
convenient xml format.

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.

2.15.4.2 Method Overview

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

Loads an image from an open


loadimage Zipobject:loadimage(filename: String) ZIP file. Returns an instance of
Image
Loads a json file from an open
loadjson Zipobject:loadjson(filename: String) ZIP file. Returns an instance of
Json file Object
Loads a text file from an open
loadtextfile Zipobject:loadtextfile(filename: String) ZIP file. Returns an instance of
Text File Object
Loads a XML file from an open
loadxml Zipobject:loadxml(filename: String) ZIP file. Returns an instance of
XML file Object

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

Read/ Defines the angle where the


cutoff_radian Number part needs support structures
Write in radian
Defines the angle where the
cutoff_degree Write Number part needs support structures
in degree
Read/ Resulting distance to
distance_from_platform Number
Write platform

Read/ Defines freedom of rotations.


rotation_axis String Valid values are ‘arbitrary’,
Write ‘x’, ‘y’
Defines the minimal rotation
distance between to
smallest_distance_between_minima_degree Write Number calculated solutions. The
smaller the angle the more
solution will be calculated
Defines the minimal rotation
Read/ distance between to
smallest_distance_between_minima_radian Number calculated solutions. The
Write smaller the angle the more
solution will be calculated
Number of calculated
solutioncount Read Number
solution
Defines wherer the buttom
Read/ surfaces needs support or
support_bottom_surface Boolean
Write not. That influences the
support-area critiria.

96 / 107
Netfabb Lua Scripting API
Documentation
Reference.docx

2.15.5.2 Method Overview


Name Syntax Description
Returns the best
orientation for the
specified critiria. The
following criteria are
s = orienter:get_best_solution_for(criteria:
get_best_solution_for allowed: 'outbox_volume',
String);
'part_height',
'support_area'
,'support_volume' and
‘center_of_gravity_height’
Creates a matrix from a
solution json object. This
matrix = matrix can be applied by
get_matrix_from_solution orienter:get_matrix_from_solution(solution: a mesh object. The mesh
lua_json) is rotated around its
center of gravity to reflect
the best orientation.
Return the orientation
get_solution s = orienter:get_solution(Index: Number);
solution for specific index
Calculates part
search_orientation orienter:search_orientation();
orientations.
Calculates part
orientations and shows a
progress bar. Start and
orienter:search_orientation_with_progress end progress numbers
search_orientation_with_progress (start_progress: Number; end_progress: are optional percentage
Number); values. This is usefull to
show the progress-bar in
a specific range (e.g. 20%
to 40%)

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:

TLUAPartAnalysis analysis = mesh:createanalyzer ().

2.15.6.1 Properties
Read /
Property
Write
Type Description Analysis

Returns the average wall Wallthickness


averagewallthickness Read Number
thickness Analysis

Returns the number of Default


badedges Read Number
invalid edges Analysis

Returns the number of edges Default


boundaryedges Read Number
making up holes Analysis

Returns the total length of all Default


boundarylength Read Number
boundary edges 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

Returns true if no errors Center of


coganalysiswassuccessful Read Boolean occurred during the Gravity
calculation of the analysis Analysis

Returns true if no errors Default


defaultanalysiswassuccessful Read Boolean occurred during the Analysis
calculation of the analysis

Returns the entered Upskin


downskin angle threshold Downskin
downskinangle Read Number
between the z plane and the Analysis
triangle

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

Returns the number of Default


facecount Read Number
triangles Analysis

Returns the number of Default


flippedtrianglecount Read Number
flipped triangles Analysis

Default
holecount Read Number Returns the number of holes
Analysis

Returns true if the meshes Default


isorientable Read Boolean triangles can be flipped to Analysis
form a closed mesh

Returns the total area of the Default


mesharea Read Number
mesh’s trianles Analysis

Returns true if the mesh has Default


meshisclosed Read Boolean
no holes Analysis

Returns true if the mesh is Default


meshisok Read Boolean
orientable and closed Analysis

Returns the volume of the Default


closed mesh or 0 if the mesh Analysis
meshvolume Read Number
contains flipped triangles or
is open

Default
nodecoount Read Number Returns the number of nodes
Analysis

Returns the max_x of the Default


outboxmaxx Read Number
outbox (in mm) Analysis

Returns the max_y of the Default


outboxmaxy Read Number
outbox (in mm) Analysis

Returns the max_z of the Default


outboxmaxz Read Number
outbox (in mm) Analysis

Returns the min_x of the Default


outboxminx Read Number
outbox (in mm) Analysis

Returns the min_y of the Default


outboxminy Read Number
outbox (in mm) Analysis

Returns the min_z of the Default


outboxminz Read Number
outbox (in mm) Analysis

Returns the length of the Default


outboxsizex Read Number
outbox in x direction Analysis

Returns the length of the Default


outboxsizey Read Number
outbox in y direction Analysis

Returns the length of the Default


outboxsizez Read Number
outbox in x direction Analysis

Returns the area of the Shadow Area


shadowarea Read Number
mesh’s shadow at z = 0 Analysis

Returns true if no errors Shadow Area


shadowareaanalysiswassuccessful Read Boolean occurred during the Analysis
calculation of the analysis

99 / 107
Netfabb Lua Scripting API
Documentation
Reference.docx

Returns the angle used to Support


calculate support clusters Volume
supportangle Read Number
used as basis for the support Analysis
shells

Support
Returns the volume of the
supportvolume Read Number Volume
support shells
Analysis

Returns true if no errors Support


supportvolumeanalysiswassuccessful Read Boolean occurred during the Volume
calculation of the analysis Analysis

Returns 1 the test passed, 0 Wallthickness


testcriticaldistance Read Number
otherwise Analysis

Returns true if no errors Upskin


updownskinanalysiswassuccessful Read Boolean occurred during the Downskin
calculation of the analysis Analysis

Returns the entered upskin Upskin


upskinangle Read Number angle threshold between the Downskin
z plane and the triangle 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

Returns true if no errors Wallthickness


wallthicknessanalysiswassuccessful Read Boolean occurred during the Analysis
calculation of the analysis

Returns the area below the Wallthickness


wallthicknessareabelowthreshold Read Number wallthicknesscriticaldistance Analysis
threshold

Returns the number of Wallthickness


wallthicknessclustercount Read Number
detected clusters Analysis

Returns the entered failing Wallthickness


threshold in mm below which Analysis
wallthicknesscriticaldistance Read Number
the cluster’s area counts
towards the failed area

Returns the entered Wallthickness


percentage threshold of the Analysis
wallthicknesscriticalsurface Read Number
surface below which the test
fails

Returns the area of the Wallthickness


wallthicknesslargestclusterarea Read Number
largest cluster Analysis

2.15.6.2 Method Overview

Name Syntax Description


Runs a default analysis on
createdefaultanalysis partanalyser:createdefaultanalysis()
the given part
partanalyser: Runs a center of gravity
createcenterofgravityanalysis
createcenterofgravityanalysis() analysis on the given part

100 / 107
Netfabb Lua Scripting API
Documentation
Reference.docx

Runs a shadow area


createshadowareaanalysis partanalyser:createshadowareaanalysis()
analysis on the given part
Runs a shadow area
partanalyser:createsupportvolumeanalysis analysis on the given part
createsupportvolumeanalysis
(AAngle: number) AAngle: threshold used for
support cluster detection
Runs a wall thickness
analysis on the given part
ADistance: minimal passing
wall thickness
partanalyser:
AAreaPercentage: Area
createwallthicknessanalysis(ADistance,
createwallthicknessanalysis below minimal passing
AAreaPercentage: number, ACancelOnFail:
thickness still allowed to
boolean)
pass
ACancelOnFail: cancel if
test already failing without
waiting for end result
Runs a upskin downskin
analysis on the given part
AUpskinAngle: minimal
angle between triangle and
z plane to be counted as
upskin
ADownskinAngle: minimal
partanalyser:
angle between triangle and
createupskindownskinanalysis(AUpskinAng
createupskindownskinanalysis z plane to be counted as
le, ADownskinAngle, AMinAreaSize:
downskin
number, AFilterSmallTriangles: boolean)
AMinAreaSize: minimal area
a cluster needs to have to
count towards the upskin or
downskin
AFilterSmallTriangles: flag
to exclude very small
triangles

2.15.7 Primitive List

[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.7.2 Method Overview

Name Syntax Description


Creates a primitive-object by
createprimitive List:createprimitive(name: string)
identifier
Creates a primitive-object by
createprimitivebyindex List:createprimitivebyindex(index: number)
index
101 / 107
Netfabb Lua Scripting API
Documentation
Reference.docx

Get name (identifier) of


getname List:getname(index: number)
primitive at given index

2.15.8 Primitive Object


[Desktop Automation]
This object is used for creating meshes.

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.

2.15.8.2 Method Overview

Name Syntax Description


Generates and returns a mesh
Generatemesh Primitive:generatemesh()
object.
Get setting-name at given
Getsettingname Primitive:getsettingname(index: number)
index
Get value of setting at given
Getsettingvalue Primitive:getsettingvalue(index: number)
index
Primitive:setsettingvalue(index: number; value Set value of setting at given
Setsettingvalue
number|string) index
Primitive:setsettingvaluebyname(key: string; Set the value of a setting with
setsettingvaluebyname
value: number|string) the given name

2.16 3S Script Objects


[3S]

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.1.2 Method Overview


Name Syntax Description
Executes script, no return
executescript structure:executescript(name: string);
value
findcell Cell:LUABaseCell = structure:findcell(name:string);
Volumedata:LUAVolumeData =
findvolumedata
structure:findvolumedata(name:string);
Surface: LUASurfaceData =
findsurfacedata
structure:findsurfacedata(“surface”);
getcell Cell:LUABaseCell structure:getcell(index:number);
Surfacedata: LUASurfaceData =
getsurfacedata
structure:getsurfacedata(index:Number);
Volumedata: LUAVolumeData =
getvolumedata
structure:getvolumedata(index:Number);

2.16.2 LUAVolume Data

Commands for the LUAVolume class

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.2.2 Method Overview


Name Syntax Description
Group: LUAVolumeDataGroup =
addgroup
volumedata:addgroup(name:String);
Part: LUAVolumeDataFragment =
addmeshtoraster
volumedata:addmeshtoraster();
Volume: LUAVolumeDataFragment =
volumedata:addsurfacedata(surfacefragment:
addsurfacedata
SurfaceFragment, [xyoffset:Number,
zoffset:Number]);
cleanup volumedata:cleanup(); No return value
Part: LUAVolumeDataFragment =
findfragment
volumedata:findfragment(name:String);
Group: LUAVolumeDataGroup =
findgroup
volumedata:findgroup(name:String);
Part: LUAVolumeDataFragment =
getfragment
volumedata:getfragment(name:String);
Group: LUAVolumeDataGroup =
getgroup
volumedata:getgroup(index:Number);
Part: LUAVolumeDataFragment =
merge volumedata:merge(part1: LUAVolumeDataGroup|
LUAVolumeDataFragment, [...]);
reset volumedata:reset(); No return value
Part: LUAVolumeDataFragment =
resize volumedata:resize(plusx, plusy, plusz, minusx,
minusy, minusz:all Number);

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;

2.16.3.2 Method Overview


Name Syntax Description
part1: LUAVolumeDataFragment =
part2:createexpansion(minusx:number,
createexpansion
minuxy:number, minuxz:number, plusx:number,
plusy:number, plusz:number, celloverride:boolean);
Skin: LUAVolumeDataFragment =
part:createhull(minusx:number, minuxy:number,
createhull
minuxz:number, plusx:number, plusy:number,
plusz:number);

104 / 107
Netfabb Lua Scripting API
Documentation
Reference.docx

part1: LUAVolumeDataFragment = projection(number)


part1:createprojection(type:number, 1 = +x , 2 = -x ,
createprojection celloverwrite:boolean); 3 = +y , 4 = -y
5 = +z ,6 = -z
Blocks: LUAVolumeDataFragment =
part:divideblocks(blocksizex:Number,
blocksizey:Number, blocksizez:Number, translationx:
divideblocks Number, translation: Number, translationz:Number,
fillblocks:boolean);

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

name read / write string


“volume1”=volume.name;
volume.name=”volume1”;
subgroupcount read only number Volume.subgroupcount

2.16.4.2 Method Overview


Name Syntax Description
Group: LUAVolumeDataGroup =
addgroup
volumedata:addgroupname:String);
Fragment: LUAVolumeDataFragment =
findfragment
volumedata:findfragment(name:string);
Group: LUAVolumeDataGroup =
findgroup
volumedata:findgroup(name:string);
Fragment: LUAVolumeDataFragment =
getfragment
volumedata:getfragment(index:number);
Group: LUAVolumeDataGroup =
getgroup
volumedata:getgroup(number:index);
Ret:Boolean = part:movetogroup(group1:
movetogroup
LUAVolumeDataGroup);

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.5.2 Method Overview


Name Syntax Description
Group: LUASurfaceDataGroup =
addgroup
surfacedata:addgroup(group1:String);
Surface: LUASurfaceDataFragment =
addmesh
surfacedata:addmesh();
part=surfacedata:classifydownsides(angle:Number,
classifydownsides minsizearea:Number, samplecomponents: boolean);
part=surfacedata:classifyupsides(angle:Number,
classifyupsides minsizearea:Number, samplecomponents: boolean);
cleanup surfacedata:cleanup();
Surface: LUASurfaceDataFragment =
findfragment
surfacedata:findfragment(“surface1:String”);
Group: LUASurfaceDataGroup =
findgroup
surfacedata:findgroup(“group1”:String);
Surface: LUASurfaceDataFragment =
getfragment
surfacedata:getfragment(index:Number);
Group: LUASurfaceDataGroup =
getgroup
surfacedata:getgroup(index:Number);
reset surfacedata:reset();

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;

name read / write string ”Surface1”=surface.name;


surface.name=”Surface1”;

2.16.6.2 Method Overview


Name Syntax Description
Ret:Boolean = surface:movetogroup(group1:
movetogroup LUASurfaceDataGroup);

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

name read / write string


“surface1”=surface.name;
surface.name=”surface1”;
subgroupcount read only number surface.subgroupcount

2.16.7.2 Method Overview


Name Syntax Description
Group: LUASurfaceDataGroup =
addgroup
surfacedata:addgroup(“group1”:string);
Surface: LUASurfaceDataFragment =
findfragment
surfacedata:findfragment(“fragment”:String);
Group: LUASurfaceDataGroup =
findgroup
surfacedata:findgroup(“group1”:String);
Surface: LUASurfaceDataFragment =
getfragment
surfacedata:getfragment(index:Number);
Group: LUASurfaceDataGroup =
getgroup
surfacedata:getgroup(index:Number);
Ret:Boolean = surface:movetogroup(group1:
movetogroup LUASurfaceDataGroup);

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

2.16.8.2 Method Overview

None.

107 / 107

You might also like