macro help for changing the output and model location workplanes in NC Program

macro help for changing the output and model location workplanes in NC Program

travisb3WVSU
Explorer Explorer
656 Views
3 Replies
Message 1 of 4

macro help for changing the output and model location workplanes in NC Program

travisb3WVSU
Explorer
Explorer

Here is what I got so far. I wanted a way to change workplanes for every toolpath when I brought in a new workpiece. So far this works to switch from a workplane named "OLD" to a user input text for a different workplane. I also have it delete "OLD" workplane in the NCGLOBAL page and that works. The program I am having is getting the user input text to also change the output and model location workplane. I don't know how to enter the variable to make it automated.

Here is what I got:

//THE INTENTION OF THIS MACRO IS TO REPLACE THE WORKPLANE FOR ONLY THOSE TOOLPATHS
//USING WORKPLANE "OLD" WITH WORKPLANE NAMED BY USER INPUT PROMPT for "new workplane name"
//
//
string wpName = ""
string oldwpname = "OLD"
STRING $UserInputText= INPUT "new workplane name"
 
 
DEACTIVATE TOOLPATH
GRAPHICS LOCK
FOREACH tp IN folder('Toolpath') {
$wpName = $tp.workplane.name
IF $wpName == $oldwpname {
DEACTIVATE TOOLPATH
INVALIDATE TOOLPATH NOQUERY $tp.name
$tp.workplane = $UserInputText
ACTIVATE TOOLPATH $tp.Name
EDIT TOOLPATH $tp.Name REAPPLY
}  
}
GRAPHICS UNLOCK
FORM NCGLOBAL
►►EDIT NCPROGRAM ALL MODELLOCATION ""◄◄ This is where I need help
►►EDIT NCPROGRAM ALL WORKPLANE ""◄◄ This is where I need help
NCGLOBAL APPLY
NCGLOBAL ACCEPT
DELETE WORKPLANE "OLD"
0 Likes
Accepted solutions (1)
657 Views
3 Replies
Replies (3)
Message 2 of 4

kevin.hammond3WX4X
Advocate
Advocate
Accepted solution

If i save a template file and wish to change the output workplane referenced by the tool paths i use the following to change the workplane.....

 

//Create a list of NCPrograms in session and prompt user to select those for post change
ENTITY LIST NCPrograms = INPUT ENTITY MULTIPLE NCPROGRAM "Select NCPrograms for Output WP change"

ENTITY LIST $Workplane = INPUT ENTITY Workplane "Pick Workplane for PGM Output"
string $WP = $Workplane.name

Activate Workplane $WP

//change out wp in selected programs
FOREACH $pg IN NCPrograms {
ACTIVATE NCProgram $pg.Name

EDIT NCPROGRAM # SET WORKPLANE $wp
NCTOOLPATH APPLY
}

 

So basically a foreach command rather globally , hope this is of some use.

 

Message 3 of 4

travisb3WVSU
Explorer
Explorer

Thank you. I am going to give this a try

0 Likes
Message 4 of 4

travisb3WVSU
Explorer
Explorer

This worked so well. I made a few changes and added it into my original macro now the whole process is automated and the user can select the workplane and the nc programs to change right at the beginning. Thank you so much for your help this made my day.

0 Likes