Edit Cutting Data Macro Help

evo80
Collaborator
Collaborator

Edit Cutting Data Macro Help

evo80
Collaborator
Collaborator
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

0 Likes
Reply
Accepted solutions (2)
534 Views
11 Replies
Replies (11)

icse
Collaborator
Collaborator

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
}

 

0 Likes

evo80
Collaborator
Collaborator

@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. 

0 Likes

icse
Collaborator
Collaborator

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

0 Likes

evo80
Collaborator
Collaborator

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
}

 

0 Likes

icse
Collaborator
Collaborator
Accepted solution
EDIT TOOL FEEDSPEED SELECT ${feedspeedIndexType} ${feedspeedIndex}
0 Likes

evo80
Collaborator
Collaborator

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
}
0 Likes

evo80
Collaborator
Collaborator

@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
}
0 Likes

icse
Collaborator
Collaborator

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
}
0 Likes

evo80
Collaborator
Collaborator

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.

0 Likes

icse
Collaborator
Collaborator
Accepted solution

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

0 Likes

evo80
Collaborator
Collaborator

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
} 

 

0 Likes