After much trial and error, and a visit to the old Delcam forum, I've got something that should work for you. It is a little persnickety, but I think it'll do the job. This works for the ACTIVE nc program only. I'm sure you can mod it to do all your nc programs should you choose.
Here is where it is goofy: When you create an NC program and add one toolpath to it, that becomes 'item 0'. The next one is 'item 1' and so on. Let's say you have 10 toolpaths in your NC program, and now you want to add another one (item 10 - remembering they start at 0) between item 3 and item 4. The one you add between 3 and 4 stays item 10. Powermill does not renumber the toolpaths in the NC program, they stay what they are when first added to the NC program. This messes up the counter as it increases by 1 and 1000. Just make sure your toolpaths are ordered how you want them when you add them to your nc program
INT i = 0
INT item_num = 0
INT comp_num = 0
FOREACH tp IN folder ('NCProgram') {
STRING LIST tpnames = extract(entity('ncprogram','').nctoolpath, 'Name')
FOREACH toolpath IN $tpnames {
INT has_comp = position(tpnames[$i], "W/COMP")
IF $has_comp > 0 {
IF !is_empty(components(entity('ncprogram',''))) {
IF components(entity('ncprogram',''))[0].RootType == 'nctoolpath' {
EDIT NCPROGRAM ; ITEM $item_num COMPONENT $comp_num COMP_CODE RIGHT
}
}
}
$i = $i + 1
$item_num = $item_num + 1
$comp_num = $comp_num + 1000
}
}
As far as the colored tick, I dont know why it wouldn't be blue if all your toolpaths are blue (or purple. I think it's purple, but whatever). pmill sees something it's unsure of. maybe it's a 2018 bug - who knows...
Let me know how this works for you
the numbers never lie