Upload
xuanphuong2710
View
215
Download
0
Embed Size (px)
Citation preview
7/23/2019 107 Postblocks
http://slidepdf.com/reader/full/107-postblocks 1/28
Volume 1 Chapter 7 Postblocks
June 2002 Mastercam Version 9 MP Post Reference Guide 7-1
7 Postblocks
A postblock is a labeled block, or series of lines, of MP language code in the post customization file
(.PST file). The post executable file (the .DLL file) interprets the code in the postblocks to create a listof instructions that produce the NC output, perform calculations and call other postblocks. These blocks of MP language code produce the NC output.
For a list of postblock descriptions, see Volume 3, Postblocks.
The postblock role
To produce an NC file, a post processor interprets a Mastercam intermediate NC file (called the NCI
file). To do this, the post executable opens the NCI file and begins reading two lines at a time. Eachtwo-line set produces a call to a specific predefined entry postblock in the post customization file.
Predefined postblocks are postblocks defined as part of the MP language (whereas postblocks defined
by a post writer are called user-defined postblocks). An entry postblock is the point in the post
customization file where the post executable begins executing postblock instructions.
The first line in the two-line set that the post executable reads from the NCI file is the NCI Gcode. This
line contains a single value - the NCI Gcode - which is the key to how the second line will beinterpreted and how the information will be processed by the post executable.
The second line in the two-line set contains parameters that complete the data to be passed with the NCI Gcode. The post executable places these parameters values into appropriate predefined MP
variables.
A typical scenario for a motion NCI Gcode (for example, Gcode 2) follows:
1. The post executable reads the first NCI line of a two-line set and stores the single parameter on
that line as the NCI Gcode in the variable gcode.
2. The post executable then stores the parameters on the second line of the two-line set into
appropriate predefined numeric variables. For NCI Gcode 2, this would be the plane variable(plane), cutter compensation (cc), X (xnci), Y (ynci), arc center in X (xc), arc center in Y (yc), Z
(znci) position, feed rate (fr ) and the contour flag. The order of the parameters in the second
NCI line determines in which predefined variable the value on the line is stored.
3. Additional calculations are performed to generate values for other predefined variables that are
commonly used for the NCI Gcode type.
4. Routines in the post executable that were enabled in the post customization file are performed.
7/23/2019 107 Postblocks
http://slidepdf.com/reader/full/107-postblocks 2/28
Chapter 7 Postblocks Volume 1
7-2 Mastercam Version 9 MP Post Reference Guide June 2002
5. Based on the value of the NCI Gcode, the post executable calls a specific MP language
mechanism called a predefined postblock . For NCI Gcode 2, the post executable calls the predefined postblock pcir. The predefined postblock that is called based on the NCI Gcode is
an entry postblock because it is the point in the post customization file where the instructions in
the postblock begin executing.
Following the flow of the logic in the postblock, the post executable file interprets each line in
the postblock, which are called postlines. Each postline is interpreted by examining the MP
language statements contained in the line, in order from left to right.
6. Depending on the MP language statement type, a character string is assembled that is the NC
output.
7. When the post executable determines that the NC output line is complete, it writes the line to
the NC output file.
8. The post executable continues processing MP language statements until the final instruction inthe entry postblock is processed.
9. The post executable reads two more lines and repeats the process.
From this description, you can see that the role of the predefined entry postblock is to provide a starting point for processing the post writer’s MP language instructions in the post customization file. The
mechanism that controls the postblock entry also gives the post writer control over which instructions
are executed based on the NCI Gcode. The postblock structure allows the post writer to jump to other postblocks and to nest postblocks.
Postblocks support the MP language features that allow the post writer to:
! Perform calculations and MP language functions
! Perform conditional branching
! Manipulate processing in the post executable (beyond what was done with initializingnumeric variables that are post switches)
! Call routines in the post executable
! Generate NC code
Postblock structure
A postblock is a labeled series of postlines containing MP language statements that produce NC output,
branch conditionally, perform calculations, call other postblocks, and trigger routines in the postexecutable.
There are two possible postblock structures:
! Traditional postblock
! Bracketed postblock
7/23/2019 107 Postblocks
http://slidepdf.com/reader/full/107-postblocks 3/28
Volume 1 Chapter 7 Postblocks
June 2002 Mastercam Version 9 MP Post Reference Guide 7-3
Traditional postblocks
A traditional postblock has two components:
! Postblock label
! One or more postlines
The postblock label declares the traditional postblock. A postblock label usually begins with the letter“p” (although “l” and “m” can also be used), must be in the first column, and must be on a line by itself
(with the exception of the post comment “#”).
See Postblock rules summary for a more complete list of rules.
Bracketed postblocks
Another form of postblock is the bracketed postblock, which is a user-defined nested postblock . The
post writer declares a bracketed postblock by using the open and close brackets ([,]) as postline
statements surrounding the postlines to be nested.
Bracketed postblocks are intended to make the post customization file more readable and are always
used within the traditional postblocks.
Bracketed postblocks are implied postblocks, which means they do not have a postblock labels declared
by the post writer.
Note: The post executable assigns labels to implied postblocks, which are used internally when the post
customization file is parsed.
Postlines
Postlines are the remaining components of the postblock. A postblock can be declared without any
postlines but this serves no useful purpose.
Postline format rules! Can start in any column except the first.
! Must use consistent indentation to make the organization of the post clear
! All postlines that are not nested in bracketed postblocks are considered part of a postblock
until another label in the first column is encountered. This label can be another postblock
label, a variable label, or post function declaration.
! Post comments are ignored and do not end the postblock.
7/23/2019 107 Postblocks
http://slidepdf.com/reader/full/107-postblocks 4/28
Chapter 7 Postblocks Volume 1
7-4 Mastercam Version 9 MP Post Reference Guide June 2002
Traditional postblock example
pblock # This is traditional postblock declaration, a comment is allowed.
x, y, z, e # This is postline with output statements.
An example of a traditional postblock with bracketed postblocks:
pblock # This is a traditional postblock declaration, a comment is allowed.
x, y, z # This is postline with output statements.
if cc_pos, # This is postline with a conditional branching statement.
[ # This is postline with start of a bracketed postblock.
tloffno, e # This is postline in the bracketed postblock.
] # This is postline ends a bracketed postblock.
else, # This is postline with an else condition for the previous if postline.
[ # This is postline with start of a bracketed postblock.
“D0”, e # This is postline in the bracketed postblock.
] # This is postline ends a bracketed postblock.
Postblock declaration
A postblock must be declared before it can be used. Traditional and bracketed postblocks are declareddifferently.
Traditional postblocks
A traditional postblock label is used in the following ways:
! to declare the postblock
! to identify the postblock
! in a postline statement to call a postblock
Traditional postblock labels:
! Must always start in the first column
! Must begin with the letter “p”, “l”, or “m”
! May contain letters (a - z), numbers(0 - 9), and the underscore character ( _)
! May be a maximum of 25 characters long
! Must be on a separate line except for a post comment ( # )
Note: Both predefined and user-defined postblocks are declared the same way.
pcomment2 # Commentscomm = ucase (scomm)if gcode = 1007, “(“, scomm, “)”else, “(“, scomm, “)”, e
7/23/2019 107 Postblocks
http://slidepdf.com/reader/full/107-postblocks 5/28
Volume 1 Chapter 7 Postblocks
June 2002 Mastercam Version 9 MP Post Reference Guide 7-5
All postlines that are not nested in bracketed postblocks are considered part of the postblock until a
label in the first column is encountered. This label can be another postblock label, a variable label or post function declaration. Post comments are ignored and do not end the postblock.
Bracketed postblocks
A bracketed postblock is declared not by a label but by the open and close brackets ([,]) as postline
statements surrounding the postlines to be included in the bracketed postblock.
The post executable assigns a label to bracketed postblocks when the post customization file is parsed.The assigned labels can be seen when the debugging options are enabled. The labels are created by
concatenating the string “p__”, the number that is the occurrence of the bracket set, the colon “:” and
the line number in the post customization file that the open bracket was on. For example, the first bracketed set found with the “[” on line 100 would result in the post executable assigning ‘p__0:100’.
Bracketed postblocks:
! Are always inside a traditional postblock
! Start with the “[“ as an output statement on an output postline
! End with the “]“ as an output statement on an output postline! Should have the nesting brackets on separate lines except for a post comment (#)
! Can be nested to a maximum of 25 levels deep
! Are always user-defined type postblocks
Postblock types
There are many postblock types. Each type serves a purpose in the posting process. Listed here are the
main types and subtypes:
! User-defined postblocks
# Bracketed postblocks
# Standard user-defined postblocks! Predefined postblocks
# Pre-process postblocks
# Preparatory postblocks
# Pre-output postblocks
# Standard postblocks
# Command postblock
# Post-process postblock
User-defined postblocks
User-defined postblocks are declared by the post writer. User-defined postblocks can be called (or jumped to) only from another postblock and can never be called as entry postblocks based on the NCI
Gcode or from an internal post executable routine.
7/23/2019 107 Postblocks
http://slidepdf.com/reader/full/107-postblocks 6/28
Chapter 7 Postblocks Volume 1
7-6 Mastercam Version 9 MP Post Reference Guide June 2002
Predefined postblocks
Predefined postblocks are an integral part of the MP language. The labels for the predefined postblockare part of the post executable and are called by specific NCI Gcode, command statements, or post
processing order.
All predefined postblocks attempt an entry into the instruction list that was parsed from the post
customization file. If there is no postblock declaration for the predefined postblock, the attempt to enterthe instruction list fails and control is returned to the post executable.
At the end of this chapter you will find descriptions all predefined postblocks.
Pre-process postblocks
Pre-process postblocks are called before post processor reads the NCI file. These postblocks do not
have access to the NCI file data. The following are preprocess postblocks:
pprep Allows post instructions after the post is parsed but before the NC and NCI file are opened. Do not
attempt to output to the NC file in this postblock because the NC output file is not yet opened.pq Allows post instructions after the NC and NCI file are opened but before reading NCI data.
Preparatory postblocks
Preparatory postblocks have access to limited NCI data and are called optionally before the normal
processing NCI file read loop. Preparatory postblocks are called on the NC tool change Gcodes and
NCI parameter Gcodes.
The following are preparatory postblocks:
ptooltbl An obsolete routine that should no longer be used. It was used to create a tool table.
pwrtt Provides tool change data from the NCI and scanned information from the toolpaths themselves.
Note: Both ptooltbl and pwrtt are called when the NCI tool change Gcodes are found by the postexecutable in the NCI file.
pwrttparam Called by the NCI parameter Gcodes; similar to the pparameter predefined postblock routine but is partof the preparatory NCI file scan.
Note: Calls to these postblocks must be enabled in the post customization file by inserting and settingthe post switch variable tooltable to 1 (on).
ptooltbl and pwrtt are mutually exclusive. If you have used ptooltbl (not recommended) then youshould not have pwrtt in your post customization file and vice versa.
See How Preparatory Postblocks Work f or more information.
7/23/2019 107 Postblocks
http://slidepdf.com/reader/full/107-postblocks 7/28
Volume 1 Chapter 7 Postblocks
June 2002 Mastercam Version 9 MP Post Reference Guide 7-7
Pre-output postblocks
Pre-output postblocks are called based on the NCI Gcode but before internal calculations are performedin the post executable. Pre-output postblocks have labels with a “0” or “00” suffix, for example psof00,
ptlchg00, plin0, pcir0, and peof00. If pre-output postblocks are present in the post customization file, the
post executable first calls the preparatory postblock with the with the same name, for example, psof00,and then the standard postblock psof .
Important Note: Postblocks psof0 , ptlchg0 , and peof0 are not pre-output postblocks. The “0” suffix with psof0 and peof0 indicate to the post to call them if the tool number (t) is zero. The “0” suffix with
ptlchg0 indicates that the postblock is called for a null tool change (a tool change information block
where the tool number has not changed from the prior tool change).See tool_zero in Volume 3, Numeric Variables.
Standard postblocks
Standard postblocks are called based on the NCI Gcode after internal calculations are performed in the post executable.
Command postblocksCommand postblocks are called during the normal NCI file processing but perform delayed calls to
output comments, subprograms and canned cycles at locations in the NC code where the user and NCcode require them. They are provided to add flexibility when generating output of comments,
subprograms and canned cycles. The following are command postblocks:
pcomment Outputs comments to the NC file.
psub_st_m Called for transform subprograms to write the subprogram header.
psub_call_m Used for transform subprograms and a single tool to call the subprogram.
psub_call_mm Used for transform subprograms and many tools to call the subprogram.
prcc_setup Used to capture information from the roughing tool with lathe canned cycles.
Post-process postblock
A post-process postblock is called after posting has completed and all the files have been closed.
ppostThe only post-process postblock, it allows manipulating the NC file after posting.
Note: The post writer is responsible for opening the files before attempting to write to them.
7/23/2019 107 Postblocks
http://slidepdf.com/reader/full/107-postblocks 8/28
Chapter 7 Postblocks Volume 1
7-8 Mastercam Version 9 MP Post Reference Guide June 2002
Postlines
Postlines are the lines of MP language instructions within the postblock. They may appear only after
the postblock declaration and constitute the body of a postblock. Because certain conditions can allowa postline to continue over more than one line in the post customization file, you must determine where
each postline ends. Never declare variables or post functions on a postline.
For example, this postblock is from the MPFAN.PST post:
ptlchg # Tool changepcuttypetoolchng = oneif mi1 = one, # Work coordinate system[pfbld, n, *sg28ref, "X0.", "Y0.", epfbld, n, "G92", *xh, *yh, *zh, e]
pbld, n, "M01", epcom_moveb
c_mmlt # Multiple tool subprogram callptoolcommentcommentpcanpbld, n, *t, "M6", epindexsav_absinc = absincif mi1 > one, absinc = zeropcan1, pbld, n, *sgcode, *sgabsinc, pwcs, pfxout, pfyout,
pfcout, *speed, *spindle, pgear, strcantext, epbld, n, "G43", *tlngno, pfzout, scoolant, next_tool, eabsinc = sav_absincpcom_moveatoolchng = zeroc_msng # Single tool subprogram call
Postline types
Some postlines generate output and some provide logic within the post customization file.
Basic postline types are determined by the type of statement at the beginning of the postline.
Listed here are the basic postline types:
! Output
! Formula
! Boolean
Output postline
The term output postline is misleading because the statements on this postline often do not generateoutput. An output postline may contain variables, commands, string literals, ASCII decimal equivalent,
and postblock call statements, as long as the line is not a formula postline or Boolean postline.
7/23/2019 107 Postblocks
http://slidepdf.com/reader/full/107-postblocks 9/28
Volume 1 Chapter 7 Postblocks
June 2002 Mastercam Version 9 MP Post Reference Guide 7-9
Formula postline
Formula postlines are assignments or equations. A result variable followed by an equal sign (=) as thefirst item on the postline identifies a formula postline.
The following function calls should always be entered as formula postlines:
! Lookup table function call
! Parameter table function call! Buffer file function call
Boolean postline
Boolean postlines begin with the conditional operators “if”, “else”, or “while”.
Postline statements
Postline statements are the components that make up the postline. MP language rules determine where
the statement types can appear on a postline, how they are delimited, and which basic postline typesthey can be used with.
Postline statement definitions include both the variables that can be used and an action. Conditional
branching statements and formula statements are identified by formula components and keywords.Output statements include variable modifiers.
Following are the major postline statement types:
! Conditional branching statement
! Formula statement
! Output statements
# Output line variables
! Numeric variable
!
User-defined numeric variable! Forced numeric variable
! Update numeric variable
! Format numeric variable
! Dependent numeric variable
! Debug numeric variable
! Command variable
! Previous numeric variable
! User-defined string variable
! String variable
! Forced string variable
! Dependent string variable! Debug string variable
# String select function call
! Selector string variable
! Selector forced string variable
7/23/2019 107 Postblocks
http://slidepdf.com/reader/full/107-postblocks 10/28
Chapter 7 Postblocks Volume 1
7-10 Mastercam Version 9 MP Post Reference Guide June 2002
! Selector dependent string variable
! Selector debug string variable
# String literal
# Dependent string literal
# ASCII literal
# Postblock call
# User prompt function call
Conditional branching statement
The conditional branching statement begins with the conditional operators “if”, “else” or “while”,contains a Boolean formula (see “Formula statement” below) and ends at the comma (,) delimiter that
is not part of a formula function. The formula component can continue over several lines.
For example:
if speed > maxss,
Formula statement
The formula statement begins with a result variable before the equal sign (=) that is part of an equation,assignment or formula and ends where the actual postline ends (ignoring spaces and post comments).
The formula statement must remain on a single line in the post customization file:
speed = abs(ss)
Formula statements and conditional branching statements are similar, differing from each other only in:
! the keyword that determines the type (for a formula, “variable =”, or for conditional branching, “if”, “else”, “while”).
! the end delimiter (for formula, the end of the postline, or for conditional branching, a
comma).
The way the result is interpreted also differs:! A conditional branching statement is tested for true or false and the result is zero or non-zero.
! A formula statement result is returned directly in the result variable.
The following are allowed as components in the formula equation.
! Math operator
! Formula function
! Numeric variable
! User-defined numeric variable
! Previous numeric variable
! String variable
! User-defined string variable! String literal
Note: What is allowed with any particular function or operator depends on the argument types. The
components of the formula are not considered as postline statement types; the entire statementincludes the type key and the type delimiter. See Formulas for more information.
7/23/2019 107 Postblocks
http://slidepdf.com/reader/full/107-postblocks 11/28
Volume 1 Chapter 7 Postblocks
June 2002 Mastercam Version 9 MP Post Reference Guide 7-11
Output statements
The term output statement is misleading, like output postline, because the statements might notgenerate output. Output statements are not allowed in a formula statement or a conditional branching
statement. Output statements can continue over multiple lines in the post customization file and even
continue through postblock calls or jumps. Output statements are separated by placing a comma (,) between each statement. If a postline statement was not identified as a formula statement or a
conditional branching statement, it is then assumed to be one of the output statement forms.
Output statements may contain:
! Output line variables
! String select function call
! String literal
! Dependent string literal
! ASCII literal
! Postblock call
! User prompt function call
Output line variablesAny variable that is defined, either by the post executable or in the post customization file, can be placed on a postline as an output statement. You can modify how the post executable handles
processing of the variable by adding a prefix called a variable modifier (!, *, @ ~, etc.) The following
may be output line variables:
Numeric variables
Variables predefined in the post executable file (without any modifiers). Output to the NC file is
expected based on modality. For example:
x
User-defined numeric variablesVariables defined by a post writer in the post customization file when the declaration is made (the
undressed form of the variable); appears as declared in the post customization file postline. Output to
the NC file is expected based on modality. For example:
xabs
Variable modifiers
When added to numeric variables, variable modifiers change processing as follows:
Forced numeric variable (*)
Both user-defined numeric variables and numeric variables can be forced to output. The prefix asterisk
(*) overrides modality and forces output to the NC file. Output to the NC file is expected.For example:
*x, *xabs
7/23/2019 107 Postblocks
http://slidepdf.com/reader/full/107-postblocks 12/28
Chapter 7 Postblocks Volume 1
7-12 Mastercam Version 9 MP Post Reference Guide June 2002
Update numeric variable (!)
Both user-defined numeric variables and numeric variables can be forced to update. The prefixexclamation (!) updates the stored previous value for the variable. No output to the NC file is expected.
For example:
!x, !xabs
Format numeric variable (@)
User-defined numeric variables and numeric variables can be formatted. The prefix at symbol (@)formats the current value for the variable. No output to the NC file is expected. For example:
@x, @xabs
Dependent numeric variable (`)
Both user-defined numeric variables and numeric variables can be prefixed with the grave accent (`) to
permit output to the NC file only when there is other valid output on the assembled NC line. Sequence
(n) already behaves this way. For example:
`x, ̀ xabs
Debug numeric variable (~)
Both user-defined numeric variables and numeric variables can be forced to output without affectingthe values internal to the post executable for the variable. The prefix tilde (~) forces output to the NC
file for debugging. Do not use this for normal output. For example:
~x, ~xabs
Command variable
Command variables are unique in that they trigger an event or routine in the post executable, possibly
calling back to the post customization file for some postblock instructions. All command variables are predefined numeric variables. Most cannot be prefixed with a variable modifier. For example:
comment
Previous numeric variableUser-defined numeric variables and numeric variables are all automatically assigned a duplicate
variable (prv _[variable name]) for storing the previous value of the variable. This controls modality bycomparing the value stored in prv_[var] with the current [var]. Previous numeric variables should not be
used for normal output and cannot be prefixed with a variable modifier. These are usually output when
debugging. For example:
prv_xabs
User-defined string variable
Defined in the post customization file by the user when the declaration is made, this is the undressed
form of the variable and appears as declared in the post customization file postline. Output to the NC
file is expected. For example:sm00
7/23/2019 107 Postblocks
http://slidepdf.com/reader/full/107-postblocks 13/28
Volume 1 Chapter 7 Postblocks
June 2002 Mastercam Version 9 MP Post Reference Guide 7-13
String variable
Variables of this type are the predefined variables in the post executable file. This is the undressedform of the string variable. Output to the NC file is expected. For example:
snamenc
When added to string variables, the variable modifiers change processing as follows:
Forced string variable (*)
Both user-defined string variables and string variables can be forced to output. The prefix asterisk (*)
override forces output to the NC file. Output to the NC file is expected. For example:
*snamenc, *sm00
Dependent string variable (`)
Both user-defined string variables and string variables can be prefixed with the grave accent (`) to
permit output to the NC file only when there is other valid output on the assembled NC line. Sequence
(n) already behaves this way. For example:
` snamenc, ̀ sm00
Debug string variable (~)
Both user-defined string variables and string variables can be forced to output. The prefix tilde (~)
forces output to the NC file for debugging. Do not use this for normal output. For example:
~ snamenc, ~ sm00
String select function calls
The string select function call is the target string in a string select function. The placement of the string
name as an output statement is sufficient to call the mechanism.
Selector string variable
The selector string variable is the target string in a string select function. The function allows the stringto inherit the modality of the numeric variable selector. Output to the NC file is expected based on themodality of numeric variable selector. For example:
sgcode
When added to selector variables, the variable modifiers change processing as follows:
Selector forced string variable (*)
The selector string variable can be forced to output. The prefix asterisk (*) forces output to the NC file.
Output to the NC file is expected. For example:
*sgcode
The selector string variable can be prefixed with the grave accent (`) to permit output to the NC fileonly when there is other valid output on the assembled NC line. Sequence (n) already behaves this way.For example:
`sgcode
7/23/2019 107 Postblocks
http://slidepdf.com/reader/full/107-postblocks 14/28
Chapter 7 Postblocks Volume 1
7-14 Mastercam Version 9 MP Post Reference Guide June 2002
Selector debug string variable (~)
The selector string variable can be forced to output. The prefix tilde (~) forces output to the NC file fordebugging. Do not use this for normal output. For example:
~sgcode
String literals (“ “)
A string literal is actually a form of user-defined string declaration. The character string is enclosedwithin double quotes (“”). The syntax implies a user-defined string variable when parsed by the post
executable. Output to the NC file is forced. For example:
”M12”
Dependent string literals
A dependent string literal is identical to a string literal except that the character string is enclosed
within single quotes (‘’). This permits output to the NC file when there is other valid output on the
assembled NC line. Sequence (n) already behaves this way. For example:
’M12’
ASCII literals
Any of the standard ASCII characters can be output to the NC file by entering the decimal equivalent
(0 to 255 ) of the desired character as an output statement. Output to the NC file is forced. For
example (the pound character (#) is ASCII 035):
35
Postblock calls
To call a postblock, place the name of the postblock as an output statement. The post executable marksthe position where the jump occurs and passes processing of postline instructions to the called
postblock. No output is generated. For example:pblock
User prompt function calls
The prompt function call is not a variable but is a combination of the letter ‘q’ and the matchingnumber of the post function for user prompt function (fq). When the trigger is encountered as an output
statement, the post processor pauses, displays the prompt text in Mastercam, and waits for the user’sresponse. No output is generated. For example:
q1
7/23/2019 107 Postblocks
http://slidepdf.com/reader/full/107-postblocks 15/28
Volume 1 Chapter 7 Postblocks
June 2002 Mastercam Version 9 MP Post Reference Guide 7-15
Restrictions on using postline types and statements
Postline types have restrictions that limit the postline statements that can be used with a postline.
Additional restrictions define where delimiters must be placed for postline statements.
Formula postline
Formula postlines are identified by a result variable followed by an equal sign (=) as the first item onthe line. This postline type is the most restricted—it can have only a single formula statement. No
other statement types are allowed and the postline cannot continue on another line in the post
customization file. A post comment can be included at the end of the postline.
Output postline
The post executable identifies a postline as an output postline when it does not succeed in identifying it
as a formula postline or a Boolean postline. Each statement on the output postline must be separated by
a comma (,). Any output statement can be placed on the output postline as long as it is separated by the
comma delimiter. For clarity, it is better to place the command variables and user prompt function calls
on separate lines.
The output postline can continue over multiple lines in the post customization file if a comma is placed
after the last output statement on the line. The command variable (e) should be placed at the end of anyoutput postline that has output statements that generate NC code. The command variable (e) calls the NC line ‘end of block’ characters, normally carriage return and line feed.
No Boolean statements or formula statements are allowed in an output postline.
Boolean postline
The Boolean postline is the most complicated of the postline types. Because it performs conditional
branching in the postblock, an action must follow the conditional branching statement. The conditional branching statement is identified by the conditional operators ‘if’, ‘else’ or ‘while’, the formula, and the
ending comma.
After the conditional branching statement comma delimiter, you may enter either an output statement
or a single formula statement. You may not enter another conditional branching statement. If you
enter a series of output statements, they must be a continuous series with a comma used to continue theseries. In other words, the action cannot be a ‘multiple postline type’ structure.
To use multiple postlines as an action, you must call the postblock by using either a declared postblock
name or a bracketed postblock.
The ‘if’ and ‘while’ Boolean postlines can stand alone and are independent of any other codingrequirements. The ‘else’ Boolean postline must always immediately follow an ‘if’ Boolean postline.
The ‘if-else’ structure is limited to a single ‘else’ Boolean statement. To expand the ‘if-else’ to an ‘if’-
‘if-else’-‘else’ type structure, you must use the bracketed postblocks and nest consecutive ‘if-else’structures.
7/23/2019 107 Postblocks
http://slidepdf.com/reader/full/107-postblocks 16/28
Chapter 7 Postblocks Volume 1
7-16 Mastercam Version 9 MP Post Reference Guide June 2002
Postblock/postline examples
Following are examples of the postblocks, postline types, and postline statements from MPFAN.PST.The MP language code here is commented with the post comment and highlighted to identify each of
the types on the postline.
psof #Start of file (Predefined postblock, Standard postblock)
#Output postline, Postblock call pcuttype
#Formula postline, Formula statementtoolchng = one#Boolean postline, Conditional branching statement if ntools = one,#Bracketed postblock, begin [#skip single tool outputs, stagetool must be on
# Formula postline, Formula statement stagetool = m_one#Output postline, Update numeric variable !next_tool
#Bracketed postblocks, end ]
#Output postline, String literal, Command variable "%", e#Output postline, Forced numeric variable, Command variable *progno, e#Output postline, String literal, Numeric variable, String literal, Command variable "(PROGRAM NAME - ", progname, ")", e#Output postline, String literal, Command variable, String literal, Command variable, String literal, Command
variable "(DATE=DD-MM-YY - ", date," TIME=HH:MM - ", time, ")",e#Output postline, Postblock call, Numeric variable, Selector forced string variable, Command variable
pbld, n, *smetric, e#Output postline, Postblock call, Numeric variable, Selector forced string variable, Selector forced string variable,
String literal, String literal, Selector forced string variable, Command variable pbld, n, *sgcode, *sgplane, "G40", "G49", "G80", *sgabsinc, e
#Formula postline sav_absinc = absinc#Boolean postline, Conditional branching statement if mi1 <= one,#Bracketed postblock, begin [#Formula postline absinc = one#Output postline, Postblock call, Numeric variable, Selector string variable, String literal, Command variable
pfbld, n, sgabsinc, *sg28ref, "Z0.", e
7/23/2019 107 Postblocks
http://slidepdf.com/reader/full/107-postblocks 17/28
Volume 1 Chapter 7 Postblocks
June 2002 Mastercam Version 9 MP Post Reference Guide 7-17
#Output postline, Postblock call, Numeric variable, Selector forced string variable, String literal, String literal,
Command variable pfbld, n, *sg28ref, "X0.", "Y0.", e
#Output postline, Postblock call, Numeric variable, String literal, Forced numeric variable, Forced numeric
variable, Forced numeric variable, Command variable pfbld, n, "G92", *xh, *yh, *zh, e
#Formula postline
absinc = sav_absinc#Bracketed postblock, end ]
#Output postline, Postblock call pcom_moveb
#Output postline, Command variable c_mmlt #Multiple tool subprogram call#Output postline, Postblock call
ptoolcomment#Output postline, Command variable comment#Output postline, Postblock call
pcan#Boolean postline, Conditional branching statement, Output statement if stagetool >= zero, pbld, n, *t, "M6", e#Output postline, Postblock call
pindex#Boolean postline, Conditional branching statement, Formula statement if mi1 > one, absinc = zero#Output postline, Postblock call, Numeric variable, Selector forced string variable, Selector forced string variable,
Postblock call, Postblock call, Postblock call, Forced numeric variable, Selector forced string variable, Postblock
call, String variable, Command variable pcan1, pbld, n, *sgcode, *sgabsinc, pwcs, pfxout, pfyout, pfcout,
*speed, *spindle, pgear, strcantext, e #Output postline, Postblock call, String literal, Forced numeric variable, Postblock call, Selector string variable,
Numeric variable, Command variable pbld, n, "G43", *tlngno, pfzout, scoolant, next_tool, e
#Formula postline absinc = sav_absinc#Output postline, Postblock call
pcom_movea#Formula postline toolchng = zero#Output postline, Command variable c_msng #Single tool subprogram call
Studying these code examples should give the novice post writer a basic understanding of how
statements and postline types are assembled.
7/23/2019 107 Postblocks
http://slidepdf.com/reader/full/107-postblocks 18/28
Chapter 7 Postblocks Volume 1
7-18 Mastercam Version 9 MP Post Reference Guide June 2002
Postblock rules summary! Two types of postblock exist in the MP language: the traditional postblock that has a label
identification and the bracketed postblock that is an implied postblock.
! Traditional postblocks must have the postblock label begin in the first column.
! Postblock labels begin with letter “p”. The letters “m” or “l” identify postblocks used withmill/turn applications.
! A postblock label must be on a line by itself (except for post comments).
! A postblock label may contain a maximum of 25 characters consisting of letters (a - z), numbers
(0 - 9), and the underscore ( _ ).
! User-defined postblock labels must not duplicate predefined postblock labels.
! Any MP language function or definition that starts in the first column following continuoustraditional postblock postline(s) ends that postblock. The exception is the post comment (#), which
is ignored.
! Postlines encapsulated in the open and close brackets ([,]) define a bracketed postblock.
! The post executable file assigns an internal postblock label to bracketed postblocks. The labels arecreated by concatenating the string “p__”, the number that represents the occurrence of the bracket
set, the colon “:”, and the line number in the post customization file that the open bracket was on.
This is displayed when debugging or with error messages.
! The open and close brackets ([,]) that encapsulate the postlines in a bracketed postblock should be
on lines by themselves.
! The brackets used to define the bracketed postblock must be indented following the same rules as a postline.
! Bracketed postblocks must be wholly contained in a single traditional postblock. Nested bracketed
postblocks must be wholly contained in the brackets of the nesting bracketed postblock.
! Bracketed postblocks may be nested to 25 levels deep.
Postline rules summary! Postlines must always be indented. Never start the postline in the first column!
! NC lines are built in the order in which the output statements occur on the postline. Modality,
variable modifiers, and other factors control what is actually output to the NC file.
! Separate output statements with commas.
! Output statements can continue over multiple lines by placing a comma at the end of the line (and
before any post comment).
7/23/2019 107 Postblocks
http://slidepdf.com/reader/full/107-postblocks 19/28
Volume 1 Chapter 7 Postblocks
June 2002 Mastercam Version 9 MP Post Reference Guide 7-19
! A series of output statements that are intended to produce NC output should be terminated with thee command variable. This tells the post executable to write the end-of-block characters.
! Output statements may follow the comma delimiter on a Boolean postline.
! A single formula statement on a single line can follow the comma delimiter on a Boolean postline.
! A formula postline must be on a single line. Do not put more than a one formula statement on a
formula postline.
! A conditional branching statement can never follow the comma delimiter on a Boolean postline.
Use a bracketed postblock or call a traditional postblock.
! A conditional branching statement can continue over multiple lines until the comma delimiter isfound.
! In a conditional branching statement, use a space to separate the Boolean keyword (if, else, while)from the formula.
Postblock call dependencies
The processing of the NCI data and the predefined postblock that is eventually called depends on:
! the settings in the post customization file
! the linear motion type that is being processed
Different predefined postblocks may be called for the same initial NCI Gcode passed to the postexecutable file depending on these variables. This section describes the logic used to determine the
postblock called in those cases where the predefined postblock call is conditional.
Note: The postblock calls for the ‘whatno’ processing are described here. ‘whatno’ processing is basedon the occurrence of motion after a tool change and is not a recommended practice. Future versions of
MP language will no longer support this type of processing.
Postblock calls for Gcode 0 and 1 in Mill/Lathe
The following list shows postblock calls with the NCI Gcode 0 and 1 for rapid and feed linear motion.
After examining output conditions in Determine if general linear or broken/Z only motion call, jump to
either Z only motion postblock calling or General motion postblock calling to determine the final
output postblock. See Volume 3, Numeric Variables f or more information on the numeric variablesused in the presented logic.
Determine if general linear or broken/Z only motion call! If Z moved (difference z to prv_z)
and not on a tool changeand not 5 axis drill (drill5)
and not lathe (posttype)
and no_brk = 0 and gcode = 0 or no_brk = 2 –
# Z only moved – Z only motion postblock calling
# Z moved negative –
7/23/2019 107 Postblocks
http://slidepdf.com/reader/full/107-postblocks 20/28
Chapter 7 Postblocks Volume 1
7-20 Mastercam Version 9 MP Post Reference Guide June 2002
! General motion postblock calling
! Z only motion postblock calling
# Z moved positive –
! Z only motion postblock calling
! General motion postblock calling
! otherwise – General motion postblock calling
Note: When motion is broken as XY then Z or Z then X, the output is controlled by the post executableby writing the previous (prv_var) value of the numeric variable x, y or z to the appropriate current
numeric variable x, y or z. Manipulating these variables prior to the break up motion can result in
unexpected behavior in your NC output.
Z only motion postblock calling! rotaxtyp >= 6 or whatno is yes –
# NCI Gcode = 0 – Call pzrapid
# NCI Gcode = 1 - Call pz
! otherwise –
# whatline = 1 – Call pz1
# whatline = 2 – Call pz # whatline = 0 or > 2 –
! NCI Gcode = 0 – Call pzrapid
! NCI Gcode = 1 - Call pz
General motion postblock calling! rotaxtyp >= 6 or whatno is yes –
# NCI Gcode = 0 –
! posttype = 1 (Mill) –o mrapid in post – Call mrapid
o otherwise – Call prapid
! posttype = 2 (Lathe) –o lrapid in post – Call lrapid o otherwise – Call prapid
# NCI Gcode = 1 –
! posttype = 1 (Mill) –
o mlin in post – Call mlin o otherwise – Call plin
! posttype = 2 (Lathe) –o llin in post – Call llin
o otherwise – Call plin
! otherwise –
# whatline = 1 – Call plin1 # whatline = 2 – Call plin2
# whatline = 0 or > 2 –
! NCI Gcode = 0 – Call prapid
! NCI Gcode = 1 - Call plin
7/23/2019 107 Postblocks
http://slidepdf.com/reader/full/107-postblocks 21/28
Volume 1 Chapter 7 Postblocks
June 2002 Mastercam Version 9 MP Post Reference Guide 7-21
Postblock calls for Gcode 2 and 3 in Mill/Lathe
The NCI Gcode 2 or 3 for circular motion. Follow the structure shown here for postblock calling.
General motion postblock calling! rotaxtyp >= 6 or whatno is yes –
# NCI Gcode = 2 or 3 –
! posttype = 1 (Mill) –o mcir in post – Call mcir o otherwise – Call pcir
! posttype = 2 (Lathe) –
o lcir in post – Call lcir o otherwise – Call pcir
! otherwise –
# whatline = 1 – Call pcir1
# whatline = 2 – Call pcir2
# whatline = 0 or > 2 – Call pcir
Postblock calls for Gcode 11 in Mill NCI Gcode 11 defines continuous 5-axis motion in Mill toolpaths. The numeric variable rotaxtyp determines the routines called with 5-axis motion. This section defines the routines and postblock calls
for NCI Gcode 11 when rotaxtyp is less than 6. When rotaxtyp is greater than 6, refer to the section
Postblock calls for Gcode 0 and 1 in Mill/Lathe. Assume the NCI Gcode of 1 when applying the logicto Postblock calls for Gcode 0 and 1 in Mill/Lathe.
The following variables influence the postblock called for output when rotaxtyp is less than 6. They
also enable the routines that add lead in and lead out moves to a toolpath and apply lead and lag to thetool.
A two-part lead in move is added to a toolpath and a two-part lead out move is added to the end of atoolpath if the following numeric variables are not zero for the move they are applied to.
ldinl1 The length of first lead-in move, measured from first point in cut. If ldinl1 = 0, this move will be
eliminated.
ldina1 The lead-in angle measured from first cut segment, in degrees. A lead-in angle of 0 would yield a
tangent lead-in.
ldinl2
The length of second lead-in move. This allows for a change from rapid to plunge feed rate. if ldinl2 =0, this move will be eliminated.
ldina2 The lead-in angle measured from first cut segment, in degrees. A lead-in angle of 0 would yield a
tangent lead-in.
7/23/2019 107 Postblocks
http://slidepdf.com/reader/full/107-postblocks 22/28
Chapter 7 Postblocks Volume 1
7-22 Mastercam Version 9 MP Post Reference Guide June 2002
ldoutl1 The length of lead-out move, measured from last point in cut. If ldoutl1 = 0, this move will be
eliminated.
ldouta1 The lead-out angle measured from last cut segment, in degrees. A lead-out angle of 0 would yield atangent lead-out.
ldoutl2 The length of second lead-out move. This allows for a change from rapid to plunge feed rate. If ldoutl2
= 0, this move will be eliminated.
ldouta2 The lead-out angle measured from last cut segment, in degrees. A lead-out angle of 90 would yield a
lead-out normal to surface.
Figure: 5-axis lead in/lead out
The drawing shows the relative location on the 5-axis toolpath where each move is generated by the post executable. These moves are not part of the NCI file but are created in the post executable.
CALCULATED
VECTOR
CALCULATED
VECTOR
LDOUTL1
LDINL2
LDOUTL2
The lead in motion is started when the NCI Gcode 11 is passed to the internal routine and the numeric
variable whatline is 0. The post executable delays this first position until the second position is readfrom the NCI file so that the cut direction can be determined. Normally, whatline is set to 0 in
ptlchg1002 when using the programming technique enabled with tlchng_aft. This routine (tlchng_aft) is
designed to include the motion NCI data after the tool change NCI gcode (1000, 1001 and 1002) line as
part of the tool change series of lines. Otherwise, whatline is assigned 0 in the psof , and ptlchg postblocks.
The lead out motion is triggered when the numeric variable cutpos, read from the NCI file, is equal to 3.
The called postblock depends on the setting of the lead in and lead out variables. If the move waseliminated because the numeric variable was 0, a call is not generated to the predefined postblock.
7/23/2019 107 Postblocks
http://slidepdf.com/reader/full/107-postblocks 23/28
Volume 1 Chapter 7 Postblocks
June 2002 Mastercam Version 9 MP Post Reference Guide 7-23
Before each output postblock call, the internal routine to apply the numeric variables tilt (for tilt along
cut direction) and rhtilt (tilt perpendicular to cut direction) is called. At the end of the routine thatapplied the tilt (if non-zero), a call is made to the postblock pmx0. Now, the postblock is called for the
NC output instructions in the post customization file.
Postblock calling for Gcode 11! whatline = 2 –
# Lead in Line 1 is valid – Call pmx1 # Lead in Line 2 is valid –
! whatline is set to 3
! Call pmx1
# Original position is output – Call pmx2
! whatline = 4 and cutpos <> 3 - Call pmx
! cutpos = 3 –
# Lead out Line 1 is valid – Call pmx1
# Lead out Line 2 is valid – Call pmx1
Note: The routines shown here are obsolete. In prior versions of Mastercam, the post would
generate many of the moves to and from a 5-axis toolpath, modify the lead and lag angles, etc. I t isrecommended that any motion that can be generated in Mastercam be used before using the
routines in the post executable to creating motion or modify motion.
Postblock calls for Gcode 81 and 100 in Mill/Lathe
Canned drilling cycles can be output as long code or as canned drilling cycles. See Working with Drill
Cycles for more information. The structure here represents the calling order when output has been
designated for canned cycles. Long code output calls to the Postblock calls for Gcode 0 and 1 in
Mill/Lathe output structure.
Postblock calling for NCI Gcode 81
! drillcyc = 0 –# posttype = 1 (Mill) –
! mdrill in post – Call mdrill
! otherwise – Call pdrill # posttype = 2 (Lathe) –
! ldrill in post – Call ldrill
! otherwise – Call pdrill
! drillcyc = 1 –
# posttype = 1 (Mill) –
! mpeck in post – Call mpeck
! otherwise – Call ppeck # posttype = 2 (Lathe) –
! lpeck in post – Call lpeck
! otherwise – Call ppeck ! drillcyc = 2 –
# posttype = 1 (Mill) –
7/23/2019 107 Postblocks
http://slidepdf.com/reader/full/107-postblocks 24/28
Chapter 7 Postblocks Volume 1
7-24 Mastercam Version 9 MP Post Reference Guide June 2002
! mchpbrk in post – Call mchpbrk
! otherwise – Call pchpbrk
# posttype = 2 (Lathe) –
! lchpbrk in post – Call lchpbrk
! otherwise – Call pchpbrk
! drillcyc = 3 –
#posttype = 1 (Mill) –
! mtap in post – Call mtap
! otherwise – Call ptap
# posttype = 2 (Lathe) –
! ltap in post – Call ltap
! otherwise – Call ptap
! drillcyc = 4 –
# posttype = 1 (Mill) –
! mbore1 in post – Call mbore1
! otherwise – Call pbore1
# posttype = 2 (Lathe) –
! lbore1 in post – Call lbore1 ! otherwise – Call pbore1
! drillcyc = 5 –
# posttype = 1 (Mill) –
! mbore2 in post – Call mbore2
! otherwise – Call pbore2 # posttype = 2 (Lathe) –
! lbore2 in post – Call lbore2
! otherwise – Call pbore2
! drillcyc = 6 –
# posttype = 1 (Mill) –
! mmisc1 in post – Call mmisc1
! otherwise – Call pmisc1 # posttype = 2 (Lathe) –
! lmisc1 in post – Call lmisc1
! otherwise – Call pmisc1 ! drillcyc = 7 –
# posttype = 1 (Mill) –
! mmisc2 in post – Call mmisc2
! otherwise – Call pmisc2
# posttype = 2 (Lathe) –
! lmisc2 in post – Call
lmisc2
! otherwise – Call pmisc2
7/23/2019 107 Postblocks
http://slidepdf.com/reader/full/107-postblocks 25/28
Volume 1 Chapter 7 Postblocks
June 2002 Mastercam Version 9 MP Post Reference Guide 7-25
Postblock calling for NCI Gcode 100! drillcyc = 0 –
# posttype = 1 (Mill) –
! mdrill_2 in post – Call mdrill_2
! otherwise – Call pdrill_2
# posttype = 2 (Lathe) –
! ldrill_2 in post – Call ldrill_2 ! otherwise – Call pdrill_2
! drillcyc = 1 –
# posttype = 1 (Mill) –
! mpeck_2 in post – Call mpeck_2
! otherwise – Call ppeck_2
# posttype = 2 (Lathe) –
! lpeck_2 in post – Call lpeck_2
! otherwise – Call ppeck_2
! drillcyc = 2 –
# posttype = 1 (Mill) –
! mchpbrk_2 in post – Call mchpbrk_2
! otherwise – Call pchpbrk_2
# posttype = 2 (Lathe) –
! lchpbrk_2 in post – Call lchpbrk_2
! otherwise – Call pchpbrk_2
! drillcyc = 3 –
# posttype = 1 (Mill) –
! mtap_2 in post – Call mtap_2
! otherwise – Call ptap
# posttype = 2 (Lathe) –
! ltap_2 in post – Call ltap_2 ! otherwise – Call ptap_2
! drillcyc = 4 –
# posttype = 1 (Mill) –
! mbore1_2 in post – Call mbore1_2
! otherwise – Call pbore1_2 # posttype = 2 (Lathe) –
! lbore1_2 in post – Call lbore1_2
! otherwise – Call pbore1_2
! drillcyc = 5 –
# posttype = 1 (Mill) –
! mbore2_2 in post – Call mbore2_2 ! otherwise – Call pbore2_2
# posttype = 2 (Lathe) –
! lbore2_2 in post – Call lbore2_2
! otherwise – Call pbore2_2
7/23/2019 107 Postblocks
http://slidepdf.com/reader/full/107-postblocks 26/28
Chapter 7 Postblocks Volume 1
7-26 Mastercam Version 9 MP Post Reference Guide June 2002
! drillcyc = 6 –
# posttype = 1 (Mill) –
! mmisc1_2 in post – Call mmisc1_2
! otherwise – Call pmisc1_2
# posttype = 2 (Lathe) –
! lmisc1_2 in post – Call lmisc1_2
!
otherwise – Call pmisc1_2 ! drillcyc = 7 –
# posttype = 1 (Mill) –
! mmisc2_2 in post – Call mmisc2_2
! otherwise – Call pmisc2_2
# posttype = 2 (Lathe) –
! lmisc2_2 in post – Call lmisc2_2
! otherwise – Call pmisc2_2
Note: Even though the postblocks are in the MP language, you would never expect to have a Lathe NCI
Gcode 100.
Postblock calls for tool end in Mill/Lathe
The end of a toolpath can be assumed to be the NCI Gcode 1011 that starts the tool change series of
NCI lines. The structure here represents the calls to the postblock based on the numeric variableposttype. This postblock is not called on the very first NCI Gcode 1011 because no toolpath exists before that NCI line.
! NCI Gcode = 1011 –
# posttype = 1 (Mill) –
! mtoolend in post – Call mtoolend
! otherwise – Call ptoolend
# posttype = 2 (Lathe) –
! ltoolend in post – Call ltoolend ! otherwise – Call ptoolend
Postblock calls for Gcode 0, 1, 20, 21 in Wire
This indented structure shows the postblock calling with the NCI Gcode 0, 1, 20 and 21 for rapid and
feed linear motion.
Note: “General motion postblock calling” is the only routine used to determine the output postblock in
Wire.
General motion postblock calling
! whatno is yes –# NCI Gcode = 0 or 20 – Call prapid
# NCI Gcode = 1 or 21 – Call plin
! otherwise –
# whatline = 1 – Call plin1
# whatline = 2 – Call plin2
7/23/2019 107 Postblocks
http://slidepdf.com/reader/full/107-postblocks 27/28
Volume 1 Chapter 7 Postblocks
June 2002 Mastercam Version 9 MP Post Reference Guide 7-27
# whatline = 3 – Call plin3
# whatline = 0 or > 2 –
! NCI Gcode = 0 – Call prapid
! NCI Gcode = 1 - Call plin
Note: Output calls for Direct Wirepaths are based on the numeric variable uvflag . The post executable
actually reads four lines from the NCI, but the first set (20s NCI Gcode) determines the actual call.
Postblock calls for Gcode 2, 3, 22, 23 in Wire
This indented structure shows the postblock calling with the NCI Gcode 2, 3, 22 and 23 for circular
motion. The heading General motion postblock calling is the only routine used to determine the output
postblock in Wire.
General motion postblock calling! whatno is yes –
# NCI Gcode = 2, 3, 22 or 23 – Call pcir
! otherwise –
# whatline = 1 – Call pcir
# whatline = 2 – Call pcir # whatline = 3 – Call pcir
# whatline = 0 or > 2 –
! NCI Gcode = 2, 3, 22 or 23 - Call pcir
Note: Output calls for Direct Wirepaths are based on the numeric variable uvflag . The postexecutable actually reads four lines from the NCI, but the first set (20s NCI Gcode) determines theactual call.
7/23/2019 107 Postblocks
http://slidepdf.com/reader/full/107-postblocks 28/28
Chapter 7 Postblocks Volume 1
7-28 Mastercam Version 9 MP Post Reference Guide June 2002