Good Day,
I have a macro which will incrementally number selected toolpaths, however, I'd like to number selected toolpaths as such 1a 1b 1c etc. or 2a 2b 2c etc.
Just a wee snippet of my incremental numbering macro.
IF $powermill.Status.MultipleSelection.First OR $powermill.Status.MultipleSelection.Total == 0 {
reset localvars
string $new_name = ""
STRING Strategy = 'null'
DIALOGS MESSAGE OFF
DIALOGS ERROR OFF
GRAPHICS LOCK
//starting number
INT StartNumber = INPUT "Start at #?"
INT start = $StartNumber
STRING start1 = $StartNumber
INT i = $start1
//set text to replace and new text
STRING oldText = "."
STRING newText = ","
}
FOREACH $tp IN explorer_selected_entities() {
If $tp.Strategy == 'drill' AND $tp.drill.type == 'single_peck' {
RENAME TOOLPATH $tp.Name ${ i + tp.Strategy + tp.drill.type + tp.Tool.name + "-T" + tp.tool.number }
$i = $i + 1
}
Solved! Go to Solution.
Solved by icse. Go to Solution.
Solved by icse. Go to Solution.
string list $abc = {'a','b','c','d','e','f','g','h','i','j','k','l','m','n','o','p','q','r','s','t','u','v','w','x','y','z'}
int $index = 0
foreach $tp in $explorer_selected_entities() {
string $newname = $tp.Name + $abc[$index]
if entity_exists('toolpath',$newname) {
$newname = new_entity_name('toolpath',$newname)
}
rename toolpath ${tp.Name} ${newname}
$index = $index + 1
if $index > 25 {
$index = 0
}
}
@icse ,
Thanks, that worked great.
Here is my code.
I have a pop up asking what number to start at, how do I modify to also ask which letter to start from als
IF $powermill.Status.MultipleSelection.First OR $powermill.Status.MultipleSelection.Total == 0 {
reset localvars
string $newname = ""
STRING Strategy = 'null'
DIALOGS MESSAGE OFF
DIALOGS ERROR OFF
GRAPHICS LOCK
//starting number
INT StartNumber = INPUT "Start at #?"
INT start = $StartNumber
STRING start1 = $StartNumber
INT i = $start1
$tp.name = ""
string list $abc = {'a','b','c','d','e','f','g','h','i','j','k','l','m','n','o','p','q','r','s','t','u','v','w','x','y','z'}
int $index = 0
foreach $tp in $explorer_selected_entities() {
string $newname = $i + $abc[$index] + '-' + $tp.Strategy + $tp.Tool.name + "XY" + $tp.Thickness + "Z" + $tp.axial_thickness + "-T" + $tp.tool.number
if entity_exists('toolpath',$newname) {
$newname = new_entity_name('toolpath')
}
rename toolpath ${tp.Name} ${newname}
STRING $newName1 = replace($newname, ".0" , "" )
rename toolpath $newname $newName1
$index = $index + 1
if $index > 25 {
$index = 0
}
}
DEACTIVATE Toolpath
DEACTIVATE TOOL
UNDRAW TOOL ALL
DIALOGS MESSAGE ON
DIALOGS ERROR ON
GRAPHICS UNLOCK
o?
I've tried a few things with no success
you could do something like this:
IF $powermill.Status.MultipleSelection.First OR $powermill.Status.MultipleSelection.Total == 0 {
reset localvars
string $newname = ""
STRING Strategy = 'null'
DIALOGS MESSAGE OFF
DIALOGS ERROR OFF
GRAPHICS LOCK
//starting number
INT StartNumber = INPUT "Start at #?"
INT start = $StartNumber
STRING start1 = $StartNumber
INT i = $start1
$tp.name = ""
string list $abc = {'a','b','c','d','e','f','g','h','i','j','k','l','m','n','o','p','q','r','s','t','u','v','w','x','y','z'}
int $index = input choice $abc 'select start letter'
foreach $tp in $explorer_selected_entities() {
string $newname = $i + $abc[$index] + '-' + $tp.Strategy + $tp.Tool.name + "XY" + $tp.Thickness + "Z" + $tp.axial_thickness + "-T" + $tp.tool.number
if entity_exists('toolpath',$newname) {
$newname = new_entity_name('toolpath')
}
rename toolpath ${tp.Name} ${newname}
STRING $newName1 = replace($newname, ".0" , "" )
rename toolpath $newname $newName1
$index = $index + 1
if $index > 25 {
$index = 0
}
}
DEACTIVATE Toolpath
DEACTIVATE TOOL
UNDRAW TOOL ALL
DIALOGS MESSAGE ON
DIALOGS ERROR ON
GRAPHICS UNLOCK
or better :
IF $powermill.Status.MultipleSelection.First OR $powermill.Status.MultipleSelection.Total == 0 {
reset localvars
string $newname = ""
STRING Strategy = 'null'
DIALOGS MESSAGE OFF
DIALOGS ERROR OFF
GRAPHICS LOCK
//starting number
INT StartNumber = INPUT "Start at #?"
INT start = $StartNumber
STRING start1 = $StartNumber
INT i = $start1
$tp.name = ""
string list $abc = {'a','b','c','d','e','f','g','h','i','j','k','l','m','n','o','p','q','r','s','t','u','v','w','x','y','z'}
string $userInput = input 'start char'
int $index = 0
if member($abc, $userInput) {
$index = get_index($abc, $userInput)
}
foreach $tp in $explorer_selected_entities() {
string $newname = $i + $abc[$index] + '-' + $tp.Strategy + $tp.Tool.name + "XY" + $tp.Thickness + "Z" + $tp.axial_thickness + "-T" + $tp.tool.number
if entity_exists('toolpath',$newname) {
$newname = new_entity_name('toolpath')
}
rename toolpath ${tp.Name} ${newname}
STRING $newName1 = replace($newname, ".0" , "" )
rename toolpath $newname $newName1
$index = $index + 1
if $index > 25 {
$index = 0
}
}
DEACTIVATE Toolpath
DEACTIVATE TOOL
UNDRAW TOOL ALL
DIALOGS MESSAGE ON
DIALOGS ERROR ON
GRAPHICS UNLOCK
IF $powermill.Status.MultipleSelection.First OR $powermill.Status.MultipleSelection.Total == 0 {
reset localvars
string $newname = ""
STRING Strategy = 'null'
DIALOGS MESSAGE OFF
DIALOGS ERROR OFF
GRAPHICS LOCK
//starting number
INT StartNumber = INPUT "Start at #?"
INT start = $StartNumber
STRING start1 = $StartNumber
INT i = $start1
$tp.name = ""
string list $abc = {'a','b','c','d','e','f','g','h','i','j','k','l','m','n','o','p','q','r','s','t','u','v','w','x','y','z'}
string $userInput = 'a'
$userInput = input 'start char'
int $index = 0
if member($abc, $userInput) {
$index = get_index($abc, $userInput)
}
foreach $tp in $explorer_selected_entities() {
string $newname = $i + $abc[$index] + '-' + $tp.Strategy + $tp.Tool.name + "XY" + $tp.Thickness + "Z" + $tp.axial_thickness + "-T" + $tp.tool.number
if entity_exists('toolpath',$newname) {
$newname = new_entity_name('toolpath')
}
rename toolpath ${tp.Name} ${newname}
STRING $newName1 = replace($newname, ".0" , "" )
rename toolpath $newname $newName1
$index = $index + 1
if $index > 25 {
$index = 0
}
}
DEACTIVATE Toolpath
DEACTIVATE TOOL
UNDRAW TOOL ALL
DIALOGS MESSAGE ON
DIALOGS ERROR ON
GRAPHICS UNLOCK
Can't find what you're looking for? Ask the community or share your knowledge.