In this tutorial we will postprocess multiple cutorders to separate cnc files.
Start by creating an IGEMS API project.
The code is very simple so it is shown in full here.
public static void DLLMain()
{
API.RegisterCommand("MultiProcess", "Multi process", null, MultiProcess);
}
private static void MultiProcess()
{
var ents=API.Select("Select cutorders", (e) => API.EntityType(e) == "CUTORDER");
if(ents== null || ents.Count <= 0)
return;
for (int i = 0; i < ents.Count; i++)
API.Process(ents[i], "c:\\temp\\file_"+(i+1).ToString()+".cnc");
}
First we register the command in the DLLMain method.
In the MultiProcess method we start by selecting entities and set a filter to only select cutorders.
var ents=API.Select("Select cutorders", (e) => API.EntityType(e) == "CUTORDER");
Then we check if anything is selected.
if(ents== null || ents.Count <= 0)
return;
We loop the selected cutorders and call the API.Process function to create one CNC file for each cutorder.
for (int i = 0; i < ents.Count; i++)
API.Process(ents[i], "c:\\temp\\file_"+(i+1).ToString()+".cnc");
The name of the files will be file_#.cnc where # is a counter that is increased for each file.
In a real application the naming might need to be more advanced.