LUA Scripting to Slice Part in Multiple Stacks

LUA Scripting to Slice Part in Multiple Stacks

jacobmcc
Explorer Explorer
1,007 Views
4 Replies
Message 1 of 5

LUA Scripting to Slice Part in Multiple Stacks

jacobmcc
Explorer
Explorer

I'm trying to use Netfabb to set up a build for a single part where the laser power will change about 45 times at equal layer intervals throughout the part. For example, the first 20 layers will be at 250 watts, the next 20 at 300, the next 20 at 275, etc. I think there should be a way to use a LUA script to import a part, slice it into some number of slice stacks, and apply parameters to each stack, but I can't find a way to do it within the documentation.


I'm able to use a script to import an STL file without issue, but I haven't managed to get the script to do any actual slicing. Below is the result of my current attempts after the importing of the part into a tray.

Any help is appreciated!

Thanks,

Jacob

 

for layer = 1, lumped_layers do
-- Create slice n
slices[layer] = slice:createoffset(layer)

-- Set variable laser power
slices[layer]:addproperty ('power', layer_powers[layer]);

-- Set constant properties
slices[layer]:addproperty('markspeed', 1000)
-- slices[layer]:addproperty()

-- Add to tree
system:addslicetotree (slices[layer]);
end

0 Likes
Accepted solutions (1)
1,008 Views
4 Replies
  • Lua
Replies (4)
Message 2 of 5

steffen_anders_adsk
Autodesk Support
Autodesk Support

Hello, @jacobmcc,

 

Welcome to the Netfabb forum!

 

You are trying to cross Lua scopes which is not supported.

 

Simply put, where you launch the script matters for what the script can access even if the classes and their properties and methods can be used regardless. Due to how Lua support is implemented in Netfabb,

  • you can have the 3D view active, run a script from the library that slices present geometry and exports the results to file system,
  • or you can have Slicing active, run a Lua script loaded from the file system that itself imports 3D geometry from the file system, slices it, and adds the results to the project tree,

but you cannot do both slicing from a 3D platform in the project tree and adding the results to the Slicing section in the tree in one script. You must split these actions and connect them in some other way, like going through the file system as an intermediary, or slicing manually by drag&drop.

 

Kind regards,

Steffen

Steffen Anders
Autodesk Netfabb team

Netfabb resources: Online help • System requirements • Knowledge base • Forums • Homepage • YouTube

How to get Netfabb Basic: Video • Help • Download

0 Likes
Message 3 of 5

jacobmcc
Explorer
Explorer

Steffen,

Thanks for the insight, that makes sense. If I load the part in manually, I should be able to slice it into multiple parts using a script in the slicing environment, correct? I can manually set start and end points for each slice stack if I'm not using a script, but I can't find documentation for that functionality in Lua scripts.

 

Thanks,
Jacob

0 Likes
Message 4 of 5

steffen_anders_adsk
Autodesk Support
Autodesk Support
Accepted solution

Jacob,

 

The equivalent to that would be the system method slicemesh() (https://help.autodesk.com/view/NETF/2025/ENU/?guid=NETF_LuaApiRef_lua_api_ref_objects_system_slicing...) which expects a part (a LUATrayMesh object) and a Z range.

 

Just remember that you can't put the resulting slice stacks back into the project tree within the same script.

 

Best regards,

Steffen

Steffen Anders
Autodesk Netfabb team

Netfabb resources: Online help • System requirements • Knowledge base • Forums • Homepage • YouTube

How to get Netfabb Basic: Video • Help • Download

0 Likes
Message 5 of 5

jacobmcc
Explorer
Explorer

Great, thank you!