Professional Documents
Culture Documents
13 Graphics Functions
The MP language and post executable allow you to perform certain Mastercam graphics functions.
Note: This information is listed for documentation completeness purposes (as of April 2002) and does
constitute a recommendation to use these techniques.
Note: These functions only work with the DLL! There are no solids with V9.03 of the DLL!
Controlling levels
Database helper variables db_lvl_src and db_lvl_trg are used with the following functions to select the
levels in Mastercam that entities are on (db_lvl_src) and the start level they are to be moved to
(db_lvl_trg). 1 to 255 are valid values. 1 is the default for db_lvl_src if it is not set or it is out of range.
If db_lvl_trg is not set or out of range, the calls that depend on it fail. Levels are automatically indexed
from db_lvl_trg for each additional transform setup function.
Note: The source and target should not be set to the same level!
Function summary
The following functions are used to control graphics in Mastercam.
delay stops processing for the time entered in seconds.
drwlin draws a line to the Mastercam graphics screen.
drwarc draws a arc to the Mastercam graphics screen.
db_view takes view matrix as the single argument and returns the view number.
Function descriptions
drwlin
drwlin allows drawing to the screen during posting. The first argument is a 6D line. The second
argument is the color as defined below. The color, signed negative, indicates that the geometry should
be saved.
It uses Mastercam’s initial WCS view. Drawing is on the level defined by the helper variable db_lvl_trg.
drwlin always returns 1 if it is not set to save geometry. drwlin also returns 1 if it is set to save geometry
and is successful, or 0 if unsuccessful.
Example:
result : 0
line_p1_x : 1
line_p1_y : 1
line_p1_z : 1
line_p2_x : 2
line_p2_y : 2
line_p2_z : 2
color : 16
ppostblock
db_lvl_trg = 1
result = drwlin( line_p1_x, color )
drwarc
drwarc allows drawing to the screen during posting. The first argument is an arc definition. (See
function xaa.) The second argument is the color as defined below. The color, signed negative,
indicates that the geometry should be saved.
The 3D point helper variables prv_ptnearx and ptnearx are used to define the start point of the arc
(prv_ptnearx) and the end position (ptnearx). These points are relative to the Mastercam initial WCS
view. In the arc definition, the center point for X and Y are also relative to the Mastercam initial WCS.
view.
The helper variable xresult is used to hold the Z axis position of the center point. This must be defined
outside of the implied arc definition.
The view number is passed in the helper variable t1. The function db_view is provided to get the view
number from a view matrix. Drawing is on the level defined by the helper variable db_lvl_trg.
drwarc always returns 1 if it is not set to save geometry. drwarc also returns 1 it is set to save geometry
and is successful, or 0 if not successful. See Volume 2, Intersection Function for information on xaa,
and ptnearx.
Note: When the start and end point departure is found to be greater than xtol, arcs become helical.
Helical arcs are converted to line segments based on the tolerance variable vtol. The start angle is
calculated from the view and the center to start point. This value is returned to the variable in the arc
definition. The sweep in the arc definition is positive CCW as viewed relative to the arc view matrix.
Arcs that do not become helical use the center point to define the arc depth. Helical arcs use the start
and end point for depth.
Example:
# Arc definition
result : 0
centerx : 1
centery : 2
radius : 1
start_ang : 0 # This is returned
sweep_ang : 90
color : 16
ppostblock
db_lvl_trg = 1
prv_ptnearx = 2
prv_ptneary = 2
prv_ptnearz = 3
ptnearx = 1
ptneary = 3
ptnearz = 3
xresult = 3 # Define Z for center point
t1 = 1 # Top view
result = drwarc (centerx, color )
db_view
db_view is used to set up drwarc when a view number must be obtained.
db_view takes a view matrix as the single argument and returns the view number, -1 if a view is not
found.
vec_xx : 1
vec_yx : 0
vec_zx : 0
vec_xy : 0
vec_yy : 1
vec_zy : 0
vec_xz : 0
vec_yz : 0
vec_zz : 1
new_view : 0
ppostblock
db_rot
db_rot is used to set up db_proc to rotate geometry. This function uses the helper variables ptfixx, ptfixy
and ptfixz for the rotation point (top view based) and the 3D vector axisx, axisy and axisz as the rotation
vector (top view based).
Set the helper variables prior to the call to the setup function. db_rot passes the first argument to
indicate if the user wants to blank the geometry on the source level. The second argument is the angle
to rotate in degrees.
The occurrence of the function in the post prior to the db_proc call corresponds directly to the order it is
processed.
db_rot returns 1if successful, or 0 if unsuccessful.
Note: db_rot only sets up for db_proc. No change is apparent. Call this function prior to db_proc. (See
db_proc for details.)
Example:
result : 0
p_x : 1
p_y : 0
p_z : 0
vec_x : 0
vec_y : 0
vec_z : 1
angle : 45
ppostblock
db_trn
db_trn is used to set up db_proc to translate geometry. The first argument indicates if the user wants to
blank the geometry on the source level. The second argument is a 3D vector (top view based)
indicating the translation distance. The occurrence of the function in the post prior to the db_proc call
corresponds directly to the order it is processed.
db_trn returns 1if successful, or 0 if unsuccessful.
Note: db_trn only sets up for db_proc. No change is apparent. Call this function prior to db_proc. (See
db_proc for details.)
Example:
result : 0
vec_x : 1
vec_y : 1
vec_z : 1
ppostblock
db_proc
db_proc uses the rotate and transform information from db_rot and db_trn to copy the geometry from
level to level based on the number of transform setup functions prior to the db_proc function call.
The geometry on the level set with db_lvl_src is transformed and copied to the level set with db_lvl_trg
on the first buffered transform setup. Subsequent buffered transform setup information (set with db_rot
or db_trn) copies the geometry from the last target level set to the next higher geometry level. This
process continues for the number of buffered transform setup information functions, up to 10
maximum. The second argument indicates the selection mask (see below).
Note: Set up using db_rot and/or db_trn prior to calling the function!
db_proc returns if the setup routines are not used. The level and selection mask is used to identify the
geometry processed with this function.
Note: db_lvl_src and db_lvl_trg cannot be the same level.
Example:
result : 0
ppostblock
db_lvl_src = 1
db_lvl_trg = 2
result = db_proc( 7 )
db_clr
db_clr removes geometry starting with the level set with db_lvl_trg. The first argument indicates the
number of levels to clear from.
db_lvl_trg
db_lvl_trg to remove the copies produced with the function db_proc. The second argument is passed to
indicate the selection mask. If any geometry has a toolpath associated with it, the user is warned.
Example:
result :0
ppostblock
db_lvl_trg = 1
result = db_clr(2, 7)
June 2002 Mastercam Version 9 MP Post Processor Reference Guide 13-5
Chapter 13 Graphics Functions Volume 2
delay
delay stops processing for the time entered in seconds. The minimum time accepted is a millisecond.
delay always returns 1.
Example:
ppostblock
Color values
Black 1
Blue 2
Green 3
Cyan 4
Red 5
Magenta 6
Brown 7
White 8
Dark gray 9
Light blue 10
Light green 11
Light cyan 12
Light red 13
Light magenta 14
Yellow 15
Bright white 16