Message 1 of 6
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report
When I add multiple toolpaths with different names and different tool diameters with a macro it doesn't order the toolpaths as they were in the toolpath tree.
There is a command in the NC program to order toolpaths by tool number, tool diameter or workplane but it doesn't work. So I am trying to make a macro that reorders all the toolpaths in the active nc program by largest tool diameter, this is what I have so far but it errors on line 15 and 26
// Get the name of the active NC program
STRING ncProg = entity('ncprogram','').name
// Get the toolpaths in the active NC program
STRING LIST ncP_toolpaths = extract(entity('ncprogram', ncProg).nctoolpath, 'Name')
// Create a list to store the tool diameters
REAL LIST tool_diameters = {}
FOREACH tp IN ncP_toolpaths {
// Get the tool entity associated with the toolpath
ENTITY tool = entity('toolpath', tp).tool
// Get the diameter of the tool and add it to the list
Error on this ---> tool_diameters = append(tool_diameters, tool.diameter)
}
// Sort the toolpaths by tool diameter in a new list
STRING LIST sorted_toolpaths = sort(ncP_toolpaths, tool_diameters)
// Initialize a counter for the new order
INT new_order = 0
FOREACH tp IN sorted_toolpaths {
// Reorder the toolpath in the NC program
Will Error on this line ---> EDIT NCPROGRAM ncProg ORDER ITEM find(ncP_toolpaths, tp) AFTER ITEM new_order
// Increment the counter
new_order = new_order + 1
}
Here is the before and after if I do it manually
Intel Core i9 13900KF CPU
128 GB Kingston Beast DDR4 SDRAM
PNY RTX A2000 6GB Video Card
WD 1 TB SSD Hard Drive
Windows 11 Pro
Solved! Go to Solution.