Macro to change selected tool path model location

Macro to change selected tool path model location

evo80
Collaborator Collaborator
1,089 Views
7 Replies
Message 1 of 8

Macro to change selected tool path model location

evo80
Collaborator
Collaborator

Good Day,

I'm working on this macro to change the model location of selected toolpaths, but I'm sort of stumped.

Any help would save the remaining hair on top of my head.

 

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

STRING $Message = "Choose New Machine Tool Model Location"
STRING LIST Selected_WORKPLANES = INPUT ENTITY MULTIPLE WORKPLANE $Message


DIALOGS MESSAGE OFF
DIALOGS ERROR OFF
GRAPHICS LOCK

FOREACH $tp IN explorer_selected_entities() {
ACTIVATE TOOLPATH $tp.name
FOREACH $ref IN folder ('WORKPLANE') {
EDIT PAR 'ModelLocation' $ref
}
EDIT TOOLPATH $tp REAPPLYFROMGUI
YES
}
MESSAGE INFO "All Selected Toolpath Machine Tool Model Locations Have Been Updated "
TEXTINFO ACCEPT

DIALOGS MESSAGE ON
DIALOGS ERROR ON
GRAPHICS UNLOCK

0 Likes
Accepted solutions (2)
1,090 Views
7 Replies
Replies (7)
Message 2 of 8

icse
Advisor
Advisor

maby this can help you:

if size(explorer_selected_entities()) <= 0 or explorer_selected_entities()[0].RootType != 'toolpath' {
	return
}

entity $newWorkplane = INPUT ENTITY WORKPLANE "Choose New Machine Tool Model Location"

DEACTIVATE Toolpath
EDIT PAR 'ModelLocation' ${newWorkplane.Name}
EDIT PAR SELECTED ModelLocation

but it will invalidate the toolpaths

 

you also could change the last line tho this:

EDIT PAR SELECTED ModelLocation accept

 so no querry apears.

0 Likes
Message 3 of 8

evo80
Collaborator
Collaborator

Thanks for the help,

I didn't have any luck with the code,

Here are the command window results.

 

Process Command : [entity $newWorkplane = INPUT ENTITY WORKPLANE "Choose New Machine Tool Model Location"\n]


Process Command : [\n]


Process Command : [DEACTIVATE Toolpath\n]


Process Command : [EDIT PAR 'ModelLocation' ${newWorkplane.Name}\n]

Error: Cannot evaluate expression:
newWorkplane.Name
Error: DMG_Attach_Op3

Process Command : [EDIT PAR SELECTED ModelLocation\n]

0 Likes
Message 4 of 8

icse
Advisor
Advisor
Accepted solution

Thats odd... yesterday i wasnt able to reproduce the error today i got same error

this should work:

 

if size(explorer_selected_entities()) <= 0 or explorer_selected_entities()[0].RootType != 'toolpath' {
	return
}

entity $newWorkplane = INPUT ENTITY WORKPLANE "Choose New Machine Tool Model Location"
deactivate toolpath
string $cmd = 'EDIT PAR "ModelLocation" "' + $newWorkplane.Name + '"'
docommand $cmd
EDIT PAR SELECTED 'ModelLocation'

 

0 Likes
Message 5 of 8

evo80
Collaborator
Collaborator

@icse 

Thankyou very much that works famously for a single selected tool path!

So I edited the code to allow multiple tool path selection, which works fine, the only thing this code doesn't do is have the invalidation message pop up, don't suppose you know how I can include this message?

Not a big deal really, I can live without it, just a fail safe would be nice.

Regards Jon Keeler 

0 Likes
Message 6 of 8

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

DIALOGS MESSAGE OFF
DIALOGS ERROR OFF
GRAPHICS LOCK

if size(explorer_selected_entities()) <= 0 or explorer_selected_entities()[0].RootType != 'toolpath' {
	return
}

entity $newWorkplane = INPUT ENTITY WORKPLANE "Choose New Machine Tool Model Location"
string $cmd = 'EDIT PAR "ModelLocation" "' + $newWorkplane.Name + '"'

FOREACH $tp IN explorer_selected_entities() {
docommand $cmd
EDIT PAR SELECTED 'ModelLocation'
}

DIALOGS MESSAGE ON
DIALOGS ERROR ON
GRAPHICS UNLOCK
0 Likes
Message 7 of 8

icse
Advisor
Advisor
Accepted solution

it actually should work with multi selection since the line:

 

EDIT PAR SELECTED 'ModelLocation'

 

should change the parameter Modelllocation for every selected entity

 

also to show the popup message you should turn em on not off

DIALOGS MESSAGE ON

 

not

DIALOGS MESSAGE OFF
0 Likes
Message 8 of 8

evo80
Collaborator
Collaborator

Sorry, Your code does indeed change selected tool paths, my mistake.

Thanks for your help, this was something that was taking up a lot of my time, so now being able to select all toolpaths

and changing the model location for different ops has helped tremendously!

Regards

0 Likes