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: 

Edit Cutting Data Macro Help

11 REPLIES 11
SOLVED
Reply
Message 1 of 12
evo80
483 Views, 11 Replies

Edit Cutting Data Macro Help

IF $powermill.Status.MultipleSelection.First OR $powermill.Status.MultipleSelection.Total == 0 {
reset localvars
DIALOGS MESSAGE OFF
	DIALOGS ERROR OFF
	GRAPHICS LOCK
	
	if size(explorer_selected_entities()) <= 0 or explorer_selected_entities()[0].RootType != 'tool' {
		return
	}
    REAL $feedspeed = INPUT "Enter Type & Operation"
	REAL $speed = INPUT "Enter Cutting Speed"
	REAL $feed = INPUT "Enter Feed/Tooth"
		
	foreach $t in filter(explorer_selected_entities(),'this.RootType == "tool"') {
	EDIT TOOL FEEDSPEED SELECT $feedspeed
    EDIT TOOL $t SURFACESPEED $speed
	EDIT TOOL $t FEEDPERTOOTH $feed
		
}	
	DIALOGS MESSAGE ON
	DIALOGS ERROR ON
	GRAPHICS UNLOCK

Good Day,

I have this macro which allows me to change the Speeds and Feeds of selected tools.

The only thing I have an issue with is the Type and Operation $feedspeed.

Currently I have to input 0 0 for Finishing General or 0 1 for Finishing Slotting and so on.

What I'd like is to have a drop down with all the Types and Operations to select from, but I'm not entirely sure how to go about doing this, any help would be much appreciated. 

Regards

11 REPLIES 11
Message 2 of 12
icse
in reply to: evo80

heres a simple example what you could do:

 

string list $operations = {'General', 'Slotting','Profiling', 'Face Milling', 'Drilling', 'Plunge Milling', 'Copy Milling'}

int $feedspeedIndex = INPUT choice $operations "Enter Operation"

	
	
foreach $t in filter(explorer_selected_entities(),'this.RootType == "tool"') {

	EDIT TOOL FEEDSPEED SELECT 0 $feedspeedIndex
}

 

you macro should look something like this then:

IF $powermill.Status.MultipleSelection.First OR $powermill.Status.MultipleSelection.Total == 0 {

	reset localvars
	DIALOGS MESSAGE OFF
	DIALOGS ERROR OFF
	GRAPHICS LOCK
	
	if size(explorer_selected_entities()) <= 0 or explorer_selected_entities()[0].RootType != 'tool' {
		return
	}
	
    string list $operations = {'General', 'Slotting','Profiling', 'Face Milling', 'Drilling', 'Plunge Milling', 'Copy Milling'}
	int $feedspeedIndex = INPUT choice $operations "Enter Operation"
	
	REAL $speed = INPUT "Enter Cutting Speed"
	REAL $feed = INPUT "Enter Feed/Tooth"
		
	foreach $t in filter(explorer_selected_entities(),'this.RootType == "tool"') {
	EDIT TOOL FEEDSPEED SELECT 0 $feedspeedIndex
    EDIT TOOL $t SURFACESPEED $speed
	EDIT TOOL $t FEEDPERTOOTH $feed
		
}	
	DIALOGS MESSAGE ON
	DIALOGS ERROR ON
	GRAPHICS UNLOCK
}

 

Message 3 of 12
evo80
in reply to: icse

@icse 

IF $powermill.Status.MultipleSelection.First OR $powermill.Status.MultipleSelection.Total == 0 {

	reset localvars
	DIALOGS MESSAGE OFF
	DIALOGS ERROR OFF
	GRAPHICS LOCK
	
	if size(explorer_selected_entities()) <= 0 or explorer_selected_entities()[0].RootType != 'tool' {
		return
	}
	
    string list $types = {'Finishing', 'Roughing'}
	int $feedspeedIndexType = INPUT choice $types "Enter Type"
    string list $operations = {'General', 'Slotting', 'Profiling', 'Face Milling', 'Drilling', 'Plunge Milling', 'Copy Milling'}
	int $feedspeedIndex = INPUT choice $operations "Enter Operation"
	
	REAL $speed = INPUT "Enter Cutting Speed"
	REAL $feed = INPUT "Enter Feed/Tooth"
		
	foreach $t in filter(explorer_selected_entities(),'this.RootType == "tool"') {
	
	EDIT TOOL FEEDSPEED SELECT 0 $feedspeedIndex 
    EDIT TOOL $t SURFACESPEED $speed
	EDIT TOOL $t FEEDPERTOOTH $feed
		
}	
	DIALOGS MESSAGE ON
	DIALOGS ERROR ON
	GRAPHICS UNLOCK
}

Splendid,

Now how do I distinguish between Roughing and Finishing?

I came up with the above but am unsure how to apply. 

Message 4 of 12
icse
in reply to: evo80

Pretty much the same as above, you just need anoter list with the options and anoter variable wich stores the value

Message 5 of 12
evo80
in reply to: icse

So I have two indexes, one for the data type and one for the operation, and they're outputting the correct values,

I'm just unsure how to put both those values on the same line as 

EDIT TOOL FEEDSPEED SELECT.
The code below fails.

 

IF $powermill.Status.MultipleSelection.First OR $powermill.Status.MultipleSelection.Total == 0 {

	reset localvars
	DIALOGS MESSAGE OFF
	DIALOGS ERROR OFF
	GRAPHICS LOCK
	
	if size(explorer_selected_entities()) <= 0 or explorer_selected_entities()[0].RootType != 'tool' {
		return
	}
	
    string list $types = {'Finishing', 'Roughing'}
	int $feedspeedIndexType = INPUT choice $types "Enter Type"
    string list $operations = {'General', 'Slotting', 'Profiling', 'Face Milling', 'Drilling', 'Plunge Milling', 'Copy Milling'}
	int $feedspeedIndex = INPUT choice $operations "Enter Operation"
	
	REAL $speed = INPUT "Enter Cutting Speed"
	REAL $feed = INPUT "Enter Feed/Tooth"
	
	foreach $t in filter(explorer_selected_entities(),'this.RootType == "tool"') {
		 
	EDIT TOOL FEEDSPEED SELECT 0 $feedspeedIndexType + $feedspeedIndex   
	PRINT $feedspeedIndexType
	PRINT $feedspeedIndex  
	EDIT TOOL $t SURFACESPEED $speed
	EDIT TOOL $t FEEDPERTOOTH $feed
		
}	
	DIALOGS MESSAGE ON
	DIALOGS ERROR ON
	GRAPHICS UNLOCK
}

 

Message 6 of 12
icse
in reply to: evo80

EDIT TOOL FEEDSPEED SELECT ${feedspeedIndexType} ${feedspeedIndex}
Message 7 of 12
evo80
in reply to: evo80

Cheers, Now it works great

IF $powermill.Status.MultipleSelection.First OR $powermill.Status.MultipleSelection.Total == 0 {

	reset localvars
	DIALOGS MESSAGE OFF
	DIALOGS ERROR OFF
	GRAPHICS LOCK
	
	if size(explorer_selected_entities()) <= 0 or explorer_selected_entities()[0].RootType != 'tool' {
		return
	}
	
    string list $types = {'Finishing', 'Roughing'}
	int $feedspeedIndexType = INPUT choice $types "Enter Type"
    string list $operations = {'General', 'Slotting', 'Profiling', 'Face Milling', 'Drilling', 'Plunge Milling', 'Copy Milling'}
	int $feedspeedIndex = INPUT choice $operations "Enter Operation"
	
	REAL $speed = INPUT "Enter Cutting Speed"
	REAL $feed = INPUT "Enter Feed/Tooth"
	
	foreach $t in filter(explorer_selected_entities(),'this.RootType == "tool"') {
		 
	EDIT TOOL FEEDSPEED SELECT ${feedspeedIndexType} ${feedspeedIndex} 
	EDIT TOOL $t SURFACESPEED $speed
	EDIT TOOL $t FEEDPERTOOTH $feed
		
}	
	DIALOGS MESSAGE ON
	DIALOGS ERROR ON
	GRAPHICS UNLOCK
}
Message 8 of 12
evo80
in reply to: evo80

@icse 

Sorry to be a pain but could you tell me why my coolant choice is failing?

IF $powermill.Status.MultipleSelection.First OR $powermill.Status.MultipleSelection.Total == 0 {

	reset localvars
	DIALOGS MESSAGE OFF
	DIALOGS ERROR OFF
	GRAPHICS LOCK
	
	if size(explorer_selected_entities()) <= 0 or explorer_selected_entities()[0].RootType != 'tool' {
		return
	}
	
    string list $types = {'Finishing', 'Roughing'}
	int $feedspeedIndexType = INPUT choice $types "Enter Type"

    string list $operations = {'General', 'Slotting', 'Profiling', 'Face Milling', 'Drilling', 'Plunge Milling', 'Copy Milling'}
	int $feedspeedIndex = INPUT choice $operations "Enter Operation"

	STRING list $Coolanttype = {'None', 'On', 'Thru'}
	STRING $C = INPUT CHOICE $Coolanttype "Enter Coolant Type"
	$C = $Coolanttype
	PRINT $C

			
	REAL $speed = INPUT "Enter Cutting Speed"
	REAL $feed = INPUT "Enter Feed/Tooth"
	
	
	foreach $t in filter(explorer_selected_entities(),'this.RootType == "tool"') {
		 
	EDIT TOOL FEEDSPEED SELECT ${feedspeedIndexType} ${feedspeedIndex} 
	EDIT TOOL $t SURFACESPEED $speed
	EDIT TOOL $t FEEDPERTOOTH $feed
	EDIT TOOL $t COOLANT $Coolanttype
	
}	
	DIALOGS MESSAGE ON
	DIALOGS ERROR ON
	GRAPHICS UNLOCK
}
Message 9 of 12
icse
in reply to: evo80

try this:

IF $powermill.Status.MultipleSelection.First OR $powermill.Status.MultipleSelection.Total == 0 {

	reset localvars
	DIALOGS MESSAGE OFF
	DIALOGS ERROR OFF
	GRAPHICS LOCK
	
	if size(explorer_selected_entities()) <= 0 or explorer_selected_entities()[0].RootType != 'tool' {
		return
	}
	
    string list $types = {'Finishing', 'Roughing'}
	int $feedspeedIndexType = INPUT choice $types "Enter Type"

    string list $operations = {'General', 'Slotting', 'Profiling', 'Face Milling', 'Drilling', 'Plunge Milling', 'Copy Milling'}
	int $feedspeedIndex = INPUT choice $operations "Enter Operation"

	STRING list $Coolanttypes = {'None', 'Standart', 'Flood', 'Mist', 'Tap', 'Air', 'Thru', 'Both'}
	int $index = INPUT CHOICE $Coolanttypes "Enter Coolant Type"
	string $Coolanttype = lcase($Coolanttypes[$index])

			
	REAL $speed = INPUT "Enter Cutting Speed"
	REAL $feed = INPUT "Enter Feed/Tooth"
	
	
	foreach $t in filter(explorer_selected_entities(),'this.RootType == "tool"') {
		 
	EDIT TOOL FEEDSPEED SELECT ${feedspeedIndexType} ${feedspeedIndex} 
	EDIT TOOL $t SURFACESPEED $speed
	EDIT TOOL $t FEEDPERTOOTH $feed
	EDIT TOOL $t COOLANT ${Coolanttype}
	
}	
	DIALOGS MESSAGE ON
	DIALOGS ERROR ON
	GRAPHICS UNLOCK
}
Message 10 of 12
evo80
in reply to: icse

Strange,

It's returning the correct coolant type when I PRINT $Coolanttype but fails with this in the command window.

 

**** EDIT TOOL $t COOLANT ${Coolanttype}\n
**** --------------------^ Unexpected input !!

Error in Network : tool ( CoolantCmd )
Last Valid Token : COOLANT extracted by graph [ COMMAND ]
Received input : " ${Coolanttype}\n"

 

I tried without the curly brackets but got the same result.

Message 11 of 12
icse
in reply to: evo80

oh ok you could try:

string $cmd = "EDIT TOOL '" + $t.Name + "' COOLANT " + $Coolanttype
docommand $cmd

or

$t.Coolant = $Coolanttype

insted of:

EDIT TOOL $t COOLANT ${Coolanttype}

 

both should work

Message 12 of 12
evo80
in reply to: evo80

Many thanks,

I used the 2nd option,

Here's the working Macro.

IF $powermill.Status.MultipleSelection.First OR $powermill.Status.MultipleSelection.Total == 0 {

	reset localvars
	DIALOGS MESSAGE OFF
	DIALOGS ERROR OFF
	GRAPHICS LOCK
	
	if size(explorer_selected_entities()) <= 0 or explorer_selected_entities()[0].RootType != 'tool' {
		return
	}
	
    string list $types = {'Finishing', 'Roughing'}
	int $feedspeedIndexType = INPUT choice $types "Enter Type"

    string list $operations = {'General', 'Slotting', 'Profiling', 'Face Milling', 'Drilling', 'Plunge Milling', 'Copy Milling'}
	int $feedspeedIndex = INPUT choice $operations "Enter Operation"

	STRING list $Coolanttypes = {'None', 'Standard', 'Flood', 'Mist', 'Tap', 'Air', 'Thru', 'Both'}
	int $index = INPUT CHOICE $Coolanttypes "Enter Coolant Type"
	string $Coolanttype = lcase($Coolanttypes[$index])
    PRINT $Coolanttype
			
	REAL $speed = INPUT "Enter Cutting Speed"
	REAL $feed = INPUT "Enter Feed/Tooth"
	
	
	foreach $t in filter(explorer_selected_entities(),'this.RootType == "tool"') {
		 
	EDIT TOOL FEEDSPEED SELECT ${feedspeedIndexType} ${feedspeedIndex} 
	EDIT TOOL $t SURFACESPEED $speed
	EDIT TOOL $t FEEDPERTOOTH $feed
	$t.Coolant = $Coolanttype
	
}	
	DIALOGS MESSAGE ON
	DIALOGS ERROR ON
	GRAPHICS UNLOCK
} 

 

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

Post to forums  

Autodesk Design & Make Report