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.
Solved! Go to Solution.
Solved by Kevin.hammond2. Go to Solution.
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.
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
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
Thanks, for the replies guys.
Mateus, i think yours does what i need, i will test it out, thanks
Kevin
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"
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