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: 

UserDefined ToolPath with macro

10 REPLIES 10
SOLVED
Reply
Message 1 of 11
jsweatherbie
705 Views, 10 Replies

UserDefined ToolPath with macro

Today im trying to make a User Definedmacro for helicals and it doesnt seem to imput the Thru ,To Depth and full dia

-------------------------------------------

heres the code

-------------------------------------

 

bool runAgain = false
do {

//SHOWS YOU A LIST OF TOOLS
string list options={"3-inch","2-inch","25mm","20mm","1/2","12mm","6mm"}
int i = INPUT CHOICE $options "Choose a tool"

string tpName = $options[$i]

FORM FEATURESELECT
MACRO PAUSE "SELECT A HOLE TO HELICAL" + crlf + "AND CLICK RESUME"

switch $i {
case 0
IMPORT TEMPLATE ENTITY TOOLPATH TMPLTSELECTORGUI "C:\Users\User\AppData\Local\Autodesk\PowerMill\My-Strategies\HELICAL\3-INCH.ptf "
break
case 1
IMPORT TEMPLATE ENTITY TOOLPATH TMPLTSELECTORGUI "C:\Users\User\AppData\Local\Autodesk\PowerMill\My-Strategies\HELICAL\2-INCH.ptf "
break
case 2
IMPORT TEMPLATE ENTITY TOOLPATH TMPLTSELECTORGUI "C:\Users\User\AppData\Local\Autodesk\PowerMill\My-Strategies\HELICAL\25MM.ptf"
break
case 3
IMPORT TEMPLATE ENTITY TOOLPATH TMPLTSELECTORGUI "C:\Users\User\AppData\Local\Autodesk\PowerMill\My-Strategies\HELICAL\20MM.ptf "
break
case 4
IMPORT TEMPLATE ENTITY TOOLPATH TMPLTSELECTORGUI "C:\Users\User\AppData\Local\Autodesk\PowerMill\My-Strategies\HELICAL\500.ptf"
break
case 5
IMPORT TEMPLATE ENTITY TOOLPATH TMPLTSELECTORGUI "C:\Users\User\AppData\Local\Autodesk\PowerMill\My-Strategies\HELICAL\12MM.ptf"
break
case 5
IMPORT TEMPLATE ENTITY TOOLPATH TMPLTSELECTORGUI "C:\Users\User\AppData\Local\Autodesk\PowerMill\My-Strategies\HELICAL\6MM.ptf"
break
}

//Choosing the Operation for the Helical
string list Operation ={"To Depth","Full Dia","Thru hole"}
int o = INPUT CHOICE $Operation "Choose a Operation"
switch $o {
case 0
EDIT DRILL DEPTH EXACT
case 1
EDIT DRILL DEPTH HOLE
case 2
EDIT DRILL DEPTH THRU
}

RENAME TOOLPATH "1" $tpName
EDIT TOOLPATH $tpName CALCULATE
FORM ACCEPT SFDrilling
FEATURESELECT CANCEL

//RUNS AGAIN IF ANSWER IS YES
$runAgain = QUERY "Helical Another Hole?"
} while $runAgain == true

Tags (1)
Labels (1)
10 REPLIES 10
Message 2 of 11

Try this:

bool runAgain = false
do {

//SHOWS YOU A LIST OF TOOLS
string list options={"3-inch","2-inch","25mm","20mm","1/2","12mm","6mm"}
int i = INPUT CHOICE $options "Choose a tool"

string tpName = $options[$i]

FORM FEATURESELECT
MACRO PAUSE "SELECT A HOLE TO HELICAL" + crlf + "AND CLICK RESUME"

switch $i {
case 0
IMPORT TEMPLATE ENTITY TOOLPATH TMPLTSELECTORGUI "C:\Users\User\AppData\Local\Autodesk\PowerMill\My-Strategies\HELICAL\3-INCH.ptf "
break
case 1
IMPORT TEMPLATE ENTITY TOOLPATH TMPLTSELECTORGUI "C:\Users\User\AppData\Local\Autodesk\PowerMill\My-Strategies\HELICAL\2-INCH.ptf "
break
case 2
IMPORT TEMPLATE ENTITY TOOLPATH TMPLTSELECTORGUI "C:\Users\User\AppData\Local\Autodesk\PowerMill\My-Strategies\HELICAL\25MM.ptf"
break
case 3
IMPORT TEMPLATE ENTITY TOOLPATH TMPLTSELECTORGUI "C:\Users\User\AppData\Local\Autodesk\PowerMill\My-Strategies\HELICAL\20MM.ptf "
break
case 4
IMPORT TEMPLATE ENTITY TOOLPATH TMPLTSELECTORGUI "C:\Users\User\AppData\Local\Autodesk\PowerMill\My-Strategies\HELICAL\500.ptf"
break
case 5
IMPORT TEMPLATE ENTITY TOOLPATH TMPLTSELECTORGUI "C:\Users\User\AppData\Local\Autodesk\PowerMill\My-Strategies\HELICAL\12MM.ptf"
break
case 5
IMPORT TEMPLATE ENTITY TOOLPATH TMPLTSELECTORGUI "C:\Users\User\AppData\Local\Autodesk\PowerMill\My-Strategies\HELICAL\6MM.ptf"
break
}

//Choosing the Operation for the Helical
string list Operation ={"To Depth","Full Dia","Thru hole"}
int o = INPUT CHOICE $Operation "Choose a Operation"
switch $o {
case 0
EDIT PAR "Drill.DepthType" "full_diameter"
case 1
EDIT PAR "Drill.DepthType" "hole"
case 2
EDIT PAR "Drill.DepthType" "thru"
}

RENAME TOOLPATH "1" $tpName
EDIT TOOLPATH $tpName CALCULATE
FORM ACCEPT SFDrilling
FEATURESELECT CANCEL

//RUNS AGAIN IF ANSWER IS YES
$runAgain = QUERY "Helical Another Hole?"
} while $runAgain == true

Rafael Sansão

EESignature

Message 3 of 11

so after it imports the template and you select the "Operation" with the drop down it doesnt stay for some odd reason... it works just not the operation. do i need to define it before hand to tell it when it imports ?
Message 4 of 11

Did you try the code I sent?
It should do exactly what you're looking for.
I changed this part of the macro:

switch $o {
case 0
EDIT PAR "Drill.DepthType" "full_diameter"
case 1
EDIT PAR "Drill.DepthType" "hole"
case 2
EDIT PAR "Drill.DepthType" "thru"
}

 

Rafael Sansão

EESignature

Message 5 of 11
jsweatherbie
in reply to: jsweatherbie

yes i did and it never set the operation for DepthTypes.....  do you need to pin point the toolpath?

 

in the reference it states "{toolpath}.Drill.DepthType " 

 

OR do i need to move the:

RENAME TOOLPATH "1" $tpName
EDIT TOOLPATH $tpName CALCULATE
FORM ACCEPT SFDrilling
FEATURESELECT CANCEL

 

 

 

Message 6 of 11

Try now.
There was an error on the Switch.

EDIT PAR "Drill.DepthType" "hole"
I fixed an issue on the Switch and I made some improvements.

$entity("Toolpath","").Drill.DepthType = "hole"

Change the parameter directly on the toolpath

 

bool runAgain = false
do {

//SHOWS YOU A LIST OF TOOLS
string list options={"3-inch","2-inch","25mm","20mm","1/2","12mm","6mm"}
int i = INPUT CHOICE $options "Choose a tool"

string tpName = $options[$i]

FORM FEATURESELECT
MACRO PAUSE "SELECT A HOLE TO HELICAL" + crlf + "AND CLICK RESUME"

switch $i {
case 0
	IMPORT TEMPLATE ENTITY TOOLPATH TMPLTSELECTORGUI "C:\Users\User\AppData\Local\Autodesk\PowerMill\My-Strategies\HELICAL\3-INCH.ptf"
	BREAK
case 1
	IMPORT TEMPLATE ENTITY TOOLPATH TMPLTSELECTORGUI "C:\Users\User\AppData\Local\Autodesk\PowerMill\My-Strategies\HELICAL\2-INCH.ptf"
	BREAK
case 2
	IMPORT TEMPLATE ENTITY TOOLPATH TMPLTSELECTORGUI "C:\Users\User\AppData\Local\Autodesk\PowerMill\My-Strategies\HELICAL\25MM.ptf"
	BREAK
case 3
	IMPORT TEMPLATE ENTITY TOOLPATH TMPLTSELECTORGUI "C:\Users\User\AppData\Local\Autodesk\PowerMill\My-Strategies\HELICAL\20MM.ptf"
	BREAK
case 4
	IMPORT TEMPLATE ENTITY TOOLPATH TMPLTSELECTORGUI "C:\Users\User\AppData\Local\Autodesk\PowerMill\My-Strategies\HELICAL\500.ptf"
	BREAK
case 5
	IMPORT TEMPLATE ENTITY TOOLPATH TMPLTSELECTORGUI "C:\Users\User\AppData\Local\Autodesk\PowerMill\My-Strategies\HELICAL\12MM.ptf"
	BREAK
case 5
	IMPORT TEMPLATE ENTITY TOOLPATH TMPLTSELECTORGUI "C:\Users\User\AppData\Local\Autodesk\PowerMill\My-Strategies\HELICAL\6MM.ptf"
	BREAK
}

//Choosing the Operation for the Helical
string list Operation ={"To Depth","Full Dia","Thru hole"}
int o = INPUT CHOICE $Operation "Choose a Operation"
switch $o {
case 0
	EDIT PAR "Drill.DepthType" "full_diameter"
	$entity("Toolpath","").Drill.DepthType = "full_diameter"
	BREAK
case 1
	EDIT PAR "Drill.DepthType" "hole"
	$entity("Toolpath","").Drill.DepthType = "hole"
	BREAK
case 2
	EDIT PAR "Drill.DepthType" "thru"
	$entity("Toolpath","").Drill.DepthType = "thru"
	BREAK
}

IF entity_exists("Toolpath",$tpName) {
	$tpName = new_entity_name("Toolpath",$tpName)
} 
RENAME TOOLPATH ; $tpName
EDIT TOOLPATH $tpName CALCULATE
FORM ACCEPT SFDrilling
FEATURESELECT CANCEL

//RUNS AGAIN IF ANSWER IS YES
$runAgain = QUERY "Helical Another Hole?"
} while $runAgain == true

 

Rafael Sansão

EESignature

Message 7 of 11
jsweatherbie
in reply to: jsweatherbie

it only works if you have a tool path already open it doesnt actually modify the one that was created im thinking i just have to have it active its self and open the menu to have it changed

Message 8 of 11

Did you copy and try to run my last macro?
I tested it from my side and it does exactly what you want.

Rafael Sansão

EESignature

Message 9 of 11
jsweatherbie
in reply to: jsweatherbie

im running 2020 powermill

Message 10 of 11

This should work in 2020.
Can you download the file "test.txt" and change the extension to "test.mac" and try to run?
If it still doesn't work, record a video showing the problem

Rafael Sansão

EESignature

Message 11 of 11

It worked out great it was me who labeled things wrong lol thank you for your help I learned alot

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

Post to forums  

Technology Administrators


Autodesk Design & Make Report