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: 

selected surface parameter

6 REPLIES 6
SOLVED
Reply
Message 1 of 7
Kevin.hammond2
1048 Views, 6 Replies

selected surface parameter

properties_selected_surfJPG.JPG

Does anyone know of a way to capture the parameter of a selected surface Z height, without changing the block, see screen shot below.

 

I can capture the information from by calculation the block to the model then using Block.Limits.ZMax, but would prefer not to mess with block.

 

 

6 REPLIES 6
Message 2 of 7
cfastM58RS
in reply to: Kevin.hammond2

I don't know of way to capture those values in a macro.  The easiest way is, as you said, to calculate a block.  

 

If you are worried about losing your block settings you could export the block at the beginning of the macro and re-import it at the end. 

I know its not the most elegant solution but it should work.

block.PNG

Message 3 of 7
LasseFred
in reply to: Kevin.hammond2

Try this:

 

FORM BLOCK
EDIT BLOCK RESET

$Block.Limits.ZMin = round(Block.Limits.ZMin;2)
$Block.Limits.ZMax = round(Block.Limits.ZMax;2)

REAL $CALC_BLOCK_Z = round(Block.Limits.ZMax;2) - round(Block.Limits.ZMin;2)

MESSAGE INFO $CALC_BLOCK_Z

BLOCK CANCEL
EDIT MODEL ALL DESELECT ALL
BLOCK CANCELLED

______________________
Lasse F.
Message 4 of 7
Anonymous
in reply to: Kevin.hammond2

Here you have another solution:

STRING filePath = "C:\surfPos.txt"

DIALOGS MESSAGE OFF
TRACEFILE OPEN $filePath
SIZE MODEL
TRACEFILE CLOSE
DIALOGS MESSAGE ON

STRING LIST $restOfFile = { }
FILE OPEN $filePath FOR READ AS input
FILE READ $restOfFile FROM input
FILE CLOSE input

STRING MinZPossition = trim(substring($restOfFile[5], 49, 20))
STRING MaxZPossition = trim(substring($restOfFile[6], 49, 20))
MESSAGE INFO "'Z' axis possition of selected surface." + CRLF + "Max.:	" + $MaxZPossition + CRLF + "Min.:		" + $MinZPossition

I hope it helps.

 

 

Mateusz

Message 5 of 7
Kevin.hammond2
in reply to: Anonymous

Thanks, for the replies guys.

Mateus, i think yours does what i need, i will test it out, thanks

 

Kevin

Message 6 of 7

 The following code should also work and does not require you to create a text file.

 

 

Real $Zmin = 0
Real $ZMax = 0
INT $Counter = 0
FOREACH $Mod IN folder('model') {
    IF $Counter {
        $Zmin = MIN($Zmin, LIMITS($Mod)[4])
        $Zmax = MAX($Zmax, LIMITS($Mod)[5])
 } ELSE {
     $Zmin = LIMITS($Mod)[4]
     $Zmax = LIMITS($Mod)[5]
 }
 $Counter = $Counter + 1
}
// Popup a dialog to inform user of the ZMin and ZMax
MESSAGE INFO "Z Maximum = $Zmax" + CRLF + "Z Minimum= $Zmin"

 

Message 7 of 7

Here's where I ended up.

Creates a list of models in the session, prompts user to pick one, then capture it's Maximum Z.

The commented (//) out lines are just for reference and the message was just to test output.

Thanks for the assistance guys.

Regards Kevin

 

Real ZMax = 0
STRING LIST Models = {}
FOREACH mod IN folder('Model') {
 int s = add_last(Models, mod.Name)

String pick = input choice $models "Get Max height from model - Pick MP"
string Modname = Models[$pick]

REAL ARRAY Lims[] = limits('model', $Modname)
//The values in the array are:
//REAL MinX = round(Lims[0], 3)
//REAL MaxX = round(Lims[1], 3)
//REAL MinY = round(Lims[2], 3)
//REAL MaxY = round(Lims[3], 3)
//REAL MinZ = round(Lims[4], 3)
REAL MaxZ = round(Lims[5], 3)

message info $Modname + " " + $MaxZ

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

Post to forums  

Autodesk Design & Make Report