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: 

Can we create our own commands?

8 REPLIES 8
SOLVED
Reply
Message 1 of 9
danmic7JH66
590 Views, 8 Replies

Can we create our own commands?

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?

8 REPLIES 8
Message 2 of 9
tibor.vekasi
in reply to: danmic7JH66

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 

Message 3 of 9
danmic7JH66
in reply to: tibor.vekasi

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"

 

 

Message 4 of 9
tibor.vekasi
in reply to: danmic7JH66

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

 

Message 5 of 9
danmic7JH66
in reply to: tibor.vekasi

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

Message 6 of 9
tibor.vekasi
in reply to: danmic7JH66

STRING RISERNAME = INPUT "CHOOSE A RISER"

STRING RISER = "C:\Users\danmic\Desktop\PREP MODELS\FCS\RISERS\15MM\"+$RISERNAME+".dgk"

IMPORT MODEL $RISER

Message 7 of 9
danmic7JH66
in reply to: tibor.vekasi

You sir are wonderful, if you're ever in my neck of the woods I owe you a
beer.or several.
Message 8 of 9
danmic7JH66
in reply to: tibor.vekasi

You sir are wonderful, if you're ever in my neck of the woods I owe you a
beer.or several.
Message 9 of 9
tibor.vekasi
in reply to: danmic7JH66

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

 

 

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

Post to forums  

Autodesk Design & Make Report