Share

LUATray

[Desktop Automation]

A fabbproject can contain more than one tray. The trays are obtained with the method fabbproject:gettray, the number of trays with the member fabbproject.traycount.

Properties

Property Read/write Type Description
errormessage Read String Error message for tray actions, currently only used by the scanline packer
filling_degree Read number Returns the fraction in percent to which the current tray is solid by means of part volume. Parts partly or fully outside the tray are not included in the calculation. The filling degree is only calculated to the maximum Z-value of any part in the tray, not the full vertical size of the buildroom itself.
filling_height Read number Returns the maximum height of parts loaded in the tray, only for packed parts
filling_height_all Read number Returns the maximum height of all parts 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
root Read/write Complex main LUAMeshGroup of the tray through which all parts and subgroups are accessed
workspacetype Read string The workspace definition UUID for the current tray. See workspaces.xml in the Netfabb installation folder for reference. All tray instances loaded from the same My Machines record, or loaded from different My Machines records created from the same make and model, have the same workspace definition UUID. If the tray does not belong to any workspace with an engine (with "process parameters"), but is just a plain buildroom, this string is empty.

Back to top

Methods

Name Syntax Description
callworkspace tray:callworkspace(command:String, parameter:String) Calls the function executecustomevent(command:String, parameter:String) in the Netfabb engine that owns the current tray. The parameters of callworkspace are passed on to the Lua callback. The engine must already be loaded to call it. To find the correct tray of the engine, iterate over the trays and check for tray.workspacetype. The UUID of a workspace is stored in the uuid attribute of the workspacedefinition tags in the workspaces.xml file located in the Netfabb installation folder.
checkforcollisions Result = checkforcollisions(RasterSize:Number) Checks the tray for collisions. Returns an instance of LUACollisionResult (See LUACollisionResult.)
createpacker Packer = tray:createpacker(packer_id:Number) Create an object of type LUAPacker using the implementation defined in packer_id. See constants packingid_null, packingid_outbox, packingid_2d, packingid_3d, packingid_montecarlo, packingid_physics for the correct id. Note that creating a packer takes a snapshot of the tray with its current parts to work on. Any addition or removal of parts after packer creation but before calling the packer's pack() method may lead to unexpected effects.
exportforsimulation exportforsimulation(file:string; material:string; laser_spot_mm:number; unify_support:Boolean; workspace_uuid:string; workspace_name:string; laser_count:number) Generate 3MF file that contains all parts of the tray with attached support and hulled support for process simulation.
getuuid uuid = tray:getuuid() Retrieve the UUID of the tray
setclipplane tray:setclipplane(axis:Number, halfspace:Number, space:Number, distance:Number, show_contour:Boolean, alpha:Number) Activates the clipping plane view just like the UI does. For the parameters halfspace and space there are pre-defined constants available. (see System object constants or below) alpha takes a number from 0.0 for full transparency to 0.75 for semi-opacity.
updatetodesktop tray:updatetodesktop() Refreshes tree and 3D view after changes such as packing to make sure that display is up to date

Back to top

Clip plane constants

Use of the constant or the literal value is equivalent.

Parameter Constant Literal Meaning
halfspace hsNone 0 Neither side of a clip plane is rendered visible.
halfspace hsBoth 1 Both sides of a clip plane are rendered visible.
halfspace hsPositive 2 The far side of the clip plane is rendered invisible.
halfspace hsNegative 3 The near side of the clip plane is rendered invisible.
space csModel 0 The Lua clip plane axis controls adhere to the model's local coordinate system. This can easily be different from the buildroom's when the model was rotated at some point and has not had its transformation matrix permanently applied yet. It can also be different for every part present. Each and every part gets its own clip plane according to its own coordinate system.
space csWorld 1 The Lua clip plane axis controls adhere to the build room's coordinate system and apply globally to all parts present in this manner, where intersected with.
space csView 2 The Lua clip plane axis controls adhere to the coordinate system of the camera's view regardless of its orientation and view direction with respect to the buildroom.

Back to top

Packer ID constants

Name Type Literal value Description
packingid_null Number 0 Constant for the null packer, see tray:createpacker
packingid_outbox Number 1 Constant for the bounding box packer, see tray:createpacker
packingid_2d Number 2 Constant for the 2d packer, see tray:createpacker
packingid_3d Number 3 Constant for the 3d packer, see tray:createpacker
packingid_montecarlo Number 4 Constant for the monte carlo packer, see tray:createpacker
packingid_physics Number 5 Constant for the gravity packer, see tray:createpacker
packingid_trueshape Number 6 Constant for the True shape packer, see tray:createpacker

Back to top

Was this information helpful?