Lua API: Generating automatically operations based on layer names

Hi everyone,

I’m working on an automatic interface between Rhino 3D and SheetCam.
In Rhino, a Python script analyses 3D solids and extracts 2D geometry, creating layers that already include tool number, operation type (CutInside, CutOutside, NoOffset, Pocket, Drilling) and cut depth.

Example layer names
(Syntax: Materialnumber_OperationType_Toolnumber_Diameter_Cuttingdepth):

MAT1_CI_T3_D2MM_D10mm 
==> Material1_CutInside_ToolNr3_Diameter2MM_Cuttingdepth10mm...
MAT1_POCKET_T6_D6MM_D5mm
MAT1_CO_T3_D3MM_D10mm

My goal is to use a Lua plugin in SheetCam that reads these layers and automatically creates matching operations based on the tool number and cutting depth embedded in the layer name.
To do this I need access via the Lua API to:

  • the layer list (Layers, GetLayers, etc.)

  • the tool table (ToolTable, GetToolTable, etc.)

  • the operations list (OperationList, GetOperations, etc.)

However, in SheetCam TNG 7.0.2, none of the usual functions (sc.scApp():GetLayers(), sc.scApp():GetToolTable(), …) seem to return valid objects.
It looks like the object names or API structure might be different in this version.

Could anyone please tell me:

  • how to correctly access the Layer, Tool and Operation objects in 7.0.2, or

  • if there are global variables/functions that provide them?

Once I get this working, I’ll gladly share the finished plugin here, so others can automate their own layer-based CAM workflows.

Many thanks!

Jan

Creating tools and operations through the Lua API is possible but it is quite involved and I have to admit not very well documented.

I think the simplest way would be to create a job file based on the desired cut parameters and tools. If you create an example job then save it as a job template you can open the file in a text editor and see how it’s laid out. To transfer the geometry save it as a dxf,svg or hpgl file. This way most of the work is done in your Python script. To load the files into SheetCam just load your created job file and drawing. You could make that a one-click process using the quick load plugin or you could create a simple Lua plugin to load the job file then the drawing.

Hi Les,

I’m currently writing a Python script that automatically generates SheetCam job templates based on DXF layer names. You previously suggested that it’s better to create job files externally rather than using Lua directly in SheetCam — and that approach works great so far.

Right now, I’m focusing on defining operations in the generated job files. For that, I’d like to know if there is any documentation describing all possible operation parameters and their meanings.

In particular, it would be very helpful to know:

  1. Which parameters are mandatory when defining an operation.

  2. Which parameters are optional and will automatically be inherited from the tool table if not defined.

Here’s an example of a section taken from a job file created by SheetCam. I’ve added a few questions as comments about parameters that aren’t self-explanatory:

[Part 0/Operation0]  # Determines the order in which operations are listed?
Angle threshold=0.534070751110265  # What is this parameter used for?  
BelongsTo=-1  # What is this parameter used for?  
Clean up exit ramp=1
Climb cut=0
CodeSnip=-1
Comment=
Contour method=1  # (0 => None, 1 => Outside, 2 => Inside?)  
Coolant=0
Cut depth=20 
Cut direction=0.5  # What is this parameter used for?  
Cutting rules=0  # What is this parameter used for?  
Depth per pass=0.5
Enabled=
Feed rate=450
Finish allowance=0
Hole Size=0
ID=0  # What is this parameter used for?  
Layer=MAT_1_RKA_WZ1_D0_8MM_T20mm
Lead in=15  # What is this parameter used for?  
Lead in type=0
Lead out=0
Lead out type=0
Leadins on open paths=0
Length=3  # What is this parameter used for?  
Name=Outside Offset, {Layer not found}, T1: Fraeser, 0.8 mm, 1 mm Deep
Name_Edited=0  # What is this parameter used for?  
Offset open paths=0
Optimisation=1  # What is this parameter used for?  
Overcut corners=0
Path rules=  # What is this parameter used for?  
Plunge rate=200
Ramp Angle=0.523598775598299
Reverse open paths=0
Spindle speed=38000
Square corners=0
Start depth=0
Start position=0
Thickness=0.5  # What is this parameter used for?  
Tool=1
Type=ContourOperation

If there’s any reference list, internal notes, or even partial documentation available for these operation parameters, that would be a huge help in making the generated templates more reliable.

Thanks a lot for your time and for the great support as always!

Best regards,

Jan

Hi Les and any other interested,

I’d like to share my progress on the workflow I’ve been developing (with ChatGPT ;-)) that automatically creates complete SheetCam job files directly from Rhino.
The goal was to fully standardize and speed up our CNC preparation process.

Here’s a short overview of how it works:

  • In Rhino, machining geometry is organized on layers following a defined naming convention (e.g. MAT_1_RKA_6MM_T5MM). The generation of the layernames and is made via python, and the geometry can be picked semiautomatically from 3d Files.

  • A Python script exports these layers as a CSV and JSON mapping file, including tool assignments, material thickness, and cutting depths.

  • A second script then uses this data to automatically generate a SheetCam job template (.jobt) containing all tools, pockets, drilling, and contour operations.

  • The operation order is automatically optimized (Drilling → Engraving → Pocketing → Inside → Outside).

  • All feed rates, step-downs, spindle speeds, etc. are taken directly from the selected .tools file.

The result:
A fully prepared SheetCam setup that can be loaded and posted instantly — no manual operation setup required.

Here’s a short screencapture showing the workflow:

I thought this might be interesting for anyone using Rhino as a geometry source and looking to automate SheetCam job creation.
Feedback, ideas, or suggestions for improvement are very welcome. I`m willing to share it with the community.

Best regards,

Jan

1 Like