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 help for changing the output and model location workplanes in NC Program

3 REPLIES 3
SOLVED
Reply
Message 1 of 4
travisb3WVSU
217 Views, 3 Replies

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

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"
Tags (2)
Labels (1)
3 REPLIES 3
Message 2 of 4

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

Thank you. I am going to give this a try

Message 4 of 4
travisb3WVSU
in reply to: travisb3WVSU

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.

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

Post to forums  

Technology Administrators