Working With Cantext: New Canned Text For Version 8
Working With Cantext: New Canned Text For Version 8
MP posts from versions prior to Version 8 must be modified to take advantage of this new feature.
When selecting canned text and processing with an older MP-style post, the first canned text entry from
the Canned Text Gcode 1025 line is placed in the variable cantext and is processed as in prior versions.
All other entries are ignored.
Each of the 10 parameters has a 1-, 2-, or 4-place value. (for example 0, 12, or 1012). An unused
parameter will always be 0. Unused parameters exist because there are 10 parameters available and
you may need to use only one or two.
Note: All logic to interpret the cant_pos position flag and the cant_val canned text value must be written
into the post customization file.
g
1 2 3 4 5 6 7 8 9 10
Cant_pos1 … cant_pos10
The variables cant_pos1 … cant_pos10 represent the position where the canned text will be output for
parameters 1 through 10 on the 1025 line. The possible values of cant_pos are:
1 and 2 are the only 1000s place values that appear on the 1025 line. A cant_pos value of –1 (off) is
indicated by no 1000s place value and 0 (unused) for the parameter. A cant_pos value of 0 is indicated
by no 1000s place value and a value greater than 0 for the parameter.
cant_val1 … cant_val10
The variables cant_val1 through cant_val10 represent the actual cantext value for parameters 1 through
10 on the 1025 line. There can be up to 99 different canned text values, so cant_val will equal a value of
1 through 99. Mastercam and the MP language associate the user’s canned text selection only with a
value of 1 through 99.
The post writer must modify the post .TXT file to display the proper text in the Mastercam Canned
Text dialog box for the up to 99 canned text possibilities.
For more information, see “Customizing the post.TXT file to display text in Mastercam”.
The post writer must also modify the post to output the correct string or value based on the value (1-
99) of cant_val. For more information, see Customizing the post to associate the cant_val with the
correct output string, output variable, or post action.
cant_no
The variable cant_no represents the number of non-zero parameters on the 1025 line (that is, the
number of canned text parameters used on that particular 1025 line.) Cant_no can be used to determine
whether there is any canned text being output from a 1025 line.
With a test such as “if cant_no > 0”, you can determine whether it is necessary to break down the
parameters on the 1025 line or skip the line and move on, that is, when cant_no is not greater than 0 and
there is no canned text to be output.
1025 is the Gcode that indicates a canned text line. The 10 values on the next line are the 10 canned
text parameters that will be output by this line. (Up to 10 canned text parameters can be output at the
same time.) In this case, there are four parameters for output, so cant_no would equal 4.
The first parameter is 2, so cant_val1 = 2. There is nothing in the 1000s place, so cant_pos1 = 0 and it
will be output before the linear move that appears on the next NCI line.
The second parameter is 9, so cant_val2 = 9. There is nothing in the1000s place, so cant_pos2 = 0 and
it will be output before the linear move that appears on the next NCI line.
The third parameter is a 1006, so cant_val3 = 6. There is a 1 in the 1000s place, so cant_pos = 1 and it
will be output with the linear move that appears on the next NCI line.
The fourth parameter is a 2010, so cant_val4 = 10. There is a 2 in the 1000s place, so cant_pos = 2 and
it will be output after the linear move that appears on the next NCI line.
Parameters will be output in order of their ‘before’, ‘with’, and ‘after’ designations, and then in the
order they were selected from the Canned Text dialog box. Notice that parameter 1 and parameter 2
are both to be output before the linear move that appears on the next NCI line. In this example,
parameter 1 will be output, then parameter 2 will be output. Parameter 3 will be output with the linear
move. Finally, parameter 4 will be output after the move.
To customize the text that appears in Mastercam’s Canned Text dialog box, list the text to be displayed
line after line in a numeric list. You can have up to 99 lines or items in this list. This text is for display
in Mastercam only. It is not the text that will appear in the NC output, which is defined in the post .PST
file. Both the post .PST and .TXT files must be updated when making changes to canned text.
This also means the text in the post .TXT file (which will be displayed in Mastercam’s canned text
dialog box) does not have to be the same text that will be output to the NC file. For example, the post
.TXT file can display “Stop”, as seen in the example below, and the post .PST file can be set up to
output “M00”. However, you should associate cant_val1 with line 1, cant_val2 with line 2, etc.
Here is an example of the canned text section of a Lathe post .TXT file:
[canned text]
1. "Stop"
2. "Ostop"
3. "Bld on"
4. "bLd off"
5. "rEt. tlstk"
6. "adV. tlstk"
7. "Ret. chute"
8. "Adv. chute"
9. "eXstp on"
10. "exstP off"
11. "Canned Text 11"
12. "M12"
13. "M13"
14. "M14"
15. "M15"
16. "M16"
See Using the Post Text File for more information
The calls to pcan, pcan1, and pcan2 must be made by adding them into postblocks in the appropriate
places to create ‘before’, ‘with’, and ‘after’ results. Look at the following a plinout postblock as an
example of how the calls to pcan, pcan1, and pcan2 might be made. Pcan is called ‘before’, pcan1 is
called ‘with’, and pcan2 is called ‘after’. Strcantext is the string that actually outputs canned text.
16-4 Mastercam Version 9 MP Post Processor Reference Guide June 2002
Volume 1 Chapter 16 Working with Cantext
# -------------------------------------------------------
# Canned Text
# -------------------------------------------------------
Pcan will be called by a postblock such as plinout. Pcan clears any existing value to strcantext, and then
tests cant_no to see if there is any canned text to be output. If not, it returns to plinout and continues
processing.
If there is canned text to be output, it tests each of the 10 positions on the 1025 line to see if the canned
text is to be output ‘before’. (It’s currently in the pcan postblock, which is only going to output ‘before’
parameters.) If anything is found that should be output ‘before’, the appropriate pcant_? postblock is
called to extract the cant_val and take it to the pcant_out postblock, where the output string (strcantext) is
built. Finally, it returns here to pcan, outputs the strcantext string, and continues until all ‘before’
parameters have been processed and it can return to plinout.
Pcan1 works very similarly to pcan, except for two major differences:
! pcan1 allows canned text to pass when cant_pos = 1 for ‘with’ output.
! Upon returning from pcant_out to pcan1, pcan1 does not output the strcantext string. Since it is being
output ‘with’, it is left so strcantext can be output on the line it is supposed to be ‘with’. This way, it
can be output in the desired order on the output line (on the NC line that is generated in postblock
plinout in this example).
pcan1 # Canned text - with move ‘WITH’
strcantext = sblank
if cant_no > zero,
[
if cant_pos1 = one, pcant_1
#… Positions 2-9 here (removed for clarity in this example)
if cant_pos10 = one, pcant_10
]
if cstop, strcantext = strcantext + sm00
if cgstop, strcantext = strcantext + sm01
# Output of strcantext occurs at the end of the output line
Pcan2 works almost the same as pcan, except pcan2 is looking for ‘after’ parameters.
Pcant_1 through pcant_10 simply set the variable cantext equal to the cant_val being processed and call
pcant_out to build the output string.
Pcant_out builds the output string, that is, turns a value such as 1 into M00. In this post, the last five
lines of code mean any cantext value (or cant_val – cantext was set equal to cant_val? in the previous
postblock) greater than 4 will simply output the cantext value with an “M” in front of it. A cantext value
of 5 would output an “M5” to the NC file (lines marked #8 through #12).
In most cases, adding more options to the list of available canned text requires just a few simple steps:
! Modify the post .TXT file to display the correct text.
! Define the output string.
! Make two changes to the pcant_out postblock.
Note: Refer to the numbers at the end of each line in the pcant_out postblock shown in the preceding
section for this example.
1. Customize the post .TXT file, which is the only way to enable the use of the modifications you
make and have them visible while in Mastercam. Line 5 of the canned text section in
MPFAN.TXT has been modified here:
[canned text]
1. "Stop"
2. "Ostop"
3. "Bld on"
4. "bLd off"
5. "M52"
3. Add a postline to pcant_out to build the sm52 string into the output string when cantext = 5. After
line 7, add the following line:
If cantext = 5, strcantext = strcantext + sm52
4. Since a cantext value of 5 now has special output defined, it is necessary to modify line 8 (if cantext
> 4,) to read:
if cantext > 5,