LUATrayMesh
[Desktop Automation]
The LUATrayMesh
object contains the data of parts in a fabbproject's buildroom, listed in the project tree, i.e. an instance of LUAMesh
(see Mesh) and its position, scale and rotation. Traditionally, these are referred to as "mesh", but they are more than purely a triangle net and can also be tessellated parametric, or CAD parts. To access the triangle net and use LUAMesh properties use the mesh
property.
Properties
Property | Read/write | Type | Description |
---|---|---|---|
area | read | Number | Get the area of the traymesh (including transformation, in mm²) |
color | read/write | String | Set or get the display color as a string in hexadecimal. Note: When you set a new color, make sure to run application:triggerdesktopevent("updateparts") some time after, otherwise the display color change remains unreflected in the actual UI on screen. |
fileorigin | read | String | If the part was imported from a file, or derived from a part that was imported from a file, this property contains the full file system path. |
id | read | Number | Internal ID of the traymesh. This is not the part number as displayed in the small box next to the part name in the project tree. |
isclosed | read | Boolean | Whether the triangle net of this traymesh is closed |
matrix | read | LUAMatrix4f | Get the transformation matrix of the traymesh |
mesh | read | LUAMesh | Get the triangle net of the traymesh. Returns a new LUAMesh object. |
hassupport | read | Boolean | Returns true if the traymesh has attached support, false otherwise |
![]() |
read/write | Boolean | Locks part position for True Shape packing |
name | Read/write | String | Name of the traymesh as it appears in the project tree |
outbox | read | Outbox | Bounding box object |
outboxbasearea | read | Number | Get the bounding box base area of the traymesh (including transformation, in mm²) |
outboxheight | read | Number | Get the bounding box height of the traymesh (including transformation, in mm) |
outboxvolume | read | Number | Get the bounding box volume of the traymesh (including transformation, in mm³) |
parent | Read/write | LUAMeshGroup | Get or set the group the traymesh belongs to |
selected | read/write | Boolean | Sets or returns selection state of the traymesh |
support | read | LUAMesh | Get the triangle net of the attached support for that traymesh. Returns a new LUAMesh object. Operation fails if the traymesh does not have support. |
![]() |
read/write | Boolean | Sets visibility of supports. To update the display, use application:triggerdesktopevent("updateparts") . Note: This property currently has no equivalent switch in the Netfabb GUI. |
visible | read/write | Boolean | Visibility of the traymesh in the 3D view. Transparent display counts as visible, or true, but cannot be set through Lua, only read. |
volume | read | Number | Get the volume of the traymesh (including transformation, in mm³) |
uuid | read | String | UUID of the traymesh |
Methods
Name | Syntax | Description |
---|---|---|
assignsupport | mainmesh:assignsupport(supportmesh:LUAMesh; relativecoordinates:Boolean) | Assigns a triangle net as a support to a tray. When relativecoordinates is true, supportmesh is applied relative to mainmesh. When supportmesh and redativecoordinates are omitted, any existing support is detached from mainmesh. |
createsupportedmesh | traymesh:createsupportedmesh( mergepart:Boolean, mergeopensupport:Boolean, mergeclosedsupport:Boolean, openthickening:number) | Returns a supported traymesh. The merge… parameters determine which mesh type is included. The thickening parameter extrudes open support into solid, closed mesh. |
getpackingoption | Option = traymesh:getpackingoption(OptionIdentifier: String) | Get a packing option of the traymesh |
getuuid | Uuid = traymesh:getuuid() | Get the UUID of a traymesh |
rotate | traymesh:rotate(axis_x, axis_y, axis_z, angle, cen_x, cen_y, cen_z: Number) | Rotate a traymesh by an angle around a selected axis around a given center against the platform coordinates. The axis is "selected" by a positive, non-zero number. Rotate angle is in radians. The center is optional. If no center is given, the center of the traymesh part's bounding box is used. |
saveto3ds | traymesh:saveto3ds(filename:String) | Export the traymesh including all transformations to 3DS |
saveto3mf | traymesh:saveto3mf(filename:String) | Export the traymesh including all transformations to 3MF |
savetoamf | traymesh:savetoamf(filename:String) | Export the traymesh including all transformations to AMF |
savetoasciistl | traymesh:savetoasciistl(filename: String) | Export the traymesh including all transformations to ASCII STL |
savetogts | traymesh:savetogts(filename:String) | Export the traymesh including all transformations to GTS |
savetoncm | traymesh:savetoncm(filename:String) | Export the traymesh including all transformations to NCM |
savetoobj | traymesh:savetoobj(filename:String) | Export the traymesh including all transformations to OBJ |
savetoply | traymesh:savetoply(filename:String) | Export the traymesh including all transformations to PLY |
savetostl | traymesh:savetostl(filename:String) | Export the traymesh including all transformations to STL |
savetovrml | traymesh:savetovrml(filename:String) | Export the traymesh including all transformations to VRML |
savetox3d | traymesh:savetox3d(filename:String) | Export the traymesh including all transformations to X3D |
savetozpr | traymesh:savetozpr(filename:String) | Export the traymesh including all transformations to ZPR |
scale | traymesh:scale(x, y, z:Number) | Scale a traymesh |
setmatrix | traymesh:setmatrix(matrix:LUAMatrix4) | Overwrite the transformation matrix of the traymesh with a new one |
setpackingoption | traymesh:setpackingoption(option:String; value:String) | Add a packing option to the traymesh |
shellasmesh | Newmesh = traymesh:shellasmesh(shellnumber:number) | Extract a shell as new LUAMesh object. Same as LUAMeshObject.shellasmesh but takes the transformation matrix into account. See LUATrayMesh.mesh.shellcount for the number of meshes. |
translate | traymesh:translate(x, y, z: Number) | Translate a traymesh |
Packing options
Read/Write parameters
- priority:number (, 1-10)
- restriction:string ("locked", "norestriction")
- rotate:string ("arbitrary", "zaxis", "forbidden")
These options must be set before packing. All packers respect priority
and restriction
. Rotate
is only respected by Monte Carlo packer.
Read-only parameters
- state:
"packed" – The part was packed 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 packing option "start_from_current_positions" was active.
"excluded" – The part was excluded from the packing process by the user.
"ignored" – The part was ignored by packing (for instance, because its mesh was empty or invisible).
"indefinite" – The packing process has not been started yet or was aborted.
Example: Reset packing options for all parts
This script accelerates resetting all packing options for all parts present on the platform currently selected in the project tree, something that could take many clicks in the respective GUI dialog.
local meshesAll = {}
local root = tray.root
insertMeshesIntoTable(root, meshesAll)
for i, traymesh in pairs(meshesAll) do
traymesh:setpackingoption('restriction', 'norestriction')
end