So I know there is a lot of information about toolpath renaming, but I require a specific naming scheme for my company's internal needs. I would like to pull the toolpath folder name and change the order of the characters, add "OP" and an A,B,C and so on if the toolpath has the same name. Here's a screenshot of what I'm looking for:
Any help is appreciated!
Solved! Go to Solution.
Solved by cfastNJWK6. Go to Solution.
Could you upload a picture of what the toolpath names look like before and how you would like them to look after the macro is ran?
I would like it to replace the toolpaths with what I have named to the way it looks on the screen snip. Plus I would like to run the macro off an active folder containing the toolpath folders. That's why I thought pulling the toolpath folder name might work out better, the toolpath folders will be named already.
You will have to be very consistent with how you name your folders for this type of macro to work. Right now it looks like you want to take the third character of the folder name and make that the first character of the toolpath name. Then add "OP". Then add the first character of the folder name. Then add the last 2 characters of the folder name. If that name already exists in the folder, add the next letter of the alphabet to the end of the toolpath name.
Does that logic seem correct?
Yes, exactly. Unless there is an easier solution then pulling the folder name
Something like this should be close to what you are looking for:
STRING LIST $Alphabet = {'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 LIST $TpFolders = get_folders('toolpath')
INT $TpFolder = INPUT CHOICE $TpFolders "Select Folder"
STRING $FolderPath = $TpFolders[0]
STRING $FolderName = $TpFolders[0]
$FolderName = replace($FolderName, "Toolpath\", "")
STRING $TpBaseName = ""
$TpBaseName = substring($FolderName, 2, 1) + "OP" + substring($FolderName, 0, 1) + substring($FolderName, 3, 2)
INT $counter = 0
FOREACH $tp IN folder($FolderPath) {
STRING $NewName = $TpBaseName
IF entity_exists(entity('Toolpath', $NewName)) {
$NewName = $NewName + $Alphabet[$counter]
$Counter = $Counter + 1
}
RENAME TOOLPATH $tp $NewName
}
Thanks for taking the time to write this out. It doesn't work exactly as expected, it seems to just read the top folder in the toolpath tree. Any way to use the name from the active folder?
The previous macro will use whatever folder you select in the drop-down menu. This one will use the active folder:
STRING LIST $Alphabet = {'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 LIST $TpFolders = get_folders('toolpath')
//INT $TpFolder = INPUT CHOICE $TpFolders "Select Folder"
INT $TpFolder = ACTIVE_FOLDER()
STRING $FolderPath = $TpFolders[0]
STRING $FolderName = $TpFolders[0]
$FolderName = replace($FolderName, "Toolpath\", "")
STRING $TpBaseName = ""
$TpBaseName = substring($FolderName, 2, 1) + "OP" + substring($FolderName, 0, 1) + substring($FolderName, 3, 2)
INT $counter = 0
FOREACH $tp IN folder($FolderPath) {
STRING $NewName = $TpBaseName
IF entity_exists(entity('Toolpath', $NewName)) {
$NewName = $NewName + $Alphabet[$counter]
$Counter = $Counter + 1
}
RENAME TOOLPATH $tp $NewName
}
Can't find what you're looking for? Ask the community or share your knowledge.