Community
PowerMill Forum
Welcome to Autodesk’s PowerMill Forums. Share your knowledge, ask questions, and explore popular PowerMill topics.
cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 

Macro Gurus Help Please

8 REPLIES 8
SOLVED
Reply
Message 1 of 9
markdiGXTYE
649 Views, 8 Replies

Macro Gurus Help Please

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:

Toolpath Name.PNG


Any help is appreciated!

8 REPLIES 8
Message 2 of 9
cfastNJWK6
in reply to: markdiGXTYE

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?

Message 3 of 9
markdiGXTYE
in reply to: cfastNJWK6

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.

Message 4 of 9
cfastNJWK6
in reply to: markdiGXTYE

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?

Message 5 of 9
markdiGXTYE
in reply to: cfastNJWK6

Yes, exactly. Unless there is an easier solution then pulling the folder name

Message 6 of 9
cfastNJWK6
in reply to: markdiGXTYE

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
	
	}
Message 7 of 9
markdiGXTYE
in reply to: cfastNJWK6

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?

Message 8 of 9
cfastNJWK6
in reply to: markdiGXTYE

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
	
	}
Message 9 of 9
markdiGXTYE
in reply to: cfastNJWK6

Cool, I have something that works. Thanks for the help!

Can't find what you're looking for? Ask the community or share your knowledge.

Post to forums  

Autodesk Design & Make Report