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: 

Does PowerMILL have similar commands?

7 REPLIES 7
Reply
Message 1 of 8
duwayne.
623 Views, 7 Replies

Does PowerMILL have similar commands?

In PowerShape there is these commands for finding the absolute coordinates for a bounding box of selected items.  "selection.min_range_exact" and "selection.max_range_exact".  Does PowerMILL have comparable commands?

Thanks

7 REPLIES 7
Message 2 of 8
5axes
in reply to: duwayne.

IN PowerMill  for such function the easyest way if to calculate the temporary BLOCK and get the limits of this Block.  Or you can also get via the Function LIMITS, the dimension of your model . Hereafter  two solutions to get the limits :

// -------------------
// Solution ONE
// -------------------

Real $Xmin = 0
Real $Xmax = 0
Real $Ymin = 0
Real $Ymax = 0
Real $Zmin = 0
Real $Zmax = 0

EDIT BLOCKTYPE BOX
EDIT BLOCK RESET
BLOCK ACCEPT

$Xmin=$block.limits.xmin
$Xmax=$block.limits.xmax
$Ymin=$block.limits.ymin
$Ymax=$block.limits.ymax
$Zmin=$block.limits.zmin
$Zmax=$block.limits.zmax

// Popup a dialog to inform user of the Min and Max
MESSAGE INFO "X max = $Xmax" + CRLF + "X min= $Xmin" + CRLF + "Y max = $Ymax" + CRLF + "Y min = $Ymin"+ CRLF + "Z max = $Zmax" + CRLF + "Z min = $Zmin"

// -------------------
// Solution Two 
// -------------------

INT $Counter = 0
// FOREACH in case of multi model
FOREACH $Mod IN folder('model') {  
 IF $Counter {
        $Xmin = MIN($Xmin, LIMITS($Mod)[0])
        $Xmax = MAX($Xmax, LIMITS($Mod)[1])
	    $Ymin = MIN($Ymin, LIMITS($Mod)[2])
        $Ymax = MAX($Ymax, LIMITS($Mod)[3])
        $Zmin = MIN($Zmin, LIMITS($Mod)[4])
        $Zmax = MAX($Zmax, LIMITS($Mod)[5])
 } ELSE {
        $Xmin = LIMITS($Mod)[0]
        $Xmax = LIMITS($Mod)[1]
	    $Ymin = LIMITS($Mod)[2]
        $Zmin = LIMITS($Mod)[4]
        $Zmax = LIMITS($Mod)[5]
 }
 $Counter = $Counter + 1
}
// Popup a dialog to inform user of the Min and Max
MESSAGE INFO "X max = $Xmax" + CRLF + "X min= $Xmin" + CRLF + "Y max = $Ymax" + CRLF + "Y min = $Ymin"+ CRLF + "Z max = $Zmax" + CRLF + "Z min = $Zmin"

 

Tags (1)
Message 3 of 8
urizenYHS3W
in reply to: 5axes

A third way in pm2018 using the apply() function:

 

REAL XMin = min(apply(folder('model'), 'limits(this)[0]'))
REAL XMax = max(apply(folder('model'), 'limits(this)[1]'))
REAL YMin = min(apply(folder('model'), 'limits(this)[2]'))
REAL YMax = max(apply(folder('model'), 'limits(this)[3]'))
REAL ZMin = min(apply(folder('model'), 'limits(this)[4]'))
REAL ZMax = max(apply(folder('model'), 'limits(this)[5]'))
Tags (1)
Message 4 of 8
duwayne.
in reply to: urizenYHS3W

Thanks for the reply.

 

In your first example I have done similar macros for manipulating blocks such as the example below.  I also have macros for mirroring and transferring blocks from one project to another.  I also looked at the help on entity based functions in regards to using the limits command.  I've never written any macro's using arrays.  I guess I have something new to learn.  By the way I am working with segments in a pattern.  The next thing Im hoping Delcam can give me info on, is an explanation of the data structure for the PICK command.  What I would like to do is to cycle through the entities in a pattern one at a time and apply that to the data format for the PICK command.  I am also still stuck in ver. 2016.

 

// DW macro to translate BLOCK by Box
// enter XYZ values just as you would in any other input field
// "X" value space "Y" value space "Z" value

STRING move = INPUT "Box Block shift XYZ"
STRING LIST Tokens = tokens(move)

REAL Xmove = Tokens[0]
REAL Ymove = Tokens[1]
REAL Zmove = Tokens[2]

Let $BL_X_MX = Block.Limits.XMax
Let $BL_X_MN = Block.Limits.XMin
Let $BL_Y_MX = Block.Limits.YMax
Let $BL_Y_MN = Block.Limits.YMin
Let $BL_Z_MX = Block.Limits.ZMax
Let $BL_Z_MN = Block.Limits.ZMin

Let $NEWBL_X_MN = $BL_X_MN + $Xmove
Let $NEWBL_X_MX = $BL_X_MX + $Xmove
Let $NEWBL_Y_MN = $BL_Y_MN + $Ymove
Let $NEWBL_Y_MX = $BL_Y_MX + $Ymove
Let $NEWBL_Z_MN = $BL_Z_MN + $Zmove
Let $NEWBL_Z_MX = $BL_Z_MX + $Zmove

FORM BLOCK
EDIT BLOCK ALL UNLOCK
DELETE BLOCK
EDIT BLOCK XMIN $NEWBL_X_MN
EDIT BLOCK XMAX $NEWBL_X_MX
EDIT BLOCK YMIN $NEWBL_Y_MN
EDIT BLOCK YMAX $NEWBL_Y_MX
EDIT BLOCK ZMIN $NEWBL_Z_MN
EDIT BLOCK ZMAX $NEWBL_Z_MX
BLOCK ACCEPT
REFRESH VIEWMILL RESIZEVIEW
Message 5 of 8
5axes
in reply to: duwayne.

I don't know what you want to do with the PICK command ... But just my point of view : Forget . the Pick command is just a clic in the screen and you cannot use it to select an area or a surface or anything except if you always Mill the same part , With the same size.  If you need to select something you must find another way, ( by color, by name , by layer ).

 

Just my point of view and my experience

Message 6 of 8
5axes
in reply to: urizenYHS3W

Thanks @urizenYHS3W for this sample code. Looks like a great improvement in the macro Code. Unfortunatly for me I'm still using the 2017 release

Message 7 of 8
duwayne.
in reply to: duwayne.

The following in my trying to understand using array's, returns the extents of the entire pattern.  Lets say that pattern 1 has 20 segments in it.  I want to find out about segment 15.  Is it possible to take the limits command down to this next level?

 

RESET LOCALVARS
REAL ARRAY d[] = limits('pattern','1')
REAL MinX = d[0]
print $MinX
REAL MaxX = d[1]
print $MaxX
REAL MinY = d[2]
print $MinY
REAL MaxY = d[3]
print $MaxY
REAL MinZ = d[4]
print $MinZ
REAL MaxZ = d[5]
print $MaxZ
Message 8 of 8
duwayne.
in reply to: 5axes

I'm attempting to develop some kind of a template macro to do the reordering of many engraving tool paths in one project that are all similar in that they do in deed fall into the same locations.  I've tried to get some input on this topic in another thread, but it didn't go anywhere.  What I currently do is to record a macro of my selecting the space of what would be each full size character.  After selecting a character, I push it to the bottom of the order stack. Then select the next one and so on.  I then run that macro on all the similar tool paths where the engraving is laid out the same.  I use the macro listed below to select the toolpaths I want to run the macro on.  There could be as many as 30 tool paths.  It's not the end of the world to do it like that.  I'm hoping to automate things a little more.  I've made a pattern containing rectangles that represent all the character positions.  I have that pattern ordered correctly.  I'm hoping to be able to cycle through the ordered segments of that template pattern with a macro to do the reordering of the characters in the tool path.  Hence the desire to translate the extents of each rectangular segment in that pattern into PICK command data.

 

//
//DW macro that allows running of your choice of macro's on multiple tool paths
//
//
//Prompt to select tool paths
//
ENTITY LIST $ents = INPUT ENTITY MULTIPLE toolpath "Select Toolpaths"
//
//Prompt to select macro to run on those tool paths
//
	STRING Filename = ''
	$Filename = FILESELECT "Please select a macro to run" "*.mac" "C:\dcam\Power-Macs\0-MACRO-WORK-AREA"

	FOREACH $tp IN $ents {
 	ACTIVATE TOOLPATH  $tp.name

	macro $Filename

}

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

Post to forums  

Autodesk Design & Make Report