I was wondering if it would be possible to assign a macro to a command in powermill. For example when I'm prepping jobs I have to bring in the FCS risers manually and add them to the model. Ultimately (and I know it's a long shot) what I'd like to be able to do is type "c6" and have it run a specified macro to import a riser into position. I know it's a long shot but I'm hoping it's possible or maybe some sort of work around macro wise. Any ideas?
Solved! Go to Solution.
Solved by tibor.vekasi. Go to Solution.
Step 1: Create a simple macro for load a risers, and move it current workplane:
STRING RiserName='furatok'
STRING RiserFile= 'C:\Munka\'+$RiserName+'.dgk'
STRING Riser=$RiserName
IF entity_exists('model',$Riser) {
$Riser=new_entity_name('model',$Riser)
}
IMPORT MODEL $RiserFile
IF entity_exists('workplane','') {
TRANSFORM TYPE WORKPLANE TRANSFORM MODEL $Riser
MODELTRANS ACCEPT
}
Alternative macro for load a risers, and input this position:
STRING RiserName='furatok'
STRING RiserFile= 'C:\Munka\'+$RiserName+'.dgk'
STRING POS=INPUT 'Riser Position X Y Z [Rot Z=0] (Space separated)'
STRING LIST V=tokens($POS)
if size($V) < 3 {
RETURN
}
STRING Riser=$RiserName
IF entity_exists('model',$Riser) {
$Riser=new_entity_name('model',$Riser)
}
IMPORT MODEL $RiserFile
REAL X=real($V[0])
REAL Y=real($V[1])
REAL Z=real($V[2])
if size($V) > 3 {
REAL ROTZ=real($V[3])
TRANSFORM ANGLE $ROTZ
TRANSFORM TYPE ROTATEZ TRANSFORM MODEL $Riser
}
TRANSFORM MOVE $X
TRANSFORM TYPE MOVE TRANSFORM MOVEX PRESET TRANSFORM MODEL $Riser
TRANSFORM MOVE $Y
TRANSFORM TYPE MOVE TRANSFORM MOVEY PRESET TRANSFORM MODEL $Riser
TRANSFORM MOVE $Z
TRANSFORM TYPE MOVE TRANSFORM MOVEZ PRESET TRANSFORM MODEL $Riser
MODELTRANS ACCEPT
RETURN
Step 2: In Powermill:
Tools->Customize keyboard Shortcuts -> Macros-> Add Macro Shortcut (2nd button), select the macro, press keys(such as CTRL+Alt+R) ->Assign ->Close
Ok so I have a few folders saved off with a riser importing in the right position. Each .dgk is named according to the grid location. Instead of moving them into position is there a way I could call up a user input and then import the corresponding riser? I'm having a little bit of difficulty getting it to work properly.
Thanks for all the help though, it seems every problem I run into your always quick with the response!
This is what I've got and I can't get it to grab the user input and put it into the model path.
STRING RISERNAME = INPUT "CHOOSE A RISER"
STRING RISER = $RISERNAME
IMPORT MODEL "C:\Users\danmic\Desktop\PREP MODELS\FCS\RISERS\15MM\$RISER.dgk"
STRING LIST Risers = list_files("files","c:\riserfolder",".dgk")
BOOL err=0
INT C = INPUT CHOICE $Risers "Choose riser"
$err=ERROR $C
IF $err {
RETURN
}
String Riser = $Risers[$C]
IMPORT MODEL $Riser
Is there anyway to just import the model name I specify through a user input instead of listing it out? ultimately I'd just like a prompt which asks for which riser I want, I type in the file name, and it imports the chose file
STRING RISERNAME = INPUT "CHOOSE A RISER"
STRING RISER = "C:\Users\danmic\Desktop\PREP MODELS\FCS\RISERS\15MM\"+$RISERNAME+".dgk"
IMPORT MODEL $RISER
riser1.mac:
STRING RISERNAME = "Riser_1"
STRING RISER = "C:\Users\danmic\Desktop\PREP MODELS\FCS\RISERS\15MM\"+$RISERNAME+".dgk"
IMPORT MODEL $RISER
riser2.mac:
STRING RISERNAME = "Riser_2"
STRING RISER = "C:\Users\danmic\Desktop\PREP MODELS\FCS\RISERS\15MM\"+$RISERNAME+".dgk"
IMPORT MODEL $RISER
.
. etc.
Then:
Powermill Tools->Customize keyboard Shortcuts -> Macros->
-> Add Macro Shortcut (2nd button), select riser1.mac , press keys(CTRL+Alt+1) ->Assign
-> Add Macro Shortcut (2nd button), select riser2.mac , press keys(CTRL+Alt+2) ->Assign
.
.
etc.
->Close