Post Processor Training Guide
Post Processor Training Guide
Post Processor Training Guide
I
CAM Post Processor Guide 8/28/19
Table of Contents
3.3.7 The Matrix Object ............................................................................................................ 3-44
3.4 Expressions ............................................................................................................................. 3-47
3.5 Conditional Statements............................................................................................................ 3-48
3.5.1 The if Statement ............................................................................................................... 3-48
3.5.2 The switch Statement........................................................................................................ 3-49
3.5.3 The Conditional Operator (?) ............................................................................................ 3-51
3.5.4 The typeof Operator ......................................................................................................... 3-51
3.5.5 The conditional Function .................................................................................................. 3-52
3.5.6 try / catch.......................................................................................................................... 3-52
3.5.7 The validate Function ....................................................................................................... 3-52
3.5.8 Comparing Real Values .................................................................................................... 3-53
3.6 Looping Statements ................................................................................................................. 3-53
3.6.1 The for Loop .................................................................................................................... 3-53
3.6.2 The for/in Loop ................................................................................................................ 3-54
3.6.3 The while Loop ................................................................................................................ 3-54
3.6.4 The do/while Loop ........................................................................................................... 3-55
3.6.5 The break Statement ......................................................................................................... 3-55
3.6.6 The continue Statement .................................................................................................... 3-56
3.7 Functions ................................................................................................................................ 3-56
3.7.1 The function Statement ..................................................................................................... 3-56
3.7.2 Calling a function ............................................................................................................. 3-57
3.7.3 The return Statement ........................................................................................................ 3-57
II
CAM Post Processor Guide 8/28/19
Table of Contents
4.6 onTerminate ............................................................................................................................ 4-95
4.7 onCommand ............................................................................................................................ 4-96
4.8 onComment ............................................................................................................................. 4-97
4.9 onDwell .................................................................................................................................. 4-98
4.10 onParameter .......................................................................................................................... 4-99
4.10.1 getParameter Function .................................................................................................. 4-100
4.10.2 getGlobalParameter Function........................................................................................ 4-101
4.11 onPassThrough .................................................................................................................... 4-102
4.12 onSpindleSpeed ................................................................................................................... 4-102
4.13 onOrientateSpindle .............................................................................................................. 4-102
4.14 onRadiusCompensation ....................................................................................................... 4-103
4.15 onMovement ....................................................................................................................... 4-104
4.16 onRapid ............................................................................................................................... 4-105
4.17 onExpandedRapid ............................................................................................................... 4-106
4.18 onLinear .............................................................................................................................. 4-106
4.19 onExpandedLinear .............................................................................................................. 4-108
4.20 onRapid5D .......................................................................................................................... 4-108
4.21 onLinear5D ......................................................................................................................... 4-109
4.22 onCircular ........................................................................................................................... 4-111
4.22.1 Circular Interpolation Settings ...................................................................................... 4-113
4.22.2 Circular Interpolation Common Functions .................................................................... 4-114
4.22.3 Helical Interpolation ..................................................................................................... 4-115
4.22.4 Spiral Interpolation ....................................................................................................... 4-116
4.22.5 3-D Circular Interpolation ............................................................................................. 4-117
4.23 onCycle ............................................................................................................................... 4-117
4.24 onCyclePoint ....................................................................................................................... 4-118
4.24.1 Drilling Cycle Types .................................................................................................... 4-119
4.24.2 Cycle parameters .......................................................................................................... 4-121
4.24.3 The Cycle Planes/Heights ............................................................................................. 4-122
4.24.4 Common Cycle Functions ............................................................................................. 4-124
4.24.5 Pitch Output with Tapping Cycles ................................................................................ 4-125
4.25 onCycleEnd ......................................................................................................................... 4-126
4.26 onRewindMachine .............................................................................................................. 4-126
4.27 Common Functions ............................................................................................................. 4-127
4.27.1 writeln .......................................................................................................................... 4-127
4.27.2 writeBlock .................................................................................................................... 4-127
4.27.3 toPreciseUnit ................................................................................................................ 4-128
4.27.4 force--- ......................................................................................................................... 4-129
4.27.5 writeRetract .................................................................................................................. 4-130
III
CAM Post Processor Guide 8/28/19
Table of Contents
5.4 onPassThrough ...................................................................................................................... 5-141
IV
CAM Post Processor Guide 8/28/19
1 Introduction to Post Processors
1.1 Scope
This manual is intended for those who wish to make their own edits to existing post processors. The
scope of the manual covers everything you will need to get started; an introduction to the recommended
editor (Autodesk Fusion 360 Post Processor Editor), a JavaScript overview (the language of Autodesk
post processors), in-depth coverage of the callback functions (onOpen, onSection, onLinear, etc.), and a
lot more information useful for working with the Autodesk post processor system.
It is expected that you have some programming experience and are knowledgeable in the requirements
of the machine tool that you will be creating a post processor for.
If you would like a bit more information on the G-code format the CNC Handbook contains a lot of
useful information including a further explanation of the G-code format in Chapter 5 CNC Programming
Language.
Though most controls recognize the G-code format the machine configuration can be different and some
codes could be supported on one machine and not another, or the codes could be interpreted differently,
for example one machine may support circular interpolation while another requires linear moves to cut
the circle, which is why you will probably need a separate post processor for each of your machine tools.
Other places to check for a post processor include the HSM Post Processor Forum or HSM Post
Processor Ideas.
It is possible that Autodesk has already created a post processor for your machine, but has not officially
released it yet. These posts are considered to be in Beta mode and are awaiting testing from the
community before placing into production. You can visit the HSM Post Processor Ideas site and search
for your post here. This site contains post processor requests from users and links to the posts that are in
Beta mode. You can search for your machine and/or controller to see if there is a post processor
available.
If your post processor is not found, then you should search the HSM Post Processor Forum using the
same method you used on the HSM Post Processor Ideas site. The Post Processor Forum is used by the
HSM community to ask questions and help each other out. It is possible that another user has created a
post to run your machine.
You should always take care when running output from a post processor for the first time on your
machine, no matter where the post processor comes from. Even though the post processor refers to
your exact name, it may be setup for options that your machine does not have or the output may not be
in the exact format that you are used to running on the machine.
When using Fusion 360 it is recommended that you enable cloud posts and place it in your Asset
Library. This way post processors, tool libraries, and templates will be synched across devices and users
at a company.
Once you have uploaded your post(s) to the Cloud Library you can access these from Fusion 360. You
do this by pressing the Setup button in the Post Process dialog and selecting your post from the
dropdown menu.
1. Make the modifications yourself using this manual as a guide and by asking for assistance from
the HSM community on the HSM Post Processor Forum.
2. Visit HSM Post Processor Ideas and create a request for a post processor for your machine.
Other users can vote for your request for Autodesk to create and add your post to our library.
3. Contact one of our CAM partners who offer post customization services. These partners can be
found on the HSM Post Processor Forum at the top of the page.
No matter which method you decide to use to create your post processor, you should have enough
information available to define the requirements, which includes as much of the following as you can
gather.
• Milling
• Turning and Mill/Turn
• Stock Transfers
• Waterjet-Laser-Plasma
• Probing
You can visit the Autodesk Manufacturing Lounge for more information on the benchmark parts.
• 2D
• Drilling
• Coolant codes
• Manual NC commands
• 3+2 5-axis
• 5-axis simultaneous
• Waterjet
• Laser
• Plasma
• Lead in/out
• Radius compensation
• Color coding
• Automatic closing and matching of parenthesis and brackets
• Automatic indentation
• Intelligent code completion
• Automatic syntax checking
• Function List
• Run the post processor directly from editor
• Match the output NC file line to the post processor command that created it
This will download an installation program that you can run to do the actual install. Left click on the
installation program to execute it.
Follow the instructions displayed on the screen to finish the installation. You should select the defaults
for all questions, though you may want to make this the default code editor and add it to the Windows
Explorer file context menu.
After installing the Autodesk Fusion 360 Post Processor Utility extension you will want to exit the VSC
editor and then restart it so that the extension is initialized. You are now ready to start editing Autodesk
post processors.
There is a description that explains the setting making it easy for you to make the changes.
The following table provides a list of some of the more common settings and their descriptions.
Setting Description
Editor > Minimap Controls if the minimap is shown. The
minimap is a small representation of the entire
file displayed on the right side of the window
and allows you to easily scroll through the file.
Editor: Font Size Size of the editor font.
Editor: Font Weight Weight (thickness) of the editor font.
Editor: Detect Indentation Automatically detects the editor.tabSize and
editor.insertSpaces settings when opening a
file.
Editor: Insert Spaces When checked, spaces will be inserted into the
file when the tab key is pressed.
Editor: Tab Size Sets the number of spaces a tab is equal to. The
standard setting for Autodesk post processors is
2.
Editor > Parameter Hints Enables a pop-up that shows parameter
documentation and style information as you
type.
Editor: Auto Closing Brackets Controls if the editor should automatically close
brackets after opening them.
Extensions: Auto Check Update or Auto Updates Automatically (check for) update extensions.
Files: Associations Associates file types with a programming
language. This must have "*.cps": "javascript"
Autodesk Post Processor Editor 2-17
CAM Post Processor Guide 8/28/19
Setting Description
set in it to enable the automatic features of the
editor in Autodesk post processors.
Workbench: Color Theme Defines the color theme for the editor. This
setting can be changed using the File-
>Preferences->Color theme menu.
HSMPost Utility: Auto Update Function List Updates the function list automatically, without
the need for refreshing.
HSMPost Utility: Sort Function List Alphabetically When checked the function list will be sorted.
Unchecked will display the function names in
the order that they are defined.
HSMPost Utility: Color Output When checked, rapid, feedrate, and circular
blocks will be displayed in color.
HSMPost Utility: Rapid Color Color for rapid move blocks.
HSMPost Utility: Linear Color Color for feedrate move blocks.
HSMPost Utility: Circular Color Color for circular move blocks.
HSMPost Utility: Enable Auto Line Selection Enables the automatic selection of the line in
the post processor that generated the selected
line in the output NC file.
HSMPost Utility: Output Units Sets the desired output units when post
processing
HSMPost Utility: Shorten Output Code Limits the number of blocks output when
posting, making it easier to navigate.
HSMPost Utility: Post On CNCSelection When checked, post processing will occur as
soon as a CNC file is selected.
HSMPost Utility: Post On Save Automatically run the post processor when it is
saved, only if the NC output file window is
open.
Commonly Changed User Settings
The Explorer flyout contains expandable lists that are used to display the open editors, folders, variables,
functions, and CNC selector. The arrow ► at the left of each entry is used to expand or collapse the list.
List Description
OPEN EDITORS Lists the files that are open in this instance of the
VSC editor. Any files that have been changed,
but not been saved will be marked with a bullet
(•). The number of changed files that have not
been saved is displayed in the Explorer icon.
NO FOLDERS OPEN You can open a folder for quick access to all of
the post processors in the folder. Expanding the
folders will display the Open Folder button that
can be used to open a folder. Clicking on a file in
the open folder will automatically open it in the
editor. Take note that if a folder is opened, then
all opened files in the editor will first be closed
and you will be prompted to save any that have
been changed.
OUTLINE Lists the functions defined in the post processor
and the variables defined in each function.
Expanding the function by pressing the arrow ►
to the left of the function name will display the
variables defined in the function. You can select
any of the variables to go to the line where it is
defined.
You can search for a text string in the current file or in all of the opened files. To search for the text
string in the current file you should use the Find popup window accessed by pressing the Ctrl+F keys.
Ctrl+F Find Popup – Search for a Text String in the Current File
As you type in a text string the editor will automatically display and highlight the next occurrence of the
text in the file. The number of occurrences of the text string in the file will be displayed to the right of
the text field. You can use the Enter key to search for the next occurrence of the string or press the
arrow keys to search forwards → and backwards ← through the file. If you use the Enter key, then the
keyboard focus must be in the Find field.
Entering a text string to search for and then pressing the Enter key will display the files that contain the
text string and the number of instances of the text string in each file. You can expand the file in the list
by pressing the arrow key ► and each instance of the text string found in the selected file will be
displayed. Clicking on one of the instances causes the editor to go to that line in the file and
automatically open the file if it is not already opened. If you don't make any changes to the file and then
select the text string in another file, then the first file will be closed before opening the next file. An
unchanged file opened from the Search flyout will have its name italicized in the editor window.
There are options that are available when searching for text strings. These options are controlled using
the icons in the Search dialog and Find popup.
Icon Description
When enabled, the case of the search string must be the same as the matching text
string in the file.
When enabled, the entire word of the matching text string in the file must be the
same as search string. When disabled, it will search for the occurrence of the search
string within words.
When enabled, the '.' character can be used as a single character wildcard and the '*'
character can be used as a multi-character wildcard in the search string.
Autodesk Post Processor Editor 2-22
CAM Post Processor Guide 8/28/19
Icon Description
Search forward in the file. In the Find popup only.
Search backward in the file. In the Find popup only.
Searches for the text string only in the selected text in the file. In the Find popup
window only.
Closes the Find popup window.
Refresh the results window. In the Search flyout only.
Collapse all expanded files in the results window. In the Search flyout only.
Displays fields that allow you to include or exclude certain files from searches. In
the Search flyout only.
Displays the Replace field, allowing you to replace the Search text with the Replace
field text.
Replaces the current (highlighted) occurrence of the Search text with the Replace
field text. Hitting the Enter key while in the Replace field performs the same
replacement. In the Find popup window only.
Replaces all occurrences of the Search text with the Replace field text. When
initiated from the Search flyout, all occurrences of the text in all files listed in the
Results window will be replaced.
Search and Replace Options
Okay, so the Bookmarks flyout is actually a Breakpoints flyout, but since JavaScript does not have an
interactive debugger we are going to use it for adding bookmarks to the opened files. Placing the cursor
to the left of the line number where you want to set a bookmark will display a red circle and then
clicking at this position will add the bookmark.
To see the active bookmarks you can open the Bookmarks flyout and expand the BreakPoints window.
You can then go directly to a line that is bookmarked by selecting that line in the Bookmarks flyout.
Bookmarks set in all opened files will be displayed in the flyout and the file that the bookmark is set in
will automatically be made the active window when the bookmark is selected.
Visual Studio Code is an open source editor and there are many extensions that have been added to it by
the community. For example, the Autodesk Fustion 360 Post Processor Utility is an extension to this
editor. By opening the Extensions flyout you can see what extensions you have installed and what
extensions have updates waiting for them.
If there is an Update to x.x.x button displayed with the extension you can press this button to install the
latest version of the associated extension.
You can search the Visual Studio Marketplace for extensions that are beneficial for your editing style by
typing in a name in the Search Extensions in Marketplace field. For example, if you want a more
dedicated way to set bookmarks you can type in bookmark in this field and all extensions dealing with
adding bookmarks will be displayed. You can press the green Install button to install the extension.
You can also search for extensions online at the Visual Studio Marketplace.
This section will go over some of the more commonly used features. You are sure to discover other
features as you use the editor.
If the Editor: Parameter Hints setting is set to true, then when you type in the name of a function,
including the opening parenthesis, you will be supplied the names of the function's arguments for
reference.
You can close the window by pressing on the X in the window footer or the X at the top right of the
Problems window.
Autodesk Post Processor Editor 2-25
CAM Post Processor Guide 8/28/19
Displaying Syntax Errors
Go to Line Number
Modifications and/or additions to the Shortcut Key assignments can be made by selecting the
keybindings.json link at the top of the page. This will open a split window display that displays the
default Shortcut Keys in the left window and the user defined Shortcut Keys in the right window. Use
the same procedure as modifying a setting to modify a Shortcut Key, by copying the binding definition
from the left window into the right window and making the desired changes. Be sure to save the
keybindings.json file after making your changes.
The format of the keystrokes that represent a single Shortcut is defined in the following table.
Running a Command
If you add a new property to the post or for some reason the properties don’t display, you can press the
yellow refresh symbol in the Post Properties header to refresh the displayed properties.
You can also select the CNC file from the Post Utility menu.
Select the CNC File or Post Processor Using the Post Utility Command
You can press the Browse… button to search for post.exe. The executable will be in one of the
following locations depending on the version of HSM being run.
username is your user name that you logged in as. (id) is a unique and long name that changes
depending on the version of Fusion that you have installed. You will usually select the folder
with the latest date.
Inventor C:\Program Files\Autodesk\InventorHSM yyyy
Once you have posted against the CNC file, the output NC file or Log file will be displayed in the right
panel of the split screen. When the HSMPostUtility: Enable Auto Line Selection setting is true, then
clicking twice on a line in the output NC file will highlight the line in the post processor that generated
the output. The second click must be on a different character on the same output line to highlight the
line. Then, by clicking on a different character in the same line you will be walked through the stack of
functions that were called in the generation of the output.
First you will need to download the export cnc file to vs code.cps post processor. You can do this by
running the Download CNC exporting post processor command.
A file browser will come up that allows you to select the folder where you want to download the post.
Follow the directions in the Downloading and Installing a Post Processor section for installing a post
processor on your system.
Once the post processor is installed you will want to post process the operations you want to use for
testing. The CNC exporting post processor is run just like any other Autodesk post processor, except it
will not generate NC code, but will rather create a copy of the CNC file from the Autodesk CAM system
in the Custom location of the CNC Selector folder. Most posts use a number for the output file name, it
is recommended that you give the CNC file a unique name that describes the operations that were used
to generate it.
Once you click the yellow refresh button you should see the CNC file in the Custom branch of the CNC
Selector list and can use it when post processing from the VSC editor. If you decide that you no longer
Using a Custom CNC Intermediate File Deleting a Custom CNC Intermediate File
3 JavaScript Overview
3.1 Overview
Autodesk post processors are written using the JavaScript language. It resembles the C, C++, and Java
programming languages, is interpreted rather than being a compiled language, and is object-orientated.
JavaScript as it is used for developing post processors is fairly simple to learn and understand, but still
retains its complex nature for more advanced programmers.
This chapter covers the basics of the JavaScript language and conventions used by Autodesk post
processors. There are many web sites that document the JavaScript language. The ELOQUENT
JAVASCRIPT site has a nicely laid out format. If you prefer a hard copy JavaScript guide, then the
JavaScript the Definitive Guide, Author: David Flanagan, Publisher: O’Reilly is recommended.
Whichever manual you use, you will want to focus on the core syntax of JavaScript and ignore the
browser and client-side aspects of the language.
The Autodesk post processor documentation is provided as the post.chm file with HSMWorks and
Inventor HSM or you can visit the Autodesk CAM Post Processor Documentation web site. You will
find that the post.chm version of the documentation is easier to view, since it has a working Index.
currentCoolant = 7;
currentCoolant = 8;
currentcoolant = 9;
Case Sensitive Definition of 3 Different Variables
There are two methods of defining comments in JavaScript. You can either enclose comments between
the /* and */ characters, which will treat all text between these delimiters as a comment, or place the //
characters prior to the comment text.
The /* comment */ format is typically used as the descriptive header of a function or to block out
multiple lines of code. Any characters on the line that follow the // characters are treated as a comment,
so you can have a single comment line or add a comment to the end of a JavaScript statement.
/**
Output a comment.
*/
function writeComment(text) {
writeln(formatComment(text)); // write out comment line
}
..
/*
switch (unit) {
case IN:
writeBlock(gUnitModal.format(20));
break;
case MM:
writeBlock(gUnitModal.format(21));
break;
}
*/
Comment Lines
Using indentation for function contents, if blocks, loops and continuation lines is recommended as this
makes it easier to visualize the code. Tab characters, though supported by JavaScript, are discouraged
from being used. It is preferred to use virtual tab stops of two spaces for indenting code in post
processor code. Most editors, including the Autodesk Post Processor Editor can be setup to
automatically convert tab characters to spaces that will align each indent at two spaces. Please refer to
the Post Processor Editor chapter for an explanation on how to setup the Autodesk recommended editor.
3.3 Variables
Variables are simply names associated with a value. The value can be a number, string, boolean, array,
or object. Variables in JavaScript are untyped, meaning that they are defined by the value that they have
assigned to them and the value type can change throughout the program. For example, you can assign a
number to a variable and later in the program you can assign the same variable a string value. The var
keyword is used to define a variable.
If a variable is not assigned a value, then it will be assigned the special value of undefined.
While you can include multiple variable declarations on the same var line, this is against the standard
used for post processors and is not recommended. You can also implicitly create a variable simply by
assigning a value to the variable name without using the var keyword, but is also not recommended.
When declaring a new variable, be sure to not use the same name as a JavaScript or Post Kernel
keyword, for example do not name it var, for, cycle, currentSection, etc. Refer to the appropriate
documentation for a list of keywords/variables allocated in JavaScript or the Post Kernel.
JavaScript supports both global variables and local variables. A global variable is defined outside the
scope of a function, for example at the top of the file prior to defining any functions. Global variables
are accessible to all functions within the program and will have the same value from function to
function. Local variables are only accessible from within the function that they are defined. You can
use the same name for local variables in multiple functions and they will each have their own unique
value in the separate functions. Unlike the C and C++ languages, local variables defined within an if
block or loop are accessible to the entire function and are not local to the block that they are defined in.
3.3.1 Numbers
Besides containing a standard numeric value, a variable assigned to a number creates a Number object.
For this discussion, we will consider an object a variable with associated functions. These functions are
specific to numbers and are listed in the following table.
JavaScript Overview 3-36
CAM Post Processor Guide 8/28/19
Function Description Returns
toExponential(digits) Format a number using exponential String representation of number
notation
toFixed(digits) Format a number with a fixed number String representation of number
of digits
toLocaleString() Format a number according to locale String representation of number
conventions
toPrecision(digits) Format a number using either a fixed String representation of number
number of digits or using exponential
notation depending on value of
number
toString() Format a number String representation of number
Number Object Functions
var a = 12.12345;
b = a.toExponential(2); // b = "1.21e+1"
b = a.toFixed(3); // b = "12.123"
b = a.toString(); // b = "12.12345"
Sample Number Output
The JavaScript built-in Math object contains functions and constants that apply to numbers. The
following table lists the Math functions and constants that are most likely to be used in a post processor.
All Math functions return a value.
a = Math.sqrt(4); // a = 2
a = Math.round(4.59); // a = 5
The Math trigonometric functions all work in radians. As a matter of fact, most functions that pass
angles in the post processor work in radians. There are kernel supplied functions that are available for
converting between radians and degrees. toDeg(x) returns the degree equivalent of the radian value x
and conversely the toRad(x) function returns the radian equivalent of the degree value x.
3.3.2 Strings
Variables assigned a text string will create a String object, which contain a full complement of functions
that can be used to manipulate the string. These functions are specific to strings and are listed in the
following table. The table details the basic usage of these functions as you would use them in a post
processor. Some of the functions accept a RegExp object which is not covered in this manual, please
refer to dedicated JavaScript manual for a description of this object.
3.3.3 Booleans
Booleans are the simplest of the variable types. They contain a value of either true of false, which are
JavaScript keywords.
3.3.4 Arrays
An array is a composite data type that stores values in consecutive order. Each value stored in the array
is considered an element of the array and the position within an array is called an index. Each element
of an array can be any variable type and each element can have a different variable type than the other
elements in the array.
An array, like numbers and strings, are considered an object with functions associated with it. You can
define an array using two different methods, as an empty array using a new Array object, or by creating
an array literal with defined values for the array. You can specify the initial size of the array when
defining an Array object. The initial size of an array defined with values is the number of values
contained in the initialization.
var a = new Array(); // creates a blank array, all values are assigned undefined
JavaScript Overview 3-39
CAM Post Processor Guide 8/28/19
var a = new Array(10); // creates a blank array with 10 elements
var a = [true, "a", 3.17]; // creates an array with the first 3 elements assigned
var a = [{x:1, y:2}, {x:3, y:4}, {x:5, y:6}]; // creates an array of 3 xy objects
Array Definitions
You can access an array element by using the [ ] brackets. The name of the array will appear to the left
of the brackets and the index to the element within the array inside of the brackets. The index can be a
simple number or an equation.
The Array object has the following functions associated with it.
3.3.5 Objects
An Object is similar to an array in that it stores multiple values within a single variable. The difference
is that objects use a name for each sub-entity rather than relying on an index pointer into an array. The
properties table in a post processor is an object. You can define an object using two different methods,
explicitly using the Object keyword, or implicitly by creating an object literal with defined names and
values for the object. Each named entity within an object can be any type of variable, number, string,
array, boolean, and another object. Objects can also be stored in an array.
Objects can be expanded to include additional named elements at any time and are not limited to the
named elements when they are created.
The following tables describe the attributes and functions contained in the Vector object. Since an
attribute is simply a value contained in the Vector object, it does not have an argument.
Attribute Description
abs Contains the absolute coordinates of
the vector
length Contains the length of the vector
length2
negated Contains the negated vector
normalized Contains the normalized/unit vector
x Contains the X-component
y Contains the Y component
z Contains the Z component
Vector Attributes
You can directly modify an attribute of a vector, but if you do then the remaining attributes will not be
updated. For example, if you directly store a value in the x attribute, vec.x = .707, the length attribute of
the vector will not be updated. You should use the vec.setX(.707) method instead.
If the Returns column in the following table has Implicit, then there is no return value, rather the Vector
object associated with the function is modified implicitly. For this reason, if you are going to nest a
Vector function within an expression, do not use the Implicit function, but rather the equivalent function
that returns a vector.
Certain post processor variables are stored as matrices, such as the workPlane variable, and some
functions require matrices as input. A Matrix object has functions that can be used when creating the
matrix and are not dependent on working with an existing matrix.
The following tables describe the attributes and functions contained in the Matrix object. Since an
attribute is simply a value contained in the Matrix object, it does not have an argument.
You can directly modify an attribute of a matrix, but if you do then the remaining attributes will not be
updated. For example, if you directly store a vector in the forward attribute, the other attributes will not
be updated to reflect this modification. You should use the matrix.setForward(vector) method instead.
If the Returns column in the following table has Implicit, then there is no return value, rather the Matrix
object associated with the function is modified implicitly. For this reason, if you are going to nest a
Matrix function within an expression, do not use the Implicit function, but rather the equivalent function
that returns a matrix.
3.4 Expressions
Variables can be assigned a simple value or text string, or can be more complex in nature containing a
list of variables or literals and operators that perform operations on the values contained in the
expression. The following table lists the common operators supported by JavaScript. and provides
samples using the operators. The operator precedence is also listed (column P), where the operators
with a higher precedence number are performed prior to the operators of a lower precedence number.
Operators with the same precedence number will calculate in the order that they appear in the
expression.
Unary operators only require a single operand instead of two. For example, y = x++ will increment the
variable x after it is assigned to the variable y.
This section describes the conditional statements and functions used when developing a post processor.
Some of the conditionals are supported by JavaScript and others are inherent in the post processor
kernel.
As with all commands that affect a body of code, if statements can be nested inside of other if bodies and
loops.
The syntax of if statements should follow the Autodesk standard of always including the {} brackets
around each body of code, specifying the opening bracket ({) on the conditional line, and the closing
if (conditional1) {
// execute code if conditional1 is true
}
if (conditional1) {
// execute code if conditional1 is true
} else {
// execute code if conditional1 is false
}
if (conditional1) {
// execute code if conditional1 is true
} else if (conditional2) {
// execute code if conditional1 is false and conditional2 is true
} else {
// execute code if all conditionals are false
}
If Statement Syntax
if (hasParameter("operation-comment")) {
comment = getParameter("operation-comment");
}
if (isProbeOperation()) {
var workOffset = probeOutputWorkOffset ? probeOutputWorkOffset : currentWorkOffset;
if (workOffset > 99) {
error(localize("Work offset is out of range."));
return;
} else if (workOffset > 6) {
probeWorkOffsetCode = probe100Format.format(workOffset - 6 + 100);
} else {
probeWorkOffsetCode = workOffset + "."; // G54->G59
}
}
Sample If Statements
case statements should follow the Autodesk standard of always including specifying the opening bracket
({) on the switch line, and the closing bracket (}) at the start of the line at the end of the body of code for
each section. The case statements will be aligned with the switch statement and all code within each
case body will be indented.
switch (variable) {
case value1:
// execute if variable = value1
break;
case value2:
// execute if variable = value2
case value3:
// execute if variable = value3
default:
// execute if variable does not equal value1, value2, or value3
break;
}
switch (coolant) {
case COOLANT_FLOOD:
m = 8;
break;
case COOLANT_THROUGH_TOOL:
m = 88;
break;
case COOLANT_AIR:
m = 51;
break;
default:
onUnsupportedCoolant(coolant);
}
}
Sample Switch Blocks
In the above syntax, a will be assigned true_value if the conditional is true, or false_value if it is false.
The typeof operator is followed by a single operand name, i.e. "typeof variable". It can return the
following string values.
conditional(expression, true_value)
conditional Syntax
writeBlock(
gRetractModal.format(98), gAbsIncModal.format(90), gCycleModal.format(82),
getCommonCycle(x, y, z, cycle.retract),
conditional(P > 0, "P" + milliFormat.format(P)), //optional
feedOutput.format(F)
);
conditional Usage
try {
// code that may generate an exception
} catch (e) { // e is a local variable that contains the exception object or value that was thrown
// code to perform if an exception is encountered
}
try/catch Syntax
try {
programId = getAsInt(programName);
} catch(e) {
error(localize("Program name must be a number."));
return;
}
try/catch Usage
validate(expression, error_message)
validate Syntax
JavaScript Overview 3-52
CAM Post Processor Guide 8/28/19
validate(retracted, "Cannot cancel length compensation if the machine is not fully retracted.");
Sample validate Code
var a = 3.141592654;
var b = 3.141593174;
// simple comparison
if (a == b) { // false
The syntax of looping statements should follow the Autodesk standard of always including the {}
brackets around each body of code, specifying the opening bracket ({) on the looping statement, and the
closing bracket (}) at the start of the line following the body of code for the loop. Loops can be nested
within other bodies of code, like conditionals or other loops.
for (var i = 0; i < getNumberOfSections(); ++i) { // loop for the number of sections in intermediate file
if (getSection(i).workOffset > 0) {
error(localize("Using multiple work offsets is not possible if the initial work offset is 0."));
return;
}
}
for (i = 0, j = ary.length - 1 ; i < ary.length / 2; ++i, --j) { // reverse the order of an array
var tl = ary[i];
ary[i] = ary[j];
ary[j] = tl;
}
Sample for Loops
for(variable in object) {
// body of loop
}
for/in Loop Syntax
do {
// body of loop
} while (expression)
do/while Loop Syntax
var i = 0;
var found = false;
do {
if (mtype[i++] == "Start") {
found = true;
}
} while (!found && i < mtype.length);
Sample do/while Loop
break is pretty much mandatory with switch statements. For loops, break can be used to get out of the
loop when an error is encountered, or when a defined pattern is found within an array.
3.7 Functions
Functions in JavaScript behave in the same manner as functions in other high-level programming
languages. In a post processor all code, except for the global settings at the top of the file, is contained
in functions, either entry functions (onOpen, onSection, etc.) or helper functions (writeBlock,
setWorkPlane, etc.). The code in a function will not be processed until that function is called from
within another routine (for the sake of clarity the calling function will be referred to as a 'routine' in this
section). Here are the main reasons for placing code in a separate function rather than programming it in
the upper level routine that calls the function.
1. The same code is executed in different areas of the code, either from the same function or in
multiple functions. Placing the common code in its own function eliminates duplicate code from
the file, making it easier to understand and maintain.
2. To logically separate logic and make it easier to understand. Separating code into its own
function can keep the calling routine from becoming too large and harder to follow, even if the
function is only called one time.
function writeComment(text) {
writeln(formatComment(text)); // text is accepted as an argument and passed to formatComment
}
Sample function Definition
Arguments accepted by a function can either be named identifiers as shown in the previous example, or
you can use the arguments array to reference the function arguments. The arguments array is built-in to
JavaScript and is treated as any other Array object, meaning that it has the length property and access to
the Array attributes and functions.
transferType = parseChoice(properties.transferType,"PHASE","SPEED","STOP");
…
function parseChoice() {
for (var i = 1; i < arguments.length; ++i) {
if (String(arguments[0]).toUpperCase() == String(arguments[i]).toUpperCase()) {
return i - 1;
}
}
return -1;
}
Sample Usage of arguments Array
return [expression]
return Statement Syntax
The return value can be any valid variable type; a number, string, object, or array. If you want to return
multiple values from a function, then you must return either an object or an array. You can also
propagate the JavaScript this object which will be automatically returned to the calling routine when the
end of the function is reached or when processing a return statement without an expression. If the this
object is used, then the function will be used to create a new object and you will need to define the
function call as if you were creating any other type of object as shown in the following example.
function writeComment(text) {
writeln(formatComment(text));
} // implicit return
function parseChoice() {
for (var i = 1; i < arguments.length; ++i) {
if (String(arguments[0]).toUpperCase() == String(arguments[i]).toUpperCase()) {
return i - 1; // return the matching choice
}
}
return -1; // return choice not found
}
var feedContext = new FeedContext(id, "Cutting", feedCutting); // create new FeedContext object
Sample return Usage
4 Entry Functions
The post processor Entry functions are the interface between the kernel and the post processor. An
Entry function will be called for each record in the intermediate file. Which Entry function is called is
determined by the intermediate file record type. All Entry functions have the 'on' prefix, so it is
recommended that you do not use this prefix with any functions that you add to the post processor.
Here is a list of the supported Entry functions and when they are called. The following sections in this
Chapter provide more detailed documentation for the most common of the Entry functions.
Setting Description
allowedCircularPlanes Defines the allowed circular planes. This setting is described in the
onCircular section.
allowHelicalMoves Specifies whether helical moves are allowed. This setting is described in
the onCircular section.
allowSpiralMoves Specifies whether spiral moves are allowed. This setting is described in
the onCircular section.
capabilities Defines the capabilities of the post processor. The capabilities can be
CAPABILITY_MILLING, CAPABILITY_TURNING,
CAPABILITY_JET, CAPABILITY_SETUP_SHEET, and
CAPABILITY_INTERMEDIATE. Multiple capabilities can be enabled
by using the logical OR operator.
mapToWCS = true;
mapToWCS = false;
mapWorkOrigin Specifies whether the coordinates are mapped to the work plane origin.
When disabled the post is responsible for handling the work plane origin.
This variable must be defined using the following syntax and can only be
defined in the global section. Any deviation from this format, including
adding extra spaces, will cause this command to be ignored.
mapWorkOrigin = true;
mapWorkOrigin = false;
maximumCircularRadius Specifies the maximum radius of circular moves that can be output as
circular interpolation and can be changed dynamically in the Property
table when running the post processor. This setting is described in the
onCircular section.
maximumCircularSweep Specifies the maximum circular sweep of circular moves that can be
output as circular interpolation. This setting is described in the onCircular
section.
minimumChordLength Specifies the minimum delta movement allowed for circular interpolation
and can be changed dynamically in the Property table when running the
post processor. This setting is described in the onCircular section.
minimumCircularRadius Specifies the minimum radius of circular moves that can be output as
circular interpolation and can be changed dynamically in the Property
table when running the post processor. This setting is described in the
onCircular section.
minimumCircularSweep Specifies the minimum circular sweep of circular moves that can be output
as circular interpolation. This setting is described in the onCircular
section.
minimumRevision The minimum revision of the post kernel that is supported by the post
processor. This value will remain the same unless the post processor takes
advantage of functionality added to a later version of the post engine that
is not available in earlier versions.
programNameIsInteger Specifies whether the program name must be an integer (true) or can be a
text string (false).
tolerance Specifies the tolerance used to linearize circular moves that are expanded
into a series of linear moves. This setting is described in the onCircular
section.
unit Contains the output units of the post processor. This is usually the same as
the input units, either MM or IN, but can be changed in the onOpen
function of the post processor by setting it to the desired units.
vendor Name of the machine tool manufacturer.
vendorUrl URL of the machine tool manufacturer's web site.
Post Kernel Settings
Entry Functions 4-61
CAM Post Processor Guide 8/28/19
description = "RS-274D";
vendor = "Autodesk";
vendorUrl = "http://www.autodesk.com";
legal = "Copyright (C) 2012-2017 by Autodesk, Inc.";
certificationLevel = 2;
minimumRevision = 24000;
longDescription = "Generic post for the RS-274D format. Most CNCs will use a format very similar
to RS-274D. When making a post for a new CNC control this post will often serve as the basis.";
extension = "nc";
setCodePage("ascii");
capabilities = CAPABILITY_MILLING;
tolerance = spatial(0.002, MM);
When you Post Process from HSM you will be presented with a dialog that allows you to select the post
processor to execute, the output file path, and other settings. The Property Table will also be displayed
in the dialog allowing you to override settings within the post processor each time it is run.
The Property Table is defined in the post processor so you have full control over the information
displayed in it, with the exception of the Built-in properties, which are displayed with every post
processor and define the post kernel variables described previously. The properties object defined in the
post processor defines the property names as they are used in the post processor along with the default
values assigned to each property.
// user-defined properties
properties = {
writeMachine: true, // write machine
writeTools: true, // writes the tools
preloadTool: true, // preloads next tool on tool change if any
showSequenceNumbers: true, // show sequence numbers
sequenceNumberStart: 10, // first sequence number
sequenceNumberIncrement: 5, // increment for sequence numbers
optionalStop: true, // optional stop
separateWordsWithSpace: true // specifies that the words should be separated with a white space
rotaryTableAxis: "none" // none, X, Y, Z, -X, -Y, -Z
};
Property Table Definition
The default values for the variables can be a number, boolean, or a text string.
The propertyDefinitions object gives you control on how you want the properties displayed to the user in
the Property Table. There should be a matching entry in the propertyDefinitions object for every entry
in the properties object. If there is not a matching entry, then the variable name from the properties
object will be displayed and this property will not have tool tip text associated with it.
The following table describes the supported variable properties in the propertyDefinitions object. It is
important that the format of the propertyDefinitions object follows the above example, where the name
of the variable is first, followed by a colon (:), and the properties enclosed in braces ({}). The values
property is an array and its properties must be enclosed in brackets ([]).
Property Description
title Description of the variable displayed in the User Interface within the Property
column.
Entry Functions 4-64
CAM Post Processor Guide 8/28/19
Property Description
description A description of the variable displayed as the tool tip when the mouse is
positioned over this variable.
group The group number that this variable belongs to. All variables with the same
group number will be displayed together in the User Interface. (This property
is not supported as of this writing)
type Defines the input type. The input types are described in the following table.
values Contains a list (array) of choices for the enum or integer input type. It is not
valid with any other input type.
Property Table User Interface Definition
The createFormat command defines how codes are formatted before being output to the NC file. It can
be used to create a complete format for an output code, including the letter prefix, or to create a primary
format that is referenced with the output definitions. It has the following syntax.
The specifiers must be enclosed in braces ({}) and contain the specifier name followed by a colon (:)
and then by a value. Multiple specifiers are separated by commas.
Specifier Value
prefix Defines the prefix of the output value as a text string. The prefix should
only be defined if this is a standalone format and is not used for multiple
output definitions.
suffix Defines the suffix of the output value as a text string. The suffix should
only be defined if this is a standalone format and is not used for multiple
output definitions.
decimals Defines the number digits to the right of the decimal point to output. The
default is 6.
forceDecimal When set to true the decimal point will always be included with the
formatted number. false will remove the decimal point for integer values.
forceSign When set to true will force the output of a plus (+) sign on positive
numbers. The default is false.
width Specifies the minimum width of the output string. If the formatted value's
width is less than the width value, then the start of the number will either be
filled with spaces or zeros depending on the value of zeropad. If the format
is used to output a code to the NC file be sure to set zeropad to true,
otherwise the prefix and value could be separated by spaces. The width of
the output string includes the decimal point when it is included in the
number, but not the sign of the number. The default is 0.
zeropad When set to true will fill the beginning of the output string with zeros to
match the specified width. If width is not specified or the output string is
longer than width, then no zeros will be added. The default is false.
trim When set to true the trailing zeros will be trimmed from the right of the
decimal point. The default is true.
trimLeadZero When set to true will trim the lead zero from a floating-point number if the
number is fractional, e.g. .123 instead of 0.123. The default is false.
Once a format is created, it can be used to create a formatted text string of a value that matches the
properties in the defined format. The following table describes the functions defined in the format
object.
Function Description
areDifferent(a, b) Returns true if the input values are different after being formatted.
format(value) Returns the formatted text string representation of the number.
getError(value) Returns the inverse of the remaining portion of the value that is not
formatted for the number. For example, if the formatted value of 4.5005 is
"4.500", then the value returned from getError will be -0.0005.
getMinimumValue() Returns the minimum value that can be formatted using this format, for
example, 1 for decimals:0, .1 for decimals:1, etc.
getResultingValue Returns the real value that the formatted output text string represents.
(value)
isSignificant(value) Returns true if the value will be non-zero when formatted.
format Functions
The createVariable and createModal objects can be used interchangeably since they both output only
the values that have changed. In a post processor you will see that the createModal object is used for
the output of G-code or M-code modal groups, where multiple codes can be output in a single block and
will only be output when the code changes value from the previous code in this group. The
createVariable object is used for all other code/register output such as the axes registers, spindle speed,
feedrates, etc. The only difference in these objects the functions that belong to them, for example you
can disable the output of a Variable, but not of a Modal.
You can use the createFormat object for codes/registers that should be output whenever they are
encountered in the post, just be sure to add the prefix to the definition.
The specifiers must be enclosed in braces ({}) and contain the specifier name followed by a colon (:)
and then by a value. Multiple specifiers are separated by commas. A format object is provided as the
second parameter. Some of the specifiers are common to all three objects and some to a particular
object, as listed in the following table.
The onchange property typically defines a function that is called whenever the formatting of the variable
results in an output text string, such as when the value changes or is forced out. The following example
will force out the gMotionModal code whenever the plane code is changed.
Once an output variable is created, it can be used to create a formatted text string for output. The
following table describes the functions assigned to the output variable objects. The functions are
properties of the defined variable object.
var WARNING_WORK_OFFSET = 0;
var ANGLE_PROBE_NOT_SUPPORTED = 0;
var ANGLE_PROBE_USE_ROTATION = 1;
var ANGLE_PROBE_USE_CAXIS = 2;
Sample Fixed Settings Code
// collected state
var sequenceNumber;
var currentWorkOffset;
Sample Collected State Code
4.2 onOpen
function onOpen() {
The onOpen function is called at start of each CAM operation and can be used to define settings used in
the post processor and output the startup blocks.
if (properties.useRadius) {
maximumCircularSweep = toRad(90); // avoid potential center calculation errors for CNC
}
The majority of machines on the market today accept input in both inches and millimeters. It is possible
that your machine must be programmed in only one unit. If this is the case, then you can define the unit
variable in the onOpen function to force the output of all relevant information in inches or millimeters.
if (true) {
var aAxis = createAxis({coordinate:0, table:true, axis:[1, 0, 0], range:[-35, 110], preference:1});
var cAxis = createAxis({coordinate:2, table:true, axis:[0, 0, 1], cyclic:true, preference:0});
machineConfiguration = new MachineConfiguration(aAxis, cAxis);
setMachineConfiguration(machineConfiguration);
optimizeMachineAngles2(1); // map tip mode
}
if (!machineConfiguration.isMachineCoordinate(0)) {
aOutput.disable();
}
Entry Functions 4-72
CAM Post Processor Guide 8/28/19
if (!machineConfiguration.isMachineCoordinate(1)) {
bOutput.disable();
}
if (!machineConfiguration.isMachineCoordinate(2)) {
cOutput.disable();
}
Defining the Machine Configuration
Some machines don't use a program number and accept the program name as a comment.
The program header can consist of the output filename, version numbers, the run date and time, the
description of the machine, and the list of tools used in the program.
In the above code sample, the machine information is retrieved from the machineConfiguration, but a
machine configuration file is not always available to the post processor, so it is possible to hard code the
machine description.
machineConfiguration.setVendor("Doosan");
machineConfiguration.setModel("Lynx");
machineConfiguration.setDescription(description);
Defining the Machine Information
if (false) { // set to true to check for duplicate tool numbers w/different cutter geometry
// check for duplicate tool number
for (var i = 0; i < getNumberOfSections(); ++i) {
var sectioni = getSection(i);
var tooli = sectioni.getTool();
for (var j = i + 1; j < getNumberOfSections(); ++j) {
var sectionj = getSection(j);
var toolj = sectionj.getTool();
if (tooli.number == toolj.number) {
if (xyzFormat.areDifferent(tooli.diameter, toolj.diameter) ||
xyzFormat.areDifferent(tooli.cornerRadius, toolj.cornerRadius) ||
abcFormat.areDifferent(tooli.taperAngle, toolj.taperAngle) ||
(tooli.numberOfFlutes != toolj.numberOfFlutes)) {
error(
subst(
localize("Using the same tool number for different cutter geometry for operation '%1' and
'%2'."),
sectioni.hasParameter("operation-comment") ?
sectioni.getParameter("operation-comment") : ("#" + (i + 1)),
sectionj.hasParameter("operation-comment") ?
sectionj.getParameter("operation-comment") : ("#" + (j + 1))
)
);
Entry Functions 4-76
CAM Post Processor Guide 8/28/19
return;
}
}
}
}
}
Check for Duplicate Tool Numbers using Different Cutter Geometry
// don't allow WCS 0 unless it is the only WCS used in the program
if ((getNumberOfSections() > 0) && (getSection(0).workOffset == 0)) {
for (var i = 0; i < getNumberOfSections(); ++i) {
if (getSection(i).workOffset > 0) {
error(localize("Using multiple work offsets is not possible if the initial work offset is 0."));
return;
}
}
}
Check for Work Offset 0 when Multiple Work Offsets are Used in Program
4.3 onSection
function onSection() {
The onSection function is called at start of each CAM operation and controls the output of the following
blocks.
The first part of onSection determines if there is a change in the tool being used and if the Work
Coordinate System offset or Work Plane is different from the previous section. These settings determine
the output required between operations.
var retracted = false; // specifies that the tool has been retracted to the safe plane
var newWorkOffset = isFirstSection() ||
(getPreviousSection().workOffset != currentSection.workOffset); // work offset changes
var newWorkPlane = isFirstSection() ||
!isSameDirection(getPreviousSection().getGlobalFinalToolAxis(),
currentSection.getGlobalInitialToolAxis());
Tool Change, Work Coordinate Sysetm Offset, and Work Plane Settings
The code to retract the tool can vary from post to post, depending on the controller model and the
machine configuration. It can output an absolute move to the machine home position, for example using
G53, or move to a clearance plane relevant to the current work offset, for example G00 Z5.0.
The onSectionEnd section has an example of ending the operation when not done in the onSection
function.
if (hasParameter("operation-comment")) {
var comment = getParameter("operation-comment");
if (comment) {
Entry Functions 4-79
CAM Post Processor Guide 8/28/19
writeComment(comment);
}
}
Output Operation Comment
The output of the operation notes is normally handled by the post processor property showNotes.
// user-defined properties
properties = {
…
showNotes: false, // specifies that operation notes should be output
…
}
Define the showNotes Property
The Length Offset value is usually output with the Initial Position as described further in this chapter.
The Diameter Offset value is output with a motion block in onLinear. All other tool parameters are
output in the tool change code.
if (insertToolCall) {
…
Entry Functions 4-81
CAM Post Processor Guide 8/28/19
if (tool.number > numberOfToolSlots) {
warning(localize("Tool number exceeds maximum value."));
}
You will have to change the setting of showToolZMin to true if you want the lower Z-limit comment
output at a tool change.
The selection of the next tool is optional and is controlled by the post processor property preloadTool.
// user-defined properties
properties = {
…
preloadTool: true, // preloads next tool on tool change if any
…
}
Define the preloadTool Property
The first tool will be loaded on the last operation of the program.
if (properties.preloadTool) {
var nextTool = getNextTool(tool.number);
The spindle codes will be output with a tool change and if the spindle speed changes.
if (insertToolCall ||
isFirstSection() ||
(rpmFormat.areDifferent(tool.spindleRPM, sOutput.getCurrent())) ||
(tool.clockwise != getPreviousSection().getTool().clockwise)) {
if (tool.spindleRPM < 1) {
error(localize("Spindle speed out of range."));
return;
}
if (tool.spindleRPM > 99999) {
warning(localize("Spindle speed exceeds maximum value."));
}
writeBlock(
sOutput.format(tool.spindleRPM), mFormat.format(tool.clockwise ? 3 : 4)
);
}
Output Spindle Codes
You will find different methods of outputting the coolant codes in the various posts. The latest method
uses a table to define the coolant on and off codes. The table is defined just after the properties table at
the top of the post processor. You can define a single code for each coolant mode or multiple codes
using an array. When adding or changing the coolant codes supported by your machine, this is the only
area of the code that needs to be changed.
var singleLineCoolant = false; // specifies to output multiple coolant codes in one line rather than in
separate lines
// samples:
// {id: COOLANT_THROUGH_TOOL, on: 88, off: 89}
// {id: COOLANT_THROUGH_TOOL, on: [8, 88], off: [9, 89]}
var coolants = [
{id: COOLANT_FLOOD, on: 8},
{id: COOLANT_MIST},
The setCoolant function will output each coolant code in separate blocks. It does this by calling the
getCoolantCodes function to obtain the coolant code(s) and using writeBlock to output each individual
coolant code. Both of these functions are generic in nature and should not have to be modified.
It may be that you want to output the coolant codes(s) in a block with other codes, such as the initial
position or the spindle speed. In this case you can call getCoolantCodes directly in the onSection
function and add the output of the coolant codes to the appropriate block. The following example will
output the coolant codes with the initial position of the operation.
WCS codes are output when a new tool is used for the operation or when the WCS offset number used is
changed. WCS offsets are typically controlled using the G54 to G59 codes and possibly an extended
syntax for handling work offsets past 6.
// wcs
if (insertToolCall) { // force work offset when changing tool
currentWorkOffset = undefined;
}
var workOffset = currentSection.workOffset;
if (workOffset == 0) { // change work offset of 0 to 1
warningOnce(localize("Work offset has not been specified. Using G54 as WCS."),
WARNING_WORK_OFFSET);
workOffset = 1;
}
if (workOffset > 0) {
if (workOffset > 6) { // handle work offsets greater than 6
var code = workOffset - 6;
if (code > 3) {
error(localize("Work offset out of range."));
return;
}
if (workOffset != currentWorkOffset) {
forceWorkPlane();
writeBlock(gFormat.format(59) + "." + code); // G59.n
currentWorkOffset = workOffset;
}
} else { // handle work offsets 1-6
Entry Functions 4-85
CAM Post Processor Guide 8/28/19
if (workOffset != currentWorkOffset) {
forceWorkPlane();
writeBlock(gFormat.format(53 + workOffset)); // G54->G59
currentWorkOffset = workOffset;
}
}
}
Output the Work Coordinate System Offset Number
The output for a Work Plane will either be the rotary axes positions or the definition of the Work Plane
itself as Euler angles. For machine controls that support both formats the useMultiAxisFeatures variable
is defined at the top of the post processor to determine the Work Plane method to use.
// fixed settings
var useMultiAxisFeatures = false; // false = use rotary axis positions, true = use Euler angles
The function getWorkPlaneMachineABC is used to calculate the rotary axes positions that satisfy the
Work Plane. This function is standard from post to post, but there are a couple of areas that are
controlled by user defined settings.
The first step is whether you require the rotary axes positions to be output closest to the angles used for
the previous Work Plane. This setting is false by default, but you can set it to true to enable it. You can
also define a starting position for the rotary axes so that if the first operation is a 3+2 operation, then it
will choose the closest angles to your starting angles.
You will also have to define whether Tool Control Point (TCP) programming is supported by the
machine or if the tool endpoint coordinates need to be adjusted for the rotary axes positions. You do this
by setting the tcp variable to true (TCP is supported) or false (adjust points for rotary axes).
In situations where the tool can be become perpendicular to the rotary table it is not possible to control
the rotary table position using the Work Plane. You will notice in this case that the table does not move
to satisfy the Work Plane rotation, but rather the output points are rotated to satisfy the Work Plane.
You can override this logic and have the rotary table move instead by adding the following code to the
TCP setting for 3+2 machining.
The logic that controls the Work Plane calculation is typically in the onSection function, but in some
post processors, especially those that support subprograms, you will find this logic in the
defineWorkPlane function.
You should be aware that the X-axis direction of the Work Plane does affect the Euler angle calculation.
The typical method of defining the Work Plane is to keep the X-axis orientation pointing in the positive
direction as you look down the Z-axis, but on some table/table style machines this will cause the
The getEuler2 function is used to calculate the Euler angles for the Work Plane. The argument passed
to the getEuler2 function specifies the order of the primary axis rotations that the machine control
requires and can be one of the values in the following table.
Check the Programming Manual for your machine to determine if Euler angles are supported and the
order of rotations. The direction of the Euler angles is also important. A general rule to follow is that
the directions should match the definition of the rotary axis using the createAxis command. If the vector
defining the rotation axis is positive for the rotary axis, then the Euler angles will be positive as shown
in the above code.
If the rotation axis is in the negative direction, usually when the machine has a rotary head, then the
Euler angles should be output in the opposite direction as shown in the following code.
The setWorkPlane function does the actual output of the Work Plane and can vary from post processor
to post processor, depending on the requirements of the machine control. It will output the calculated
Euler angles or rotary axes positions, and in some cases, both. In the following code, G68.2 is used to
define the Work Plane using Euler angles.
function setWorkPlane(abc) {
// the Work Plane does not change, do not output it
if (!((currentWorkPlaneABC == undefined) ||
abcFormat.areDifferent(abc.x, currentWorkPlaneABC.x) ||
abcFormat.areDifferent(abc.y, currentWorkPlaneABC.y) ||
abcFormat.areDifferent(abc.z, currentWorkPlaneABC.z))) {
return; // no change
}
Some machine controls require that the rotary axes positions be output prior to the Euler angle block. If
this is the case, then the code to output the Work Plane can be modified to output both variations of the
Work Plane.
// output tool length offset on tool change or if tool has been retracted
if (insertToolCall || retracted) {
var lengthOffset = tool.lengthOffset;
if (lengthOffset > numberOfToolSlots) {
error(localize("Length offset out of range."));
return;
}
gMotionModal.reset();
writeBlock(gPlaneModal.format(17));
4.4 onSectionEnd
function onSectionEnd() {
The onSectionEnd function can be used to define the end of an operation, but in most post processors
this is handled in the onSection function. The reason for this is that different output will be generated
depending on if there is a tool change, WCS change, or Work Plane change and this logic is handled in
the onSection function (see the insertToolCall variable), though it could be handled in the onSectionEnd
function if desired by referencing the getNextSection and isLastSection functions.
var retracted = false; // specifies that the tool has been retracted to the safe plane
var newWorkOffset = isLastSection() ||
(currentSection.workOffset != getNextSection().workOffset); // work offset changes
var newWorkPlane = isLastSection() ||
!isSameDirection(currentSection.getGlobalFinalToolAxis(),
getNextSection().getGlobalInitialToolAxis());
if (properties.optionalStop) {
onCommand(COMMAND_OPTIONAL_STOP);
}
}
}
Ending the Operation in onSectionEnd
You will need to remove the similar code from the onSection function and probably the onClose
function, which will duplicate the session ending code if left intact.
One reason for ending the operation in the onSectionEnd function is if a Manual NC command is used
between operations. The Manual NC command will be processed prior to the onSection function and if
the previous operation is terminated in onSection, then the Manual NC command will be acted upon
prior to ending the previous operation.
The onSectionEnd function is pretty basic in most posts and will reset codes that may have been
changed in the operation and possibly some variables that are operation specific.
function onSectionEnd() {
writeBlock(gPlaneModal.format(17));
forceAny();
}
Basic onSectionEnd Function
4.5 onClose
function onClose() {
The onClose function is called at the end of the last operation, after onSectionEnd. It is used to define
the end of an operation, if not handled in onSectionEnd, and to output the end-of-program codes.
function onClose() {
// end previous operation
writeln("");
optionalSection = false;
onCommand(COMMAND_COOLANT_OFF);
Entry Functions 4-94
CAM Post Processor Guide 8/28/19
writeRetract(Z); // retract
disableLengthCompensation(true);
setSmoothing(false);
zOutput.reset();
setWorkPlane(new Vector(0, 0, 0)); // reset working plane
writeRetract(X, Y); // return to home
4.6 onTerminate
function onTerminate() {
The onTerminate function is called at the end of post processing, after onClose. It is called after all
output to the NC file is finished and the NC file is closed. It may be used to rename the output file(s)
after processing has finished, to automatically create a setup sheet, or to run another program against the
output NC file.
function onTerminate() {
var outputPath = getOutputPath();
var programFilename = FileSystem.getFilename(outputPath);
var programSize = FileSystem.getFileSize(outputPath);
var postPath = findFile("setup-sheet-excel-2007.cps");
var intermediatePath = getIntermediatePath();
var a = "--property unit " + ((unit == IN) ? "0" : "1"); // use 0 for inch and 1 for mm
if (programName) {
a += " --property programName \"'" + programName + "'\"";
}
if (programComment) {
a += " --property programComment \"'" + programComment + "'\"";
}
a += " --property programFilename \"'" + programFilename + "'\"";
a += " --property programSize \"" + programSize + "\"";
a += " --noeditor --log temp.log \"" + postPath + "\" \"" + intermediatePath + "\" \"" +
FileSystem.replaceExtension(outputPath, "xlsx") + "\"";
execute(getPostProcessorPath(), a, false, "");
executeNoWait("excel", "\"" + FileSystem.replaceExtension(outputPath, "xlsx") + "\"", false, "");
}
Create and Display Setup Sheet from onTerminate
Arguments Description
command Command to process.
The onCommand function can be called by a Manual NC command, directly from HSM, or from the
post processor.
Command Description
COMMAND_ACTIVATE_SPEED_FEED_SYNCHRONIZATION Activate threading mode
COMMAND_ALARM Alarm
COMMAND_ALERT Alert
COMMAND_BREAK_CONTROL Tool break control
COMMAND_CALIBRATE Run calibration cycle
COMMAN_CHANGE_PALLET Change pallet
COMMAND_CLEAN Run cleaning cycle
COMMAND_CLOSE_DOOR Close primary door
COMMAND_COOLANT_OFF Coolant off (M09)
COMMAND_COOLANT_ON Coolant on (M08)
COMMAND_DEACTIVATE_SPEED_FEED_SYNCHRONIZATION Deactivate threading mode
COMMAND_END Program end (M02)
COMMAND_EXACT_STOP Exact stop
COMMAND_LOAD_TOOL Tool change (M06)
COMMAND_LOCK_MULTI_AXIS Locks the rotary axes
COMMAND_MAIN_CHUCK_CLOSE Close main chuck
COMMAND_MAIN_CHUCK_OPEN Open main chuck
COMMAND_OPEN_DOOR Open primary door
COMMAND_OPTIONAL_STOP Optional program stop (M01)
COMMAND_ORIENTATE_SPINDLE Orientate spindle (M19)
COMMAND_POWER_OFF Power off
COMMAND_POWER_ON Power on
COMMAND_SECONDARY_CHUCK_CLOSE Close secondary chuck
COMMAND_SECONDARY_CHUCK_OPEN Open secondary chuck
COMMAND_SECONDARY_SPINDLE_SYNCHRONIZATION_ACTIVATE Activate spindle synchronization
COMMAND_SECONDARY_SPINDLE_SYNCHRONIZATION_DEACTIVATE Deactivate spindle synchronization
COMMAND_SPINDLE_CLOCKWISE Clockwise spindle direction (M03)
COMMAND_SPINDLE_COUNTERCLOCKWISE Counter-clockwise spindle direction
(M04)
COMMAND_START_CHIP_TRANSPORT Start chip conveyor
COMMAND_START_SPINDLE Start spindle in previous direction
COMMAND_STOP Program stop (M00)
COMMAND_STOP_CHIP_TRANSPORT Stop chip conveyor
Entry Functions 4-96
CAM Post Processor Guide 8/28/19
Command Description
COMMAND_STOP_SPINDLE Stop spindle (M05)
COMMAND_TOOL_MEASURE Measure tool
COMMAND_UNLOCK_MULTI_AXIS Unlocks the rotary axes
COMMAND_VERIFY Verify path/tool/machine integrity
Valid Commands
The Manual NC commands that call onCommand are described in the Manual NC Commands chapter.
Internal calls to onCommand are usually generated when expanding a cycle. The post processor itself
will call onCommand directly to perform simple functions, such as outputting a program stop, cancelling
coolant, opening the main door, turning on the chip conveyor, etc.
// stop spindle and cancel coolant before retract during tool change
if (insertToolCall && !isFirstSection()) {
onCommand(COMMAND_COOLANT_OFF);
onCommand(COMMAND_STOP_SPINDLE);
}
Calling onCommand Directly from Post Processor
The onImpliedCommand function changes the state of certain settings in the post engine without calling
onCommand and outputting the associated codes with the command. The state of certain parameters is
important when the post processor engine expands cycles.
onImpliedCommand(COMMAND_END);
onImpliedCommand(COMMAND_STOP_SPINDLE);
onImpliedCommand(COMMAND_COOLANT_OFF);
writeBlock(mFormat.format(30)); // stop program, spindle stop, coolant off
Using onImpliedCommand
4.8 onComment
function onComment(message) {
Arguments Description
message Text of comment to output.
The onComment function is called when the Manual NC command Comment is issued. It will format
and output the text of the comment to the NC file.
There are two other functions that are used to format and output comments, formatComment and
writeComment. These comment functions are standard in nature and do not typically have to be
modified, though the permittedCommentChars variable, defined at the top of the post, is used to define
the characters that are allowed in a comment and may have to be changed to match the control. The
formatComment function will remove any characters in the comment that are not specified in this
variable. Lowercase letters will be converted to uppercase by the formatComment function. If you want
to support lowercase letters, then they would have to be added to the permittedCommentChars variable
and the formatComment function would need to have the conversion to uppercase removed.
4.9 onDwell
function onDwell(seconds) {
Entry Functions 4-98
CAM Post Processor Guide 8/28/19
Arguments Description
seconds Dwell time in seconds.
The onDwell function can be called by a Manual NC command, directly from HSM, or from the post
processor. The Manual NC command that calls onDwell is described in the Manual NC Commands
chapter. Internal calls to onDwell are usually generated when expanding a cycle. The post processor
itself will call onDwell directly to output a dwell block.
function onDwell(seconds) {
if (seconds > 99999.999) {
warning(localize("Dwelling time is out of range."));
}
milliseconds = clamp(1, seconds * 1000, 99999999);
writeBlock(gFeedModeModal.format(94), gFormat.format(4), "P" +
milliFormat.format(milliseconds));
}
Output the Dwell Time in Milliseconds
onCommand(COMMAND_COOLANT_ON);
onDwell(1.0); // dwell 1 second after turning coolant on
Calling onDwell Directly from Post Processor
4.10 onParameter
function onParameter(name, value) {
Arguments Description
name Parameter name.
value Value stored in the parameter.
Almost all parameters used for creating a machining operation in HSM are passed to the post processor.
Common parameters are available using built in post processor variables (currentSection, tool, cycle,
etc.) as well as being made available as parameters. Other parameters are passed to the onParameter
function.
The name of the parameter along with its value is passed to the onParameter function. Some Manual
NC commands will call the onParameter function, these are described in the Manual NC Commands
chapter. You can see how to run and analyze the output from the dump.cps post processor in the
Debugging chapter.
Arguments Description
name Parameter name.
You can retrieve operation parameters at any place in the post processor by calling the getParameter
function. Operation parameters are defined as parameters that are redefined for each machining
operation. There is a chance that a parameter does not exist in all flavors of HSM, so it is recommended
that the presence of the parameter is first verified by calling the hasParameter function.
if (hasParameter("operation-comment")) {
var comment = getParameter("operation-comment");
if (comment) {
writeComment(comment);
}
}
Verify a Parameter Exists Using the hasParameter Function
When scanning through the operations in the intermediate file it is possible to access the parameters for
that operation by using the section variant of the hasParameter and getParameter functions.
Arguments Description
name Parameter name.
Some parameters are defined at the start of the intermediate file prior to the first operation. These
parameters are considered global and are accessed using the hasGlobalParameter and
getGlobalParameter functions. The same rules that apply to the operation parameters apply to global
parameters.
-1: onOpen()
0: onParameter('product-id', 'fusion360')
1: onParameter('generated-by', 'Fusion 360 CAM 2.0.3803')
2: onParameter('generated-at', 'Saturday, March 24, 2018 4:34:36 PM')
3: onParameter('hostname', 'host')
4: onParameter('username', 'user')
5: onParameter('document-path', 'Water-Laser-Plasma v2')
6: onParameter('leads-supported', 1)
7: onParameter('job-description', 'Laser')
9: onParameter('stock', '((0, 0, -5), (300, 200, 0))')
11: onParameter('stock-lower-x', 0)
13: onParameter('stock-lower-y', 0)
15: onParameter('stock-lower-z', -5)
17: onParameter('stock-upper-x', 300)
19: onParameter('stock-upper-y', 200)
21: onParameter('stock-upper-z', 0)
23: onParameter('part-lower-x', 0)
25: onParameter('part-lower-y', 0)
27: onParameter('part-lower-z', -5)
29: onParameter('part-upper-x', 300)
31: onParameter('part-upper-y', 200)
33: onParameter('part-upper-z', 0)
35: onParameter('notes', '')
Sample Global Variables
4.11 onPassThrough
Function onPassThrough (value)
Arguments Description
value Text to be output to the NC file.
The onPassThrough function is called by the Pass through Manual NC command and is used to pass a
text string directly to the NC file without any processing by the post processor. This function is
described in the Manual NC Commands chapter.
4.12 onSpindleSpeed
function onSpindleSpeed(speed) {
Arguments Description
spindleSpeed The new spindle speed in RPM.
The onSpindleSpeed function is used to output changes in the spindle speed during an operation,
typically from the post processor engine when expanding a cycle.
function onSpindleSpeed(spindleSpeed) {
writeBlock(sOutput.format(spindleSpeed));
}
Sample onSpindleSpeed Function
4.13 onOrientateSpindle
function onOrientateSpindle(angle) {
Arguments Description
angle Spindle orientation angle in radians.
4.14 onRadiusCompensation
function onRadiusCompensation() {
The onRadiusCompensation function is called when the radius (cutter) compensation mode changes. It
will typically set the pending compensation mode, which will be handled in the motion functions
(onRapid, onLinear, onCircular, etc.). Radius compensation, when enabled in an operation, will be
enabled on the move approaching the part and disabled after moving off the part.
The state of radius compensation is stored in the global radiusCompensation variable and is not passed
to the onRadiusCompensation function. Radius compensation is defined when creating the machining
operation in HSM (1). The Sideways Compensation (2) setting determines the side of the part that the
tool will be on when cutting. It is based on the forward direction of the tool during the cutting operation.
function onRadiusCompensation() {
pendingRadiusCompensation = radiusCompensation;
}
Sample onRadiusCompensation Function
4.15 onMovement
function onMovement(movement) {
Arguments Description
movement Movement type for the following motion(s).
onMovement is called whenever the movement type changes. It is used to tell the post when there is a
positioning, entry, exit, or cutting type move. There is also a movement global variable that contains the
movement setting. This variable can be referenced directly in other functions, such as onLinear, to
access the movement type without defining the onMovement function.
Movement types are used in defining parametric feedrates in some milling posts and for removing all
non-cutting moves for waterjet/plasma/laser machines that require only the cutting profile.
4.16 onRapid
function onRapid(_x, _y, _z) {
Arguments Description
_x, _y, _z The tool position.
The onRapid function handles rapid positioning moves (G00) while in 3-axis mode. The tool position is
passed as the _x, _y, _z arguments. The format of the onRapid function is pretty basic, it will handle a
change in radius compensation, may determine if the rapid moves should be output at a high feedrate
(due to the machine making dogleg moves while in rapid mode), and output the rapid move to the NC
file.
If the High feedrate mapping property is set to Always use high feed, then the onLinear function will be
called with the high feedrate passed in as the feedrate and the onRapid function will not be called.
4.17 onExpandedRapid
onExpandedRapid(x, y, z);
Arguments Description
x, y, z The tool position.
It is possible that the post processor will need to generate rapid positioning moves during the processing
of the intermediate file. An example would be creating your own expanded drilling cycle. Instead of
calling onRapid with the post generated moves, it is recommended that onExpandedRapid be called
instead. This will ensure that the post engine is notified of the move and the current position is set.
onExpandedRapid will then call onRapid with the provided arguments.
The onExpandedRapid function is not considered an entry function, since it will never be called directly
by the post processor engine.
4.18 onLinear
function onLinear(_x, _y, _z, feed) {
Arguments Description
_x, _y, _z The tool position.
feed The feedrate.
4.19 onExpandedLinear
onExpandedLinear(x, y, z, feed);
Arguments Description
_x, _y, _z The tool position.
feed The feedrate.
It is possible that the post processor will need to generate cutting moves during the processing of the
intermediate file. An example would be creating your own expanded drilling cycle. Instead of calling
onLinear with the post generated moves, it is recommended that onExpandedLinear be called instead.
This will ensure that the post engine is notified of the move and the current position is set.
onExpandedLinear will then call onLinear with the provided arguments.
The onExpandedLinear function is not considered an entry function, since it will never be called directly
by the post processor engine.
4.20 onRapid5D
function onRapid5D(_x, _y, _z, _a, _b, _c) {
Arguments Description
_x, _y, _z The tool position.
_a, _b, _c The rotary angles if a machine configuration has been defined, otherwise the
tool axis vector is passed.
The onRapid5D function handles rapid positioning moves (G00) in multi-axis operations. The tool
position is passed as the _x, _y, _z arguments and the rotary angles as the _a, _b, _c arguments. If a
machine configuration has not been defined, then _a, _b, _c contains the tool axis vector. The
onRapid5D function will be called for all rapid moves in a multi-axis operation, even if the move is only
a 3-axis linear move without rotary movement.
Like the onRapid function, the onRapid5D function handles a change in radius compensation, may
determine if the rapid moves should be output at a high feedrate (due to the machine making dogleg
moves while in rapid mode), and outputs the rapid move to the NC file.
Entry Functions 4-108
CAM Post Processor Guide 8/28/19
function onRapid5D(_x, _y, _z, _a, _b, _c) {
// enable this code if machine does not accept IJK tool axis vector input
if (false) {
if (!currentSection.isOptimizedForMachine()) {
error(localize("This post configuration has not been customized for 5-axis toolpath."));
return;
}
}
// Machine Configuration has been defined, output rotary angles with move
if (currentSection.isOptimizedForMachine()) {
var x = xOutput.format(_x);
var y = yOutput.format(_y);
var z = zOutput.format(_z);
var a = aOutput.format(_a);
var b = bOutput.format(_b);
var c = cOutput.format(_c);
writeBlock(gMotionModal.format(0), x, y, z, a, b, c);
// Machine Configuration has not been defined, output tool axis with move
} else {
forceXYZ();
var x = xOutput.format(_x);
var y = yOutput.format(_y);
var z = zOutput.format(_z);
var i = ijkFormat.format(_a);
var j = ijkFormat.format(_b);
var k = ijkFormat.format(_c);
writeBlock(gMotionModal.format(0), x, y, z, "I" + i, "J" + j, "K" + k);
}
forceFeed();
}
Sample onRapid5D Function
Please refer to the Multi-Axis Post Processors chapter for a detailed explanation on supporting a multi-
axis machine.
4.21 onLinear5D
function onLinear5D(_x, _y, _z, _a, _b, _c, feed) {
The onLinear5D function handles cutting moves (G01) in multi-axis operations. The tool position is
passed as the _x, _y, _z arguments and the rotary angles as the _a, _b, _c arguments. If a machine
configuration has not been defined, then _a, _b, _c contains the tool axis vector. The onLinear5D
function will be called for all cutting moves in a multi-axis operation, even if the move is only a 3-axis
linear move without rotary movement.
Like the onLinear function, the onLinear5D function handles a change in radius compensation, and
outputs the cutting move to the NC file.
// Machine Configuration has been defined, output rotary angles with move
if (currentSection.isOptimizedForMachine()) {
var x = xOutput.format(_x);
var y = yOutput.format(_y);
var z = zOutput.format(_z);
var a = aOutput.format(_a);
var b = bOutput.format(_b);
var c = cOutput.format(_c);
// Machine Configuration has not been defined, output tool axis with move
} else {
forceXYZ();
var x = xOutput.format(_x);
var y = yOutput.format(_y);
var z = zOutput.format(_z);
var i = ijkFormat.format(_a);
var j = ijkFormat.format(_b);
var k = ijkFormat.format(_c);
var f = getFeed(feed);
Please refer to the Multi-Axis Post Processors chapter for a detailed explanation on supporting a multi-
axis machine.
4.22 onCircular
function onCircular(clockwise, cx, cy, cz, x, y, z, feed) {
The onCircular function is called whenever there is circular, helical, or spiral motion. The circular
move can be in any of the 3 standard planes, XY-plane, YZ-plane, or ZX-plane, it is up to the
onCircular function to determine which types of circular are valid for the machine and to correctly
format the output.
The structure of the onCircular function in most posts uses the following layout.
1. Test for radius compensation. Most controls do not allow radius compensation to be started on a
circular move.
2. Full circle output.
3. Center point (IJK) output.
4. Radius output.
Each of the different styles of output will individually handle the output of circular interpolation in each
of the planes and possibly 3-D circular interpolation if it is supported.
Setting Description
allowedCircularPlanes Defines the standard planes that circular interpolation is allowed in,
PLANE_XY, PLANE_YZ, PLANE_ZX. It can be set to undefined to
allow circular interpolation in all three planes, 0 to disable circular
interpolation, or a bit mask of PLANE_XY, PLANE_YZ, and/or
PLANE_YZ to allow only certain planes.
allowHelicalMoves Helical interpolation is allowed when this variable is set to true. Helical
moves are linearized if set to false.
allowSpiralMoves Spiral interpolation is defined as circular moves that have a different
starting radius than ending radius and can be enabled by setting this
variable to true. Spiral moves are linearized if set to false.
maximumCircularRadius Specifies the maximum radius of circular moves that can be output as
circular interpolation and can be changed dynamically in the Property
table when running the post processor. Any circular records whose radius
exceeds this value will be linearized. This variable must be set in
millimeters (MM).
maximumCircularSweep Specifies the maximum angular sweep of circular moves that can be
output as circular interpolation and is specified in radians. Any circular
records whose delta angle exceeds this value will be linearized.
minimumChordLength Specifies the minimum delta movement allowed for circular interpolation
and can be changed dynamically in the Property table when running the
post processor. Any circular records whose delta linear movement is less
than this value will be linearized. This variable must be set in millimeters
(MM).
minimumCircularRadius Specifies the minimum radius of circular moves that can be output as
circular interpolation and can be changed dynamically in the Property
table when running the post processor. Any circular records whose radius
is less than this value will be linearized. This variable must be set in
millimeters (MM).
minimumCircularSweep Specifies the minimum angular sweep of circular moves that can be output
as circular interpolation and is specified in radians. Any circular records
whose delta angle is less than this value will be linearized.
tolerance Specifies the tolerance used to linearize circular moves that are expanded
into a series of linear moves. Circular interpolation records can be
linearized due to the conditions of the circular interpolation settings not
being met or by the linearize function being called. This variable must be
set in millimeters (MM).
Circular Interpolation Settings
Helical interpolation is typically output using the same format as circular interpolation with the addition
of the third axis and optionally a pitch value (incremental distance per 360 degrees) for the third axis.
case PLANE_XY:
writeBlock(gPlaneModal.format(17), gMotionModal.format(clockwise ? 2 : 3),
xOutput.format(x), yOutput.format(y), zOutput.format(z),
iOutput.format(cx-start.x, 0), jOutput.format(cy-start.y, 0), kOutput.format(getHelicalPitch()),
feedOutput.format(feed));
break;
Helical Interpolation with Pitch Output
Spiral interpolation when supported on a control is typically specified with a G-code different than the
standard G02/G03 circular interpolation G-codes. Most stock post processors do not support spiral
interpolation.
if (isSpiral()) {
var startRadius = getCircularStartRadius();
var endRadius = getCircularRadius();
var dr = Math.abs(endRadius - startRadius);
if (dr > maximumCircularRadiiDifference) { // maximum limit
if (isHelical()) { // not supported
linearize(tolerance);
return;
}
switch (getCircularPlane()) {
case PLANE_XY:
writeBlock(gPlaneModal.format(17), gMotionModal.format(clockwise ? 2.1 : 3.1),
xOutput.format(x), yOutput.format(y), zOutput.format(z),
iOutput.format(cx - start.x, 0), jOutput.format(cy - start.y, 0), getFeed(feed));
break;
case PLANE_ZX:
writeBlock(gPlaneModal.format(18), gMotionModal.format(clockwise ? 2.1 : 3.1),
xOutput.format(x), yOutput.format(y), zOutput.format(z),
iOutput.format(cx - start.x, 0), kOutput.format(cz - start.z, 0), getFeed(feed));
break;
case PLANE_YZ:
writeBlock(gPlaneModal.format(19), gMotionModal.format(clockwise ? 2.1 : 3.1),
xOutput.format(x), yOutput.format(y), zOutput.format(z),
jOutput.format(cy - start.y, 0), kOutput.format(cz - start.z, 0), getFeed(feed));
Entry Functions 4-116
CAM Post Processor Guide 8/28/19
break;
default:
linearize(tolerance);
}
return;
}
}
3-D circular interpolation when supported on a control is typically specified with a G-code different than
the standard G02/G03 circular interpolation G-codes and must contain either the mid-point of the
circular move and/or the normal vector of the circle. Most stock post processors do not support 3-D
circular interpolation.
default:
if (properties.allow3DArcs) { // a post property is used to enable support of 3-D circular
// make sure maximumCircularSweep is well below 360deg
var ip = getPositionU(0.5); // calculate mid-point of circle
writeBlock(gMotionModal.format(clockwise ? 2.4 : 3.4), // 3-D circular direction G-codes
xOutput.format(ip.x), yOutput.format(ip.y), zOutput.format(ip.z), // output mid-point of circle
getFeed(feed));
writeBlock(xOutput.format(x), yOutput.format(y), zOutput.format(z)); // output end-point
} else {
linearize(tolerance);
}
}
3-D Circular Interpolation Output
4.23 onCycle
function onCycle() {
The onCycle function is called once at the beginning of an operation that contains a canned cycle and
can contain code to prepare the machine for the cycle. Mill post processors will typically set the
machining plane here.
function onCycle() {
writeBlock(gPlaneModal.format(17));
}
Sample onCycle Function
Entry Functions 4-117
CAM Post Processor Guide 8/28/19
Mill/Turn post processors will usually handle the stock transfer sequence in the onCycle function. Logic
for the Mill/Turn post processors will be discussed in a dedicated chapter.
4.24 onCyclePoint
function onCyclePoint(x, y, z) {
Argument Description
x, y, z Hole bottom location.
Canned cycle output is handled in the onCyclePoint function, which includes positioning to the
clearance plane, formatting of the cycle block, calculating the cycle parameters, discerning if the canned
cycle is supported on the machine or should be expanded, and probing cycles which will not be
discussed in this chapter.
The location of the hole bottom for the cycle is passed in as the x, y, z arguments to the onCyclePoint
function. All other parameters are available in the cycle object or through cycle specific function calls.
The flow of outputting canned cycles usually follows the following logic.
The actual output of the cycle blocks is handled in a switch block, with a separate case for each of the
supported cycles.
switch (cycleType) {
case "drilling":
writeBlock(
gRetractModal.format(98), gAbsIncModal.format(90), gCycleModal.format(81),
getCommonCycle(x, y, z, cycle.retract),
feedOutput.format(F)
);
break;
Sample Cycle Formatting Code
case "deep-drilling":
if (P > 0) { // the machine does not support a dwell code, so expand the cycle
expandCyclePoint(x, y, z);
} else {
writeBlock(
gRetractModal.format(98), gAbsIncModal.format(90), gCycleModal.format(83),
getCommonCycle(x, y, z, cycle.retract),
"Q" + xyzFormat.format(cycle.incrementalDepth),
feedOutput.format(F)
);
}
break;
Expanding a Cycle When a Feature is not Support on the Machine
The 2nd through the nth locations in a cycle operation are typically output using simple XY moves
without any of the cycle definition codes. Expanded cycles still need to be expanded at these locations.
cycleType Description
drilling Feed in to depth and rapid out (G81)
Entry Functions 4-119
CAM Post Processor Guide 8/28/19
cycleType Description
counter-boring Feed in to depth, dwell, and rapid out (G82)
chip-breaking Multiple pecks with periodic partial retract to clear chips (G73)
deep-drilling Peck drilling with full retraction at end of each peck (G83)
break-through-drilling Allows for reduced speed and feed before breaking through hole
(expanded)
gun-drilling Guided deep drilling allows for a change in spindle speed for
positioning (expanded)
tapping Feed in to depth, reverse spindle, optional dwell, and feed out.
Automatically determines left or right tapping depending on the tool
selected. (G74/G84)
left-tapping Left-handed tapping (G74)
right-tapping Right-handed tapping (G84)
tapping-with-chip-breaking Tapping with multiple pecks. Automatically determines left or right
tapping depending on the tool selected. (expanded)
reaming Feed in to depth and feed out (G85)
boring Feed in to depth, dwell, and feed out (G86)
stop-boring Feed to depth, stop the spindle, and feed out (G87)
fine-boring Feed to depth, orientate the spindle, shift from wall, and rapid out
(G76)
back-boring Orientate the spindle, rapid to depth, start spindle, shift the tool to
wall, feed up to bore height, orientate spindle, shift from wall, and
rapid out (G77)
circular-pocket-milling Mills out a hole (expanded)
thread-milling Helical thread cutting (expanded)
Types of Drilling Cycles
Any of these cycles can be expanded if the machine control does not support the specific cycle. There
are some caveats, where the post (and machine) must support certain capabilities for the expanded cycle
to run correctly on the machine. The following table lists the commands that must be defined in the
onCommand function to support the expansion of these cycles. It is expected that the machine will
support these features if they are enabled in the post processor.
Certain cycles also use the following parameters when they are expanded.
Entry Functions 4-120
CAM Post Processor Guide 8/28/19
machineParameters. Description
drillingSafeDistance Specifies the safety distance above the stock when repositioning into
the hole for the chip-breaking and deep-drilling cycles.
spindleSpeedDwell Dwell in seconds after the spindle speed changes during a cycle.
Parameters for Expanded Cycles
You define the expanded cycle parameters using the following syntaxes.
Parameter Description
accumulatedDepth The depth of the combined cuts before the tool will be fully retracted
during a chip-breaking cycle.
backBoreDistance The cutting distance of a back-boring cycle.
bottom The bottom of the hole.
breakThroughDistance The distance above the hole bottom to switch to the break-through
feedrate and spindle speed during a break-through-drilling cycle.
breakThroughFeedRate The feedrate used when breaking through the hole during a break-
through-drilling cycle.
breakThroughSpindleSpeed The spindle speed used when breaking through the hole during a
break-through-drilling cycle.
chipBreakDistance The distance to retract the tool to break the chip during a chip-
breaking cycle.
clearance Clearance plane where to tool will retract the tool to after drilling a
hole and position to the next hole.
compensation Radius compensation in effect for circular-pocket-milling and thread-
milling cycles. This value can be control, wear, and inverseWear.
compensationShiftOrientation Same as shiftOrientation.
depth The depth of the hole.
diameter The diameter of the hole for circular-pocket-milling and thread-
milling cycles.
direction Either climb or conventional milling for circular-pocket-milling and
thread-milling cycles.
dwell The dwell time in seconds.
dwellDepth The distance above the cut depth at which to dwell, used for gun-
drilling cycles.
feedrate The primary cutting feedrate.
HSM assumes that the tool will always be retracted to the Retract Height (cycle.clearance) between
holes, you will notice this in the simulation of the cycle in HSM. This is typically handled in the
machine control with a G98 (Retract to clearance plane) code. Of course this code can be different from
machine control to machine control and there are controls that will always retract to the Feed Height
(cycle.retract) at the end of a drilling operation. In this case it is up to the post processor to retract the
tool to the Retract Height.
You can cancel the cycle at the end of the onCyclePoint function and output a tool retract block to take
the tool back up to the Retract Height. When this method is used it is also mandatory that the full cycle
be output for every hole in the operation and not just the first cycle point. Some machines support a
retract plane to be specified with the cancel cycle code, i.e. G80 Rxxx.
function onCyclePoint(x, y, z) {
// if (isFirstCyclePoint()) {
if (true) { // output a full cycle block for every hole in the operation
repositionToCycleClearance(cycle, x, y, z);
...
...
default:
expandCyclePoint(x, y, z);
}
// retract tool (add at the end of the cycleType switch code)
gMotionModal.format.reset();
writeBlock(gCycleModal.format(80), gMotionModal.format(0), zOutput.format(cycle.clearance));
} else {
if (cycleExpanded) {
Retracting the Tool to the Retract Plane when Unsupported by Machine Control
Function Description
isFirstCyclePoint() Returns true if this is the first point in the cycle operation. It is
usually called to determine whether to output a full cycle block or
just the cycle location.
isLastCyclePoint() Returns true if this is the last point in the cycle operation. This
function is typically used for a lathe threading operation since
HSM sends a single pass to the onCyclePoint function and the full
depth of the thread is required to output a single threading block.
onCycleEnd is used to terminate a drilling cycle, so this function is
not typically used in drilling cycles.
isProbingCycle() Returns true if this is a probing cycle.
repositionToCycleClearance() Moves the tool to the Retract Height plane (cycle.clearance). This
function is typically called prior to outputting a full cycle block.
getCommonCycle(x, y, z, r) Formats the common cycle parameters (X, Y, Z, R) for output.
Common Cycle Functions
These functions are built into the post engine, except the getCommonCycle function, which is contained
in the post processor. It takes the cycle location (x, y, z) and the retract plane/distance (r) as arguments.
Some machines require that the retract value be programmed as a distance from the current location
rather than as an absolute position. There are two ways to accomplish this. You can pass in the distance
as the retract value.
function getCommonCycle(x, y, z, r) {
forceXYZ();
return [xOutput.format(x), yOutput.format(y),
zOutput.format(z),
"R" + xyzFormat.format(r)];
}
…
case "drilling":
writeBlock(
gRetractModal.format(98), gAbsIncModal.format(90), gCycleModal.format(81),
getCommonCycle(x, y, z, cycle.retract – cycle.clearance),
feedOutput.format(F)
);
break;
Pass Retract Distance to Standard getCommonCycle Function
Or you can pass the clearance plane in to the getCommonCycle function and have it calculate the
distance. This method is typically used in post processors that support subprograms that require a retract
plane while in absolute mode and a distance when in incremental mode.
In the tapping sections of the onCyclePoint function you will need to assign the correct pitch value to the
output. The tapping pitch is stored in the tool.threadPitch variable.
case "tapping":
writeBlock(
gRetractModal.format(98), gCycleModal.format((84),
getCommonCycle(x, y, z, cycle.retract),
(conditional(P > 0, "P" + milliFormat.format(P)),
Entry Functions 4-125
CAM Post Processor Guide 8/28/19
pitchOutput.format(tool.threadPitch)
);
forceFeed(); // force the feedrate to be output after a tapping cycle with pitch output
break;
Output the Thread Pitch on a Tapping Cycle
If the tapping cycle requires that the machine be placed in FPR mode, then you can also calculate the
pitch value by dividing the feedrate by the spindle speed. You will also need to output the FPR code
(G95) with the tapping cycle and reset it at the end of the tapping operation, usually in the onCycleEnd
function.
case "tapping":
var F = cycle.feedrate / spindleSpeed;
writeBlock(
gRetractModal.format(98), gFeedModeModal.format(95), gCycleModal.format((84),
getCommonCycle(x, y, z, cycle.retract),
(conditional(P > 0, "P" + milliFormat.format(P)),
pitchOutput.format(F)
);
forceFeed(); // force the feedrate to be output after a tapping cycle with pitch output
break;
Output the Feedrate as FPR on a Tapping Cycle
4.25 onCycleEnd
function onCycleEnd() {
The onCycleEnd function is called after all points in the cycle operation have been processed. The cycle
is cancelled in this function and the feedrate mode (FPM) is reset if it is a tapping operation that uses
FPR feedrates.
function onCycleEnd() {
if (!cycleExpanded) {
writeBlock(gCycleModal.format(80));
// writeBlock(gFeedModeModal.format(94)), gCycleModal.format(80)); // reset FPM mode
zOutput.reset();
}
}
onCycleEnd Function
4.26 onRewindMachine
function onRewindMachine(_a, _b, _c) {
Argument Description
_a, _b, _c Rotary axes rewind positions.
Entry Functions 4-126
CAM Post Processor Guide 8/28/19
The onRewindMachine function is used to reposition the rotary axes when a machine limit is reached. It
is described in detail in the Rewinding of the Rotary Axis when Limits are Reached section of this
manual.
4.27.1 writeln
writeln(text);
Arguments Description
text Text to output to the NC file
The writeln function is built into the post engine and is not defined in the post processor. It is used to
output text to the NC file without formatting it. Text can be a quoted text string or a text expression.
writeln is typically used for outputting text strings that don't require formatting, or debug messages.
4.27.2 writeBlock
function writeBlock(arguments) {
Arguments Description
arguments Comma separated list of codes/text to output.
The writeBlock function writes a block of codes to the output NC file. It will add a sequence number to
the block, if sequence numbers are enabled and add an optional skip character if this is an optional
operation. A list of formatted codes and/or text strings are passed to the writeBlock function. The code
list is separated by commas, so that each code is passed as an individual argument, which allows for the
codes to be separated by the word separator defined by the setWordSeparator function.
/**
Entry Functions 4-127
CAM Post Processor Guide 8/28/19
Writes the specified block.
*/
function writeBlock() {
var text = formatWords(arguments);
if (!text) {
return;
}
if (properties.showSequenceNumbers) { // add sequence numbers to output blocks
if (optionalSection) {
if (text) {
writeWords("/", "N" + sequenceNumber, text);
}
} else {
writeWords2("N" + sequenceNumber, text);
}
sequenceNumber += properties.sequenceNumberIncrement;
} else { // no sequence numbers
if (optionalSection) {
writeWords2("/", text);
} else {
writeWords(text);
}
}
}
Sample writeBlock Function
4.27.3 toPreciseUnit
toPreciseUnit(value, units);
Arguments Description
value The input value.
units The units that the value is given in, either MM or IN.
The toPreciseUnit function allows you to specify a value in a given units and that value will be returned
in the active units of the input intermediate CNC file. When developing a post processor, it is highly
recommended that any unit based hard coded numbers use the toPreciseUnit function when defining the
number.
Entry Functions 4-128
CAM Post Processor Guide 8/28/19
yAxisMinimum = toPreciseUnit(gotYAxis ? -50.8 : 0, MM); // minimum range for the Y-axis
yAxisMaximum = toPreciseUnit(gotYAxis ? 50.8 : 0, MM); // maximum range for the Y-axis
xAxisMinimum = toPreciseUnit(0, MM); // maximum range for the X-axis (radius mode)
Defining Values using toPreciseUnit
4.27.4 force---
The force functions are used to force the output of the specified axes and/or feedrate the next time they
are supposed to be output, even if it has the same value as the previous value.
Function Description
forceXYZ Forces the output of the linear axes (X, Y, Z) on the next motion block.
forceABC Forces the output of the rotary axes (A, B, C) on the next motion block.
forceFeed Forces the output of the feedrate on the next motion block.
forceAny Forces all axes and the feedrate on the next motion block.
Force Functions
Arguments Description
arguments X, Y, and/or Z. Separated by commas when multiple axes are specified.
The writeRetract function is used to retract the Z-axis to its clearance plane and move the X and Y axes
to their home positions.
The writeRetract function can be called with one or more axes to move to their home position. The axes
are specified using their standard names of X, Y, Z, and are separated by commas if multiple axes are
specified in the call to writeRetract.
The writeRetract function is not generic in nature and may have to be changed to match your machine's
requirements. For example, some machines use a G28 to move an axis to its home position, some will
use a G53 with the home position, and some use a standard G00 block.
// special conditions
if (_useG28 && _xyzMoved[2] && (_xyzMoved[0] || _xyzMoved[1])) { // XY don't use G28
Entry Functions 4-130
CAM Post Processor Guide 8/28/19
error(localize("You cannot move home in XY & Z in the same block."));
return;
}
if (_xyzMoved[0] || _xyzMoved[1]) {
_useG28 = false;
}
5 Manual NC Commands
Manual NC commands are used to control the behavior of individual operations when there is not a
setting in the operation form for controlling a specific feature of a control. You can use Manual NC
commands to display a message, insert codes into the output NC file, perform an optional stop, define a
setting, etc. The Manual NC menu is accessed from different areas of the ribbon menu depending on the
product you are running.
Once you select the Manual NC menu you will see a form displayed that is used to select the type of
Manual NC command that you want to pass to the post processor and optionally the parameter that will
be passed with the command.
If you use a Manual NC command in your part, then it is necessary that the post processor is equipped to
handle this command. Some of the commands are supported by the stock post processors, such as Stop,
Optional stop, and Dwell, while support would have to be added to the post processor to support other
Manual NC commands. If you use a Manual NC command that is not supported by the post, then it will
either generate an error or be ignored. The general rule is it will generate an error if the onCommand
function is called and will be ignored when another function is called.
Arguments Description
command The Manual NC command that invoked the function.
value The value entered with the command.
The expandManualNC command can also be used to process the Manual NC command using the
separate functions listed in the table. It is typically used as the default condition in the onManualNC
function to process commands where you do not care if they are entered as a Manual NC command or
from an internal call in the post processor.
The following table describes the Manual NC commands along with the function that will be called
when the command is processed when the onManualNC function does not exist or expandManualNC is
called.
For example, the following onManualNC function definition could be used to process comments entered
using the CAM Manual NC command differently than comments generated from the post processor. It
simply appends the text ‘MSG,’ prior to the comment for a Manual NC Display comment command. All
other Manual NC commands are processed normally.
/**
Buffer Manual NC commands for processing later
*/
var manualNC = [];
function onManualNC(command, value) {
manualNC.push({command:command, value:value});
}
/**
Processes the Manual NC commands
Pass the desired command to process or leave argument list blank to process all buffered
commands
*/
function executeManualNC(command) {
for (var i = 0; i < manualNC.length; ++i) {
if (!command || (command == manualNC[i].command)) {
switch(manualNC[i].command) {
case COMMAND_DISPLAY_MESSAGE:
writeComment("MSG, " + manualNC[i].value);
break;
default:
expandManualNC(manualNC[i].command, manualNC[i].value);
}
}
}
for (var i = 0; i < manualNC.length; ++i) {
if (!command || (command == manualNC[i].command)) {
manualNC.splice(i, 1);
}
}
}
Manual NC Commands Support Functions
The calls to process the Manual NC commands can be placed anywhere in the post processor. In the
following code example, the COMMAND_DISPLAY_MESSAGE command is processed just before
the tool change block is output and the rest of the Manual NC commands after the tool change block.
The following sections give a description of the functions that are called by the Manual NC commands
outside of the onManualNC function and samples on how they are handled in the functions. The
onComment and onDwell functions are described in the Entry Functions chapter, since they are simple
functions and behave in the same manner no matter how they are called.
5.2 onCommand
function onCommand(command) {
Arguments Description
command Command to process.
All Manual NC commands that do not require an associated parameter are passed to the onCommand
function and as you see from the Manual NC Commands table, this entails the majority of the
commands. The onCommand function also handles other commands that are not generated by a Manual
NC command and these are described in the onCommand section in the Entry Functions chapter.
function onCommand(command) {
switch (command) {
…
case COMMAND_BREAK_CONTROL: // handle the 'Tool break' command
if (!toolChecked) { // avoid duplicate COMMAND_BREAK_CONTROL
onCommand(COMMAND_STOP_SPINDLE);
onCommand(COMMAND_COOLANT_OFF);
writeBlock(
gFormat.format(65),
"P" + 9853,
"T" + toolFormat.format(tool.number),
"B" + xyzFormat.format(0),
"H" + xyzFormat.format(properties.toolBreakageTolerance)
);
toolChecked = true;
}
Manual NC Commands 5-137
CAM Post Processor Guide 8/28/19
return;
case COMMAND_TOOL_MEASURE: // ignore tool measurements
return;
}
5.3 onParameter
function onParameter(name, value) {
Arguments Description
name Parameter name.
value Value stored in the parameter.
The onParameter function handles the Action, Call program, Display message, and Print message
Manual NC commands. It is passed both the name of the parameter being defined and the text string
associated with that parameter. This section will describe how the Action command can be used, since
this is the most commonly used of these commands.
The Action command is typically used to define post processor settings, similar to the post properties
defined at the top of the post processor, except that the settings defined using this command typically
only apply to a single operation. Since the HSM operations are executed in the order that they are
defined in the CAM tree, the Manual NC command will always be processed prior to the operation that
they precede. You can also use the Action command to define a setting so that the command can be
executed within another section of the post, by referencing this setting. You can even define settings
that are typically set in the post properties into your program, so you are not reliant on making sure that
the property is set for a specific program. In this case the Action command would set the value of the
post property based on the input value associated with the command.
It is the onParameter function's responsibility to parse the text string passed as part of the Action
command. The text string could be a value, list of values, command and value, etc. The following table
lists the Action commands that are supported by the sample post processor code used in this section.
These Action commands set variables that will be used elsewhere in the program.
In this example, the format for entering the Action Manual NC command is to specify the command
followed by the ':' separator which in turn is followed by the value, in the Action text field.
var smoothingType = 0;
var smoothingTolerance = .001;
function onParameter(name, value) {
var invalid = false;
switch (name) {
case "action":
var sText1 = String(value).toUpperCase();
var sText2 = new Array();
sText2 = sText1.split(":");
if (sText2.length != 2) {
error(localize("Invalid action command: ") + value);
return;
}
switch (sText2[0]) {
case "SMOOTHING":
smoothingType = parseChoice(sText2[1], "OFF", "LOW", "MEDIUM", "HIGH");
if (smoothingType == undefined) {
error(localize("Smoothing type must be Off, Low, Medium, or High"));
return;
}
break;
case "TOLERANCE":
smoothingTolerance = parseFloat(sText2[1]);
if (isNaN(smoothingTolerance) || ((smoothingTolerance < .001) || (smoothingTolerance > .999))) {
Manual NC Commands 5-139
CAM Post Processor Guide 8/28/19
error(localize("Smoothing tolerance must be a value between .001 and .999"));
return;
}
break;
case "FASTTOOLCHANGE":
var fast = parseChoice(sText2[1], "YES", "NO");
if (fast == undefined) {
error(localize("fastToolChange must be Yes or No"));
return;
}
properties.fastToolChange = fast;
break;
default:
error(localize("Invalid action parameter: ") + sText2[0] + ":" + sText2[1]);
return;
}
}
}
To make it easier to use custom Action Manual NC commands you can use the Template capabilities of
HSM. First you will create the Manual NC command that you will turn into a template using the
example in the Action Command Format picture shown above. Once the Manual NC command is
created you will want to give it a meaningful name by renaming it in the Operation Tree.
Now you will create a template from this Manual NC command by right clicking on the Manual NC
command and selecting Store As Template. You will want to give the template the same name as you
did in the rename operation.
The template is now ready to be used in other operations and parts. You do this by right clicking a
Setup or a Folder in the Operations Tree, position the mouse over the Create From Template menu and
select the template you created.
5.4 onPassThrough
Function onPassThrough (value)
Arguments Description
value Text to be output to the NC file.
The Pass through Manual NC command is used to pass a text string directly to the NC file without any
processing by the post processor. It is similar to editing the NC file and adding a line of text by hand.
The text string could be standard codes (G, M, etc.) or a simple message. Since the post has no control
or knowledge of the codes being output, it is recommended that you use the Pass through command
sparingly and only with codes that cannot be output using another method.
function onPassThrough(text) {
var commands = String(text).split(",");
for (text in commands) {
writeBlock(commands[text]);
}
}
Output Lines of Codes/Text Separated by Commands Using the Pass through Manual NC Command
Like the Action Manual NC command, you can setup a Template to use with the Pass through command
if you find yourself needing to output the same codes in multiple instances.
6 Debugging
6.1 Overview
The first thing to note when debugging is that there is not an interactive debugger associated with the
Autodesk CAM post processors. This means that all debugging information must be output using
settings within the post and with explicit writes. This section describes different methods you can use
when debugging your post.
You can also use the HSM Post Processor Editor to aid in debugging your program as described in the
Running/Debugging the Post section of this manual
342: onParameter('dwell', 0)
344: onParameter('incrementalDepth', 0.03937007874015748)
346: onParameter('incrementalDepthReduction', 0.003937007932681737)
348: onParameter('minimumIncrementalDepth', 0.01968503937007874)
350: onParameter('accumulatedDepth', 5)
352: onParameter('chipBreakDistance', 0.004023600105694899)
354: onMovement(MOVEMENT_CUTTING /*cutting*/)
354: onCycle()
cycleType='chip-breaking'
cycle.clearance=123456
cycle.retract=0.19685039370078738
Debugging 6-142
CAM Post Processor Guide 8/28/19
cycle.stock=0
cycle.depth=0.810440544068344
cycle.feedrate=15.748000257597194
cycle.retractFeedrate=39.370100366787646
cycle.plungeFeedrate=15.748000257597194
cycle.dwell=0
cycle.incrementalDepth=0.03937007874015748
cycle.incrementalDepthReduction=0.003937007932681737
cycle.minimumIncrementalDepth=0.01968503937007874
cycle.accumulatedDepth=5
cycle.chipBreakDistance=0.004023600105694899
354: onCyclePoint(-1.25, 0.4999999924907534, -0.810440544068344)
355: onCyclePoint(1.25, 0.4999999924907534, -0.810440544068344)
356: onCycleEnd()
Sample dump.cps Output
6.3.1 debugMode
debugMode = true;
Setting the debugMode variable to true enables the output of debug information from the debug
command and is typically defined at the start of the post processor.
6.3.2 setWriteInvocations
setWriteInvocations (value);
Arguments Description
value true outputs debug information for the entry functions.
Enabling the setWriteInvocations setting will create debug output in the NC file similar to what is output
using the dump post processor. The debug information contains the entry functions (onParameter,
onSection, etc.) called during post processing and the parameters that they are called with. This
information will be output prior to actually calling the entry function and is labeled using the !DEBUG:
text.
Debugging 6-143
CAM Post Processor Guide 8/28/19
!DEBUG: onLinear(-0.433735, 1.44892, -0.5, 19.685)
N200 Z-0.5 F19.68
setWriteInvocations Output
6.3.3 setWriteStack
setWriteStack (value);
Arguments Description
value true outputs the call stack that outputs the line to the NC file.
Enabling the setWriteStack setting displays the call stack whenever text is output to the NC file. The
call stack will consist of the !DEBUG: label, the call level, the name of the post processor, and the line
number of the function call (the function name is not included in the output).
!DEBUG: 1 rs274.cps:108
!DEBUG: 2 rs274.cps:919
!DEBUG: 3 rs274.cps:357
N125 M5
setWriteStack Output
…
108: writeWords2("N" + sequenceNumber, arguments);
…
357: onCommand(COMMAND_STOP_SPINDLE);
…
919: writeBlock(mFormat.format(mcode));
Post Processor Contents
The text provided to the debug functions can contain operations and follow the same rules as defining a
string variable in JavaScript. You can also specify vectors or matrixes and these will be properly
formatted for output. For example,
var x = 3;
debug("The value of x is " + x);
For floating point values you may want to create a format that limits the number of digits to right of the
decimal point, as some numbers can be quite long when output.
When writing output debug information to the log and/or NC files it is recommended that you precede
the debug text with a fixed string, such as "DEBUG – ", so that it is easily discernable from other output.
6.4.1 debug
debug (text);
Arguments Description
text Outputs text to the log file when debugMode is set to true.
The debug function outputs the provided text message to the log file only when the debugMode variable
is set to true. The text is output exactly as provided, without any designation that the output was
generated by the debug function.
6.4.2 log
log(text);
Arguments Description
text Outputs text to the log file.
The log function outputs the text to the log file. It is similar to the debug function, but does not rely on
the debugMode setting.
6.4.3 writeln
writeln(text);
Arguments Description
text Outputs text to the NC file.
The writeln function outputs the text to the NC file. It is used extensively in post processors to output
valid data to the NC file and not just debug text.
6.4.4 writeComment
writeComment(text);
Arguments Description
text Outputs text to the NC file as a comment.
Debugging 6-145
CAM Post Processor Guide 8/28/19
The writeComment function is defined in the post processor and is used to output comments to the
output NC file. It is described in the onComment section of this manual.
6.4.5 writeDebug
Function writeDebug(text);
Arguments Description
text Outputs text to the NC and log files.
The writeDebug function is not typically present in the generic post processors. You can create one to
handle the output of debug information to both the log file and NC file so that if the post processor either
fails or runs successfully you would still see the debug output.
function writeDebug(text) {
if (true) { // can use the global setting 'debugMode' instead
writeln("DEBUG - " + text); // can use 'writeComment' instead
log("DEBUG - " + text); // can use 'debug' instead
}
}
Sample writeDebug Function
Please note that support for 3+2 operations is not handled here, except for the setup of the machine.
Refer to the Work Plane section in the onSection chapter for a description on how to handle 3+2
operations.
setMachineConfiguration(machineConfiguration);
optimizeMachineAngles2(0); // TCP mode
}
if (!machineConfiguration.isMachineCoordinate(0)) {
aOutput.disable();
}
if (!machineConfiguration.isMachineCoordinate(1)) {
bOutput.disable();
}
if (!machineConfiguration.isMachineCoordinate(2)) {
cOutput.disable();
}
Define the Machine Configuration
The conditional at the start of the logic must be set to true for the multi-axis configuration to be defined.
You can now customize the rotary axes to match the machine configuration as described below.
First, you will need to use the createAxis function to define all available axes. The createAxis function
accepts the following parameters.
Parameter Description
table Set to true when the rotary axis is a table, or false if it is a head. The default if not
specified is true.
axis Specifies the rotational axis of the rotary axis in the format of a vector, i.e. [0, 0, 1].
This vector does not have to be orthogonal to a major plane, for example it could be [0,
.7017, .7017]. The direction of the rotary axes are based on the righthand rule for tables
and the lefthand rule for heads. You can change direction of the axis by supplying a
vector pointing in the opposite direction, i.e. [0, 0, -1]. This parameter is required.
offset Defines the rotational position of the axis in the format of a coordinate, i.e. [0, 0, 0], but
it is not currently supported by the post processor. Adding support for this offset
position when the rotary configurataion consists of at least one head is discussed in the
Adjusting the Points for Rotary Heads section of this chapter. The default is [0, 0, 0].
Multi-Axis Post Processors 7-147
CAM Post Processor Guide 8/28/19
Parameter Description
coordinate Defines the coordinate of the axis, either X, Y, or Z. You will notice a number used in
most of the generic posts, in this case 0=X, 1=Y, and 2=Z. Either specification is
acceptable input. This parameter is required.
cyclic Defines whether the axis is cyclic (continuous) in nature, in that the output will always
be within the range specified by the range parameter. Cyclic axes will never cause the
onRewindFunction to be called, since they are continuous in nature and do not have
limits. The range applies specifically to output values for this axis. The default is false.
range Defines the upper and lower limits of the rotary axis using the format [lower, upper]. If
the rotary axis is cyclic, then the range sets the limits of the output values for this axis,
if it is not cyclic the range is the actual physical limits of the machine.
preference Specifies the preferred angle direction at the beginning of an operation. -1 = choose the
negative angle, 0 = no preference, and 1 = choose the positive angle. The default is 0.
reset Defines the starting position of the axis for a new operation and when the rotary axes
need to be rewound and reconfigured due to exceeding the limits. 0 = remember the
position from previous section, 1 = reset to 0 at start of operation, 2 = reset to 0 at
automatic rewind, 3 = reset to 0 at start of operation and at automatic rewind. This
parameter is implemented since R42225 of the post engine.
resolution Specifies the resolution in degrees of the rotational actuator. Typically, this will be set
to the number of digits to the right of the decimal as specified in the createFormat call
for the rotary axes. The default is 0.
createAxis Parameters
Now you will have to define the machine configuration using the following command.
The order in which the axes are defined in the MachineConfiguration definition is important and must
use the following order.
The optimizeMachineAngles2 function determines if the tool endpoint coordinates should be adjusted for
the rotary axes and can have the following values.
Value Description
0 Don't adjust the coordinates for the rotary axes. Used for TCP mode.
1 Adjust the coordinates for the rotary axes. If either of the rotary axes
is a head, then this setting should not be used as there is no internal
support for adjusting the points for a head. Adding this capability to
the post is discussed further in the Adjusting the Points for Rotary
Heads section of this chapter.
2 Adjust the coordinates for rotary tables. No adjustment will be made
for heads.
optimizeMachineAngles2 Settings
The code to disable the output variables for each axis is generic in nature and should be exactly as
shown.
if (!machineConfiguration.isMachineCoordinate(0)) {
aOutput.disable();
}
if (!machineConfiguration.isMachineCoordinate(1)) {
bOutput.disable();
}
if (!machineConfiguration.isMachineCoordinate(2)) {
cOutput.disable();
}
Disable the Output of Unused Rotary Axes
if (currentSection.isMultiAxis()) {
forceWorkPlane();
cancelTransformation();
onCommand(COMMAND_UNLOCK_MULTI_AXIS);
var abc = currentSection.getInitialToolAxisABC();
gMotionModal.reset();
writeBlock(
gMotionModal.format(0),
conditional(machineConfiguration.isMachineCoordinate(0), aOutput.format(abc.x)),
conditional(machineConfiguration.isMachineCoordinate(1), bOutput.format(abc.y)),
conditional(machineConfiguration.isMachineCoordinate(2), cOutput.format(abc.z))
);
} else {
Output Initial Rotary Axes Positions
if (x || y || z || a || b || c) {
writeBlock(gMotionModal.format(1), x, y, z, a, b, c, f);
} else if (f) {
if (getNextRecord().isMotion()) { // try not to output feed without motion
feedOutput.reset(); // force feed on next line
} else {
writeBlock(gMotionModal.format(1), f);
}
}
}
onLinear5D Function
Both of these functions as presented are basic in nature and the requirements for your machine may
require some modification. For example, the tool endpoint may have to be adjusted for rotary heads or
inverse time feedrates may need to be supported.
Function Description
machineConfiguration.isMultiAxisConfiguration() Returns true if a machine configuration containing rotary
axes has been defined. It is still possible to create output
Multi-Axis Post Processors 7-151
CAM Post Processor Guide 8/28/19
Function Description
for some multi-axis machines if the rotary axes have not
been defined, by outputting the tool axis vector instead of
the rotary axes positions or by using Euler angles for 3+2
operations.
machineConfiguration.getABC(matrix) Returns the rotary axes angles for the provided matrix.
This matrix is usually the Work Plane matrix
(currentSection.workPlane).
machineConfiguration.remapToABC(abc, current) Returns the closest rotary axes angles to the current axes
positions as a Vector. abc is the rotary angles to be
remapped.
machineConfiguration.remapABC(abc) Returns the rotary axes angles within the valid range for
each angle as a Vector..
machineConfiguration.getPreferred(abc) Returns the preferred rotary axes angles given the input
abc angles as a Vector. The preferred angles will be in
the valid range for each angle.
machineConfiguration.isABCSupported(abc) Returns true if the abc angles are within the valid ranges
for the defined rotary axes. Returns false if any of the
angles are outside of their defined range.
section.isOptimizedForMachine() Returns true if an active machine configuration containing
rotary axes is defined for the provided section..
section.isMultiAxis() Returns true if the operation specified by section is a
multi-axis operation.
section.getGlobalInitialToolAxis() Returns the initial tool axis for the provided section as a
Vector. Usually used at the start of an operation using the
currentSection variable.
section.getInitialToolAxisABC() Returns the initial rotary axes angles for the provided
section as a Vector. Usually used at the start of an
operation using the currentSection variable. An error will
be generated if a machine configuration containing rotary
axes has not been defined.
section.getGlobalFinalToolAxis() Returns the final tool axis for the provided section as a
Vector. Usually used at the start of an operation using
getPreviousSection().
section.getFinalToolAxisABC() Returns the final rotary axes angles for the provided
section as a Vector. Usually used at the start of an
operation using getPreviousSection(). An error will be
generated if a machine configuration containing rotary
axes has not been defined.
getCurrentDirection() Returns the current rotary axes angles as a Vector in a
multi-axis operation. It will return the Work Plane
forward vector when in a 3-axis or 3+2 operation.
is3D() Returns true if the entire program is a 3-axis operation
with no multi-axis operations. Returns false if even one
operation is a 3+2 or multi-axis operation.
Multi-Axis Common Functions
A rotary scale on the other had typically outputs the rotary angle positions between 0 and 360 degrees,
usually with the sign ± specifying the direction. If a sign is not required and the control will always take
the shortest route, then it is pretty straight forward to output the rotary axis on a rotary scale, simply
define it as a cyclic axis with a range of 0 to 360 degrees.
You may also have to create a blank onRewindMachine function so that the post processor does not
produce an error when the specified range of the axis is exceeded. The new version of the post kernel
will treat a cyclic axis as a continuous axis and will not require rewinds when the specified range is
exceeded. If you are creating a 5-axis post-processor and the range of the non-continuous rotary axis
can be exceeded, then refer to the onRewindMachine section in this chapter on how to handle this
situation.
For controls that require a sign to designate the direction the rotary axis will move, you will need to keep
track of the current axis position and include a function to calculate the rotary axis output with the sign.
// collected state
…
var previousABC = new Vector(0, 0, 0)
Define the previousABC Variable
The previousABC variable should only be set in the setWorkPlane function when 3+2 operations are
output as the actual rotary axes positions. If the 3+2 orientation is defined using Euler angles, then the
rotary axis positions need to be calculated and stored in the previousABC variable separately. You can
typically use the machineConfiguration.getABC function to calculate the rotary axes positions from the
work plane.
previousABC = machineConfiguration.getABC(currentSection.workPlane);
Calculate the Rotary Axes from the 3+2 Work Plane
You will now need to add the function that calculates the rotary axes using a directional (signed) value.
The final required step is to call the getDirectionalABC function wherever the rotary axis is output. In
the following code, the C-axis is output on a rotary scale.
if (currentSection.isMultiAxis()) {
forceWorkPlane();
cancelTransformation();
onCommand(COMMAND_UNLOCK_MULTI_AXIS);
var abc = currentSection.getInitialToolAxisABC();
gMotionModal.reset();
writeBlock(
gMotionModal.format(0),
conditional(machineConfiguration.isMachineCoordinate(0), aOutput.format(abc.x)),
conditional(machineConfiguration.isMachineCoordinate(1), bOutput.format(abc.y)),
conditional(machineConfiguration.isMachineCoordinate(2),
cOutput.format(getDirectionalABC(previousABC.z, abc.z, cOutput))
);
…
function onRapid5D(_x, _y, _z, _a, _b, _c) {
…
var a = aOutput.format(_a);
var b = bOutput.format(_b);
var c = cOutput.format(getDirectionalABC(previousABC.z, _c, cOutput));
…
function onLinear5D(_x, _y, _z, _a, _b, _c, feed) {
…
var a = aOutput.format(_a);
var b = bOutput.format(_b);
var c = cOutput.format(getDirectionalABC(previousABC.z, _c, cOutput));
…
Adding Calls to getDirectionalABC
Similar to setting the previousABC variable in the setWorkPlane function, the call to getDirectionalABC
should only be made when the actual rotary axes positions are output and should not be used when Euler
angles are output.
First, you will need to make sure that you set the proper tool path adjustments so that the tool tip data is
provided as input to the post processor using the optimizeMachineAngles2 function as described earlier
in this chapter.
Now if your machine supports TCP programming, you can skip the rest of this section, as this is all that
is needed (except for outputting the code to enable TCP programming if required by the machine
control).
If your machine consists of a rotary table and a rotary head, then the value passed to
optimizeMachineAngles2 should be 2, so that the tool path is adjusted for the table. The distance to the
pivot point(s) of the head is defined in the offset parameter of the createAxis command.
Remember the head slave/rider axis is defined first and then the head master/carrier axis. When the
master and slave heads share a common pivot point, then only the offset for the slave axis needs to be
defined. This offset is defined from the tool stop position to the pivot point. When the pivot points are
different, the master axis offset is defined as the offset from the slave pivot point. Most machines will
use a common pivot point for both rotary axes.
One other offset that needs to be addressed is the distance from the tool tip to the tool stop. This value is
either a fixed number if tool length compensation is supported, or is defined by the tool body length.
You will need to add a function that adjusts the points for the rotary head. This is typically
accomplished by translating the tool tip point up the tool axis to the pivot point of the rotary head and
then back down along the spindle axis to the virtual tool tip when the head is at 0 degrees and the control
supports tool length compensation along the spindle axis. If tool length compensation is not supported,
you will need to translate the tool tip to the pivot point of the rotary head and output this position. The
following code is used to calculate the output coordinates for a rotary head and can be included in your
post processor.
if (!reverse) {
xyz = getOptimizedHeads(xyz, abc, rotaryAxis, reverse);
} else {
xyz = getOptimizedHeads(xyz, abc, rotaryAxis, reverse);
}
return xyz;
}
The code is generic in nature and should not have to be modified when inserting it into a post processor,
but there are settings at the top of the code that may have to be changed to match your requirements.
Setting Description
useOptimized Should be set to OPTIMIZE_HEADS to adjust the tool end points for the
head rotations.
usePivotPoint true = the tool locations will be adjusted to be at the pivot point of the
rotary head. false = the tool locations will be adjusted to be at the virtual
tool endpoint (as if the rotary head angles are at 0 degrees). false is used for
machines that support tool length compensation with multi-axis moves,
where the virtual tool position will be output.
toolLength The length of the tool. This can be set to a fixed value when tool length
compensation is used. When the pivot point is output, then this value
should reflect the distance of the tool tip to the tool stop position.
Calls to the getOptimizedPosition need to be inserted wherever the tool position is output, for example
in the onRapid5D and onLinear5D functions. The same calls may have to be added to the 3-axis
functions, output of initial point, onLinear, onRapid, onCyclePoint, and onCircular, depending on if tool
length compensation is supported in the control.
var x = xOutput.format(xyz.x);
var y = yOutput.format(xyz.y);
var z = zOutput.format(xyz.z);
If the control requires the pivot point locations, then you will need to define the tool length each time a
tool is loaded and add the call to getOptimizedPosition to all functions that output the tool position,
including the onSection (output of initial position), onRapid, onLinear, onCyclePoint, and onCircular
functions.
toolLength = tool.bodyLength;
var xyz = getFramePosition(currentSection.getInitialPosition());
var initialPosition = getOptimizedPosition(xyz, abc, TCP_OPTIMIZED);
Set the Tool Length for Pivot Point Output
The singularity logic in the kernel will massage the tool axis direction to keep the tool within tolerance
and minimize the rotary axis movement in these cases. A safeguard that linearizes the moves around the
singularity has also been implemented. This linearization will add tool locations as necessary to keep
the tool endpoint within tolerance of the part.
There are settings in the post processor that manage how the singularity issue is handled. These settings
are defined using the following command.
Variable Description
adjust Set to true to enable singularity optimization within the post processor.
Singularity optimization includes the ability to adjust the tool axis to
minimize singularity issues (large rotary axis movement when the tool axis
approaches perpendicularity to a rotary axis) and the linearization of the
moves around the singularity to keep the tool endpoint within tolerance. The
default is true.
method When set to SINGULARITY_LINEARIZE_OFF it disables the linearization
of the moves to keep the tool endpoint within tolerance of the programmed
tool path around the singularity. SINGULARITY_LINEARIZE_ROTARY
will linearize the moves around the singularity. Additional points are added
to keep the tool within the specified tolerance and is optimized for revolved
movement as if the tool were moving around a cylinder or other revolved
feature. SINGULARITY_LINEARIZE_LINEAR will also add additional
points to keep the tool within tolerance, but will keep the tool endpoint
moving in a straight line. The default is
SINGULARITY_LINEARIZE_ROTARY.
cone Specifies the angular distance that the tool axis vector must be within in
reference to the singularity point before the singularity logic is activated. This
is usually a small value (less than 5 degrees), since the further away the tool
Multi-Axis Post Processors 7-162
CAM Post Processor Guide 8/28/19
Variable Description
axis is from the singularity, the less noticeable the fluctuations in the rotary
axes will be and the less benefit this feature will provide. This parameter is
specified in radians and the default value is .052 (3 degrees).
angle The minimum angular delta movement that the rotary axes must move prior
to considering adjusting the tool axis vector for singularity optimization. This
limit is used to keep from adjusting the tool axis vector when the rotary axes
do not fluctuate greatly. This is typically set to a value of 10 degrees or more.
This parameter is in radians and the default value is .175 (10 degrees).
tolerance The tolerance value used to keep the tool within tolerance when the tool axis
is adjusted to minimize rotary axis movement around the singularity. The
default value is .04mm (.0015in).
linearizationTolerance The tolerance value to use when additional points are added to keep the tool
endpoint within tolerance of the programmed move when the tool axis is near
the singularity. The default value is .04mm (.0015in).
The default settings are valid for most tool paths, but this command allows for some tweaking in special
cases where you want to fine tune the output.
The best possible solution for the rotary axes is always selected at the start of an operation and when a
rewind is required due to a rotary axis crossing the limits, the tool will always stop on the exact limit of
the machine, eliminating previous scenarios where a valid solution for the rewinding of the rotary axes
could not always be found.
When a rewind is required there is a group of functions that can be added to the custom post processor to
handle the actual rewinding of the affected rotary axis. This code can be easily copied into your custom
post processor and modified to suit your needs with just a little bit of effort.
One setting that is very important when defining a rotary axis is the cyclic parameter in the call to
createAxis. Where in older versions of the post kernel you would set the cyclic parameter to enable the
ability to rewind the rotary axes when the limits were reached, cyclic is now considered synonymous
with continuous, meaning that this axis has no limits and will not be considered when determining if the
rotary axes have to be repositioned to stay within limits. The range specifier used in conjunction with a
cyclic axis defines the output limits of a rotary axis, for example specifying a range of [0,360] will cause
all output angles for this axis to be output between 0 and 360 degrees. The range for a non-cyclic axis
defines the actual physical limits of that axis on the machine and are used to determine when a rewind is
Another important setting is the reset parameter, which allows you to define the starting angle at the
start of an operation and after a rewind of the axes has occurred. By default, the post engine will use the
ending angle of the previous multi-axis operation. Some controls allow for the rotary axis encoder to be
reset so that the stored angle is reset to be within the 0-360 degrees without unwinding the axis. In this
case you will want to issue the proper codes to reset the axis encoder, for example G28 C0, and specify
reset:3 when you create the axis.
Now on to how you can implement the onRewindMachine capabilities in your post. First, copy the code
from a post processor that contains these functions, such as the haas umc-750.cps post processor. All
the lines between and including the following lines should be copied.
This code is generic in nature and will work with all machine configurations; table/table, head/head, and
head/table. Because of this most of the functions included in this code will not have to be modified by
you. The rest of this section describes the changes that you may have to make to customize the rewind
logic for your machine.
The safeRetractDistance value is added to the distance that the tool will be retracted out of the part prior
to rewinding the rotary axis. The tool will be retracted past the stock of the part plus this value.
properties = {
…
safeRetractDistance: 0.0 // distance to add to retract distance when rewinding rotary axes
}
Add safeRetractDistance to Properties Table
The variables at the top of the rewind code determine if rewinds are supported, the feedrates, and stock
expansion.
Variable Description
performRewinds When set to false an error will be generated when a rewind of a rotary axis
is required. Setting it to true will enable the rewind logic to be executed.
safeRetractFeed Specifies the feedrate to retract the tool prior to rewinding the rotary axis.
The first function that is unique for different machines is the onRewindMachineEntry function, which is
used to either override or supplement the standard rewind logic. It will simply return false when the
standard rewind logic of retracting the tool, repositioning the rotary axes, and repositioning the tool is
desired. Code can be added to this function for controls that just require the encoder to be reset or to
output the new rotary axis position when the control will automatically track the tool with the rotary axis
movement. The following example resets the C-axis encoder on a Hass machine when it is currently at
a multiple of 360 degrees and the B-axis does not change.
Returning a value of true designates that the onRewindMachineEntry function performed all necessary
actions to reposition the rotary axes and the retract/reposition/plunge sequence will not be performed.
Returning false will process the retract/reposition/plunge sequence normally.
The moveToSafeRetractPosition function controls the move to a safe position after the tool is retracted
from the part and before the rotary axes are repositioned. It will typically move to the home position in
Z and optionally in X and Y using a G28 or G53 style block. You should find similar code to retract the
tool when positioning the rotary axes for a 3+2 operation and in the onClose function, which positions
the tool at the end of the program. You should use the same logic found in these areas for the
moveToSafeRetractPosition function.
The returnFromSafeRetractPosition function controls the move back to the position of the tool at the
original retract location past the stock. This function is called after the rotary axes are repositioned.
These should be all the areas of the rewind code that should be modified, the rest is generic for all
machine configurations.
To implement multi-axis feedrate support into your post, you will first need to copy the code from a post
processor that already supports this feature, such as the haas trunnion.cps post processor. All the lines
between and including the following lines should be copied.
This code is generic in nature and will work with all machine configurations; table/table, head/head, and
head/table. Because of this most of the functions included in this code will not have to be modified by
you, though you will have to modify other sections of the post processor to fully implement this feedrate
logic.
The rest of this section describes the changes that you may have to make to customize the multi-axis
feedrate logic for your machine.
If Inverse Time feedrates are supported you will need to create the inverseTimeOutput variable at the top
of the post processor code and if the accuracy of the Inverse Time feedrates is different than the standard
FPM feedrate you will also need to create a new format to associate with it.
The variables at the top of the multi-axis feedrate code define variables used in the calculation of Inverse
Time and DPM feedrates.
var dpmBPW = (unit == IN) ? 0.1 : 1.0; // ratio of rotary accuracy to linear for DPM calculations
var inverseTimeUnits = 1.0; // 1.0 = minutes, 60.0 = seconds
Multi-Axis Post Processors 7-167
CAM Post Processor Guide 8/28/19
var maxInverseTime = 45000; // maximum value to output for Inverse Time feeds
var maxDPM = 9999.99; // maximum value to output for DPM feeds
var useInverseTimeFeed = true; // use 1/T feeds
var previousDPMFeed = 0; // previously output DPM feed
var dpmFeedToler = 0.5; // tolerance to determine when the DPM feed has changed
// var previousABC = new Vector(0, 0, 0); // previous ABC if used in post, don't define if not used
var forceOptimized = undefined; // used to override optimized-for-angles points (XZC-mode)
Variable Description
dpmBPW Defines the pulse weight ratio for the rotary axes when DPM feedrates are
output as a combination of linear and rotary movements. The pulse
weight is a scale factor based on the rotary axes accuracy compared to the
linear axes accuracy. For example, it should be set to .1 when the linear
axes are output on .0001 increments and the rotary axes on .001
increments.
inverseTimeUnits Defines the unit of time for Inverse Time feedrates. Specify 1.0 for
minutes or 60.0 for seconds.
maxInverseTime Specifies the maximum value that can be output for Inverse Time
feedrates.
maxDPM The maximum value that can be output for DPM feedrates.
useInverseTimeFeed Can be set to true for Inverse Time feedrates or false for DPM feedrates
when only one of the formats is supported.
previousDPMFeed Used to determine when the DPM feedrate should be output. Should not
be changed.
dpmFeedToler Determines when the DPM feedrate should be output. The calculated
feedrate number will not be output unless it changes by more than this
value.
previousABC Some post processors require that the previous ABC output positions be
maintained inside the post processor, for example post processors that
output the rotary axes on a rotary scale with the sign of the value
specifying the direction of rotation. In this case, previousABC should be
defined. If the post processor does not maintain this variable, then it
should be commented out, otherwise it will adversely affect the
calculations of the multi-axis feedrates.
forceOptimized This variable is used for Mill/Turn machines where multi-axis
programming uses the points adjusted for the C-axis and XZC
programming uses the input tool endpoint positions. It is set to false when
calculating the XZC mode positions and to undefined for all other
positions. It must be set to undefined when created.
headOffset For machines that have a rotary head, the headOffset variable can be
defined. It contains the fixed pivot length combined with the tool length
and is used to calculate the length of the move. Basically, it is the
distance from the tool tip to the pivot point of the head. This variable is
typically defined in post processors that support rotary heads.
Variables that Control Multi-Axis Feedrate Calculations
The object returned from the getMoveLength function returns the values that may be needed by different
post processors to calculate the Inverse Time and DPM feedrates. The following table lists the variables
calculated and returned by the getMoveLength function.
Variable Description
abc Delta movement for each rotary axis, returned as a Vector.
abcLength Combined rotary delta movement.
radius Calculated radius for each rotary axis, returned as a Vector.
tool Calculated tool endpoint movement along the actual tool path.
xyz Delta movement for each linear axis, returned as a Vector.
xyzLength Combined linear delta movement.
Move LengthVariables
If your machine supports both Inverse Time and DPM feedrates, you can add the useInverseTime
variable to the property table at the top of the post processor and allow the user to choose the multi-axis
feedrate format.
properties = {
…
useInverseTime: true // true = inverse time feedrates, false = degrees per minute feedrates
}
Multi-Axis Post Processors 7-169
CAM Post Processor Guide 8/28/19
…
propertyDefinitions = {
…
useInverseTime: {title:"Use inverse time feedrates",
description:"'Yes' enables inverse time feedrates, 'No' outputs DPM feedrates.", type:"boolean"}
Optionally Add useInverseTime to Properties Table
The only other function that you may need to modify in the included code is the getFeedDPM function
that calculates the Degrees Per Minute feedrates. It contains calculations for standard DPM feedrates
and combination FPM/DPM feedrates based on the combined movement of the linear and rotary axes,
sometimes referred to as Pulses Per Minute. There are some controls that use a proprietary calculation
for DPM feedrates, such as the Fadal control. In this case there is a defined block where you can add the
control specific calculation.
Now there are other areas of the post processor that need to be changed to support these feedrate modes.
First, the onLinear5D function must have support added to call the function and output the correct
feedrate codes.
You will need to reset the feedrate mode to FPM either at the end of the multi-axis operation or on a
standard 3-axis move. It is much easier to do this at the end of the section, otherwise you would have to
modify all instances that output feedrates, such as in onLinear, onCircular, onCycle, etc.
function onSectionEnd() {
…
if (currentSection.isMultiAxis()) {
writeBlock(gFeedModeModal.format(94)); // inverse time feed off
}
You can check the post processor you are working with to see if it supports WCS Probing. The easiest
method is to try to run a probing operation against the post, the post will fail if probing is not supported.
You may see an error message complaining about the spindle speed being out of range (probe operations
do not turn on the spindle) or a message that states that the probing cycle must be handled in the post
processor.
###############################################################################
Error: Spindle speed out of range.
Error at line: 735
Error in operation: 'WCS Probe1'
Failed while processing onSection() for record 261.
###############################################################################
Spindle Speed Error Message
If you receive either of these messages, then probing is not supported in your post processor and you
will need to add it.
One thing you will notice when creating a probing operation is that interface is intelligent enough to
only give you the probing operation types that apply to the type of geometry selected. For example, if
you select a planar face perpendicular to the X-axis, then the only operations available to you are the X
surface and Angle along X-axis operations.
The WCS Probing operations are considered a canned cycle in the post processor and therefore are
output in the onCyclePoint function, with the probe type being stored in the cycleType variable. The
following table lists the available probing operations. You should note that probing cycles cannot be
expanded and must be handled in the post processor, either by performing the cycle or by giving an
error.
cycleType Description
probing-X Probes a wall perpendicular to the X-axis.
probing-Y Probes a wall perpendicular to the Y-axis.
probing-Z Probes a wall perpendicular to the Z-axis.
probing-x-wall Probes a wall thickness in the X-axis
probing-y-wall Probes a wall thickness in the Y-axis
probing-x-channel Probes the open distance between two walls in the X-axis
probing-y-channel Probes the open distance between two walls in the Y-axis
probing-x-channel-with-island Probes the open distance between two walls with an
island between the walls in the X-axis
probing-y-channel-with-island Probes the open distance between two walls with an
island between the walls in the Y-axis
probing-xy-circular-boss Probes the outer wall of a circular boss
probing-xy-circular-hole Probes the inner wall of a circular hole
probing-xy-circular-hole-with-island Probes the inner wall of a circular hole with an island in
the hole
probing-xy-rectangular-boss Probes the outer walls of a rectangular protrusion
probing-xy-rectangular-hole Probes the inner walls of a rectangular hole
probing-xy-rectangular-hole-with-island Probes the inner walls of a rectangular hole with an island
in the hole
probing-xy-inner-corner Probes an inner corner. Modifies the origin and rotation
of the part.
The parameters defined in the WCS Probing operation are passed to the cycle functions using the cycle
object. The following variables are available and are referenced as ‘cycle.parameter’.
Parameter Description
approach1 The distance from the contact point at which the probe starts to
approach the part.
approach2 The distance from the contact point at which the probe starts to
approach the second face of a multi-face operation.
depth The position along the probe axis to touch the part.
probeClearance The height the probe rapids to on its way to the start of the probing
and the position it returns to after the probing operation is finished.
probeOvertravel The maximum distance the probe can move beyond the expected
contact point and still record a measurement.
probeSpacing The probe spacing between points on the selected face for Angle style
probing.
retract The height to retract the probe to at the programmed feedrate.
width1 The width of the boss or hole being probed.
width2 The width of the secondary walls (Y-axis) of a rectangular boss or
hole being probed.
Probing Parameters
The following functions support angular probing and may have to be modified to match the
requirements of your control. The code shown is for a Fanuc style control. They should be added prior
to the onCyclePoint function.
/**
Output rotation offset based on angular probing cycle.
*/
function setProbingAngle() {
if ((g68RotationMode == 1) || (g68RotationMode == 2)) { // Rotate coordinate system for Angle
Probing
if (!properties.useG54x4) {
gRotationModal.reset();
gAbsIncModal.reset();
writeBlock(
gRotationModal.format(68), gAbsIncModal.format(90),
(g68RotationMode == 1) ? "X0" : "X[#135]",
(g68RotationMode == 1) ? "Y0" : "Y[#136]",
"Z0", "I0.0", "J0.0", "K1.0", "R[#139]"
);
g68RotationMode = 3;
} else if (angularProbingMode != ANGLE_PROBE_NOT_SUPPORTED) {
writeBlock("#26010=#135");
writeBlock("#26011=#136");
writeBlock("#26012=#137");
writeBlock("#26015=#139");
writeBlock(gFormat.format(54.4), "P1");
g68RotationMode = 0;
} else {
error(localize("Angular probing is not supported for this machine configuration."));
return;
}
}
}
Probing Parameters
var probeWorkOffsetCode;
if (isProbeOperation()) {
if (!useMultiAxisFeatures && !isSameDirection(currentSection.workPlane.forward, new Vector(0,
0, 1)) && (!cycle.probeMode || (cycle.probeMode == 0))) {
error(localize("Updating WCS / work offset using probing is only supported by the CNC in the
WCS frame."));
return;
}
The highlighted code is controller specific and may have to be modified to match your control. It will
be similar to the WCS logic in the onSection function.
The code that outputs the probing calls is usually located after the drilling cycle logic in the main switch
block. Copy all code that contains the case statements for probing operations.
switch (cycleType) {
case “drilling”:
…
case “probing-x”: // copy from this line to before the “default” case
…
default:
Now add the conditional to ignore subsequent cycle locations. Probing cycles only contain a single
location.
Add the following code to the onCycleEnd function to end the probing operation.
function onCycleEnd() {
if (isProbeOperation()) {
writeBlock(probeCode.code.format(probeCode.value), "P" + 9810,
zOutput.format(cycle.clearance)); // protected retract move
writeBlock(probeCode.code.format(probeCode.value), "P" + 9833); // spin the probe off
setProbingAngle(); // define rotation of part
// we can move in rapid from retract optionally
} else {
…
}
Add the following definitions to the fixed settings section at the top of the post processor.
var ANGLE_PROBE_NOT_SUPPORTED = 0;
var ANGLE_PROBE_USE_ROTATION = 1;
var ANGLE_PROBE_USE_CAXIS = 2;
Add to Fixed Settings Section
Add the following variables to the collected state section at the top of the post processor.
var g68RotationMode = 0;
var angularProbingMode;
Add to Collected State Section
The following function and variable definition should be added prior to the onParameter function. The
onParameter function should also have the shown conditional added if it is not there.
function isProbeOperation() {
return hasParameter("operation-strategy") && (getParameter("operation-strategy") ==
"probe");
}
if (!isProbeOperation() &&
(insertToolCall ||
forceSpindleSpeed ||
isFirstSection() ||
(rpmFormat.areDifferent(spindleSpeed, sOutput.getCurrent())) ||
(tool.clockwise != getPreviousSection().getTool().clockwise))) {
forceSpindleSpeed = false;
Don’t Output Spindle Speed with a Probe Tool
if (isProbeOperation()) {
if (g68RotationMode != 0) {
error(localize("You cannot probe while G68 Rotation is in effect."));
return;
}
angularProbingMode = getAngularProbingMode();
writeBlock(probeCode.code.format(probeCode.value), "P" + 9832); // spin the probe on
}
// define subprogram
subprogramDefine(initialPosition, abc, retracted, zIsOutput);
retracted = false;
}
Add at the end of the onSection Function
Coolant should be disabled during probing operations, so make sure that the following conditional is in
the getCoolantCodes function.
function getCoolantCodes(coolant) {
var multipleCoolantBlocks = new Array(); // create a formatted array to be passed into the outputted
line
if (!coolants) {
error(localize("Coolants have not been defined."));
}
if (isProbeOperation()) { // avoid coolant output for probing
coolant = COOLANT_OFF;
Like in WCS Probing, the parameters defined in the Geometry Probing operation are passed to the cycle
functions using the cycle object. These are in addition to the parameters defined for WCS Probing,
which are also available in Geometry Probing. The following variables are available and are referenced
as ‘cycle.parameter’.
Parameter Description
angleAskewAction Set to “stop-message” when Askew Action is enabled.
incrementComponent Increments the output component number when printing the results.
outOfPositionAction Set to “stop-message” when Out of Position Action is enabled.
printResults Measurements will be printed to a file on the controller when enabled.
toleranceAngle Used to determine if angular measurement is within tolerance.
tolerancePosition Used to determine if the positional measurement is within tolerance.
toleranceSize Used to determine if the size of the feature (hole, boss) is within
tolerance.
toolDiameterOffset Defines the tool diameter offset register used to machine the feature.
toolLengthOffset Defines the tool length offset register used to machine the feature.
toolWearErrorCorrection The percentage of the deviation to update the tool wear by.
toolWearUpdateThreshold The minimum deviation that will trigger a tool wear update.
updateToolWear Enabled when tool wear compensation should be activated on the
controller.
wrongSizeAction Set to “stop-message” when Wrong Size Action is enabled.
Geometry Probing Parameters
To add Geometry Probing to your post you will first need to implement WCS Probing. After this there
are only minor changes required to support Geometry Probing. First make sure that the
isProbeOperation looks like the following.
Adding Support for Probing 8-180
CAM Post Processor Guide 8/28/19
function isProbeOperation() {
return hasParameter("operation-strategy") && ((getParameter("operation-strategy") == "probe" ||
getParameter("operation-strategy") == "probe_geometry"));
}
isProbeOperation Function with Geometry Probing Support
In the onCyclePoint function you will need to modify the probing cycles so that they call the
getProbingArguments function, which formats the parameter output for both WCS and Geometry
Probing.
case "probing-x":
forceXYZ();
// move slowly always from clearance not retract
writeBlock(gFormat.format(65), "P" + 9810, zOutput.format(z - cycle.depth), getFeed(F)); //
protected positioning move
writeBlock(
gFormat.format(65), "P" + 9811,
"X" + xyzFormat.format(x + approach(cycle.approach1) * (cycle.probeClearance +
tool.diameter/2)),
"Q" + xyzFormat.format(cycle.probeOvertravel),
getProbingArguments(cycle, probeWorkOffsetCode) // "S" + probeWorkOffsetCode
);
break;
Add Call to getProbingArguments to All Probing Operations
Now you will need to add the getProbingArguments function prior to the onCycleEnd function.
Inspection streamlines the manufacturing process by letting you identify problem areas and decide on
any rework needed earlier in the process. It also helps to reduce the need to move parts between the
machine tool and a measuring device.
Surface Inspection is initiated using the Inspect Surface operation listed in the PROBING menu.
If you wish to use the Inspect Surface operations, you will need a post processor that will allow you to
output and run these inspection paths on your machine. You can either use one of the generic Inspection
post processors available on the Fusion/HSM Post Library, or modify your current milling post which is
already set up for your machine to add in the inspection functionality.
The Inspection post processors will have the inspection or inspect surface suffix appended to the name
of the post processor. These are the only post processors that support Inspect Surface operations. You
will need to use one of these generic posts as a source for adding the inspection code to your post
processor.
The Surface Inspect operations are considered a cycle in the post processor and therefore call the
onCyclePoint function, though they are expanded in the inspectionCycleInspect function. The standard
cycleType variable to define the cycle type is not set for Surface Inspect operations, but rather the
isInspectionOperation function is used to determine if it is a Surface Inspection cycle. This is further
explained in the Adding the Supporting Surface Inspect Logic section. Unlike other cycles that pass a
single point to the onCyclePoint function, the Surface Inspect cycle will contain the following 3 points
per cycle location, with each location generating a separate and subsequent call to onCyclePoint.
The parameters defined in the Inspect Surface operation are passed to the cycle functions using either
the cycle object or through section parameters (getParameter). These parameters are not described here,
since they are handled in the core Surface Inspect functions that are copied from an existing inspection
post processor.
You can also search the online Post Library for Fusion 360 and Autodesk HSM to see if any other post
processors have been added with inspection capabilities.
The main code for Inspect Surface logic is located at the end of the post processor. You will need to
copy from the definition of description located after the onClose or onTerminate function to the end of
the file and add this code to the end of your post processor.
If your post processor does not have the isInspectionOperation function defined, then add it after the
isProbeOperation function.
function isInspectionOperation(section) {
return section.hasParameter("operation-strategy") && (section.getParameter("operation-strategy")
== "inspectSurface");
}
Add isInspectionOperation
At the end of the onSection function, but before any subprograms are defined, add the following code.
Index 187
Autodesk CAM Post Processor Guide 8/28/19
Index
F getNumberOfTools ......................... 4-75
getOrientation ................................. 4-87
Feedrate ........................................ 4-112
getParameter ................................. 4-100
fixed settings .......................... 4-70, 4-71
getPositionU .......................4-115, 4-117
for ................................. 3-53, 3-54, 3-55
getRemainingOrientation ................ 4-87
Force tool change ............................ 4-81
getResultingValue ................. 3-53, 4-67
forceABC ...................................... 4-129
getSection ................... 4-75, 4-76, 4-100
forceAny ....................................... 4-129
getTool ........................................... 4-76
forceFeed ...................................... 4-129
getToolTypeName .......................... 4-76
forceXYZ ...................................... 4-129
getWorkPlaneMachineABC ... 4-87, 4-89
format .................. 4-66, 4-67, 4-68, 4-69
Global Section ................................ 4-59
formatComment .............................. 4-98
global variable .............. 3-36, 4-60, 4-71
function ................ 3-36, 3-51, 3-56, 3-57
H
G
hasGlobalParameter ...................... 4-101
G-code ..................................... 1-1, 4-68
hasParameter ................................ 4-100
Geometry Probing ......................... 8-180
headOffset .................................... 7-168
getABC.......................................... 7-154
helical interpolation ...................... 4-115
getCircularCenter ............... 4-115, 7-151
helical move ................................... 4-60
getCircularChordLength ................ 4-115
high feedrate .......................4-105, 4-108
getCircularNormal ........................ 4-115
highFeedMapping ........................... 4-60
getCircularPlane ............................ 4-115
highFeedrate ................................... 4-60
getCircularRadius.......................... 4-115
home position ............................... 4-130
getCircularStartRadius .................. 4-115
HSM Post Processor Editor............. 3-35
getCircularSweep .......................... 4-115
getCommonCycle.......................... 4-124
I
getCoolantCodes ............................. 4-84
getCurrent ....................................... 4-69 if 3-48, 3-51
getCurrentDirection....................... 7-152 incremental ..................................... 4-68
getCurrentPosition ........................ 4-115 indentation ...................................... 3-35
getDirectionalABC ........................ 7-154 Initial Position ....................... 4-81, 4-92
getError ........................................... 4-67 insertToolCall ............... 4-78, 4-81, 4-93
getEuler2................................ 4-89, 4-90 Inspect Surface ............................. 8-182
getFeedDPM ................................. 7-170 intermediate file ................................ 1-1
getFramePosition ............................ 4-92 Inverse Time ................................. 7-166
getGlobalParameter ....................... 4-101 inverseTimeOutput ....................... 7-167
getGlobalZRange ............................ 4-75 isFirstCyclePoint .......................... 4-124
getHeaderDate ................................ 4-74 isFirstSection .................................. 4-78
getHeaderVersion............................ 4-74 isFullCircle ................................... 4-115
getHelicalDistance ........................ 4-115 isHelical ....................................... 4-115
getHelicalOffset ............................ 4-115 isLastCyclePoint ........................... 4-124
getHelicalPitch ................... 4-115, 4-116 isLastSection .................................. 4-93
getInitialToolAxisABC ................. 7-149 isMultiAxis ..................................... 4-89
getMinimumValue .......................... 4-67 isMultiAxisConfiguration ............... 4-89
getMultiaxisFeed ........................... 7-169 isProbingCycle ............................. 4-124
getNextSection ................................ 4-93 isSignificant.................................... 4-67
getNumberOfSections . 4-75, 4-76, 4-100 isSpiral ......................................... 4-115
Index 188
Autodesk CAM Post Processor Guide 8/28/19
Index
J Multi-Axis Feedrates .................... 7-166
JavaScript........................................ 3-34
N
K NC file extension ............................ 4-60
next tool ......................................... 4-82
kernel settings ................................. 4-60
number .................................. 3-36, 3-58
L Number Objects .............................. 3-37
Index 189
Autodesk CAM Post Processor Guide 8/28/19
Index
P setSingularity................................ 7-162
setSuffix ......................................... 4-70
parametric feedrates ...................... 4-105
setup ............................................. 4-102
pendingRadiusCompensation ........ 4-104
setWordSeparator ................ 4-72, 4-127
permittedCommentChars ................. 4-98
setWorkPlane ........................ 4-90, 7-154
Plasma ............................................ 1-11
setWriteInvocations ............. 2-30, 6-143
post kernel....................................... 3-36
setWriteStack ...................... 2-30, 6-144
Post Library ...................................... 1-2
singularity..................................... 7-161
post processor ................................. 2-29
spindle codes .................................. 4-83
post processor documentation .......... 3-34
spiral interpolation ..............4-115, 4-116
Post Processor Forum ................. 1-2, 1-6
spiral move ..................................... 4-60
Post Processor Ideas ................... 1-2, 1-6
stock transfer .................................. 1-11
Post Properties ................................ 2-30
string ............................ 3-35, 3-38, 3-58
preloadTool ..................................... 4-82
String Object Functions .................. 3-39
previousABC ................................. 7-153
switch .................................... 3-49, 3-55
Probing .......... 1-12, 8-172, 8-180, 8-182
program comment ........................... 4-73
T
program name ........................ 4-61, 4-73
programComment ........................... 4-73 tapping cycles ............................... 4-125
programName ................................. 4-73 TCP ..................................... 4-87, 7-166
programNameIsInteger ........... 4-61, 4-73 Template ...................................... 5-140
properties ........................................ 4-63 toDeg.............................................. 3-38
Property Table ...... 3-41, 4-62, 4-70, 4-71 tolerance ....................4-61, 4-114, 4-115
propertyDefinitions ......................... 4-63 tool axis ................... 4-108, 4-110, 7-161
Tool change .................................... 4-81
R tool length offset ............................. 4-92
toPreciseUnit ................................ 4-128
radians ................................. 3-38, 7-147
toRad .............................................. 3-38
radius compensation4-105, 4-107, 4-110, 4-112
try/catch.......................................... 3-52
range .................................. 7-153, 7-163
typeof ............................................. 3-51
rapid ................................................ 4-60
real value ........................................ 3-53
U
repositionToCycleClearance.......... 4-124
reset ................................................ 4-70 undefined ........................................ 3-36
retract ..................................... 4-79, 4-92 unit ........................................ 4-72, 4-77
return ..................................... 3-56, 3-57 useMultiAxisFeatures ..................... 4-87
returnFromSafeRetractPosition ..... 7-166 User Settings .................................. 2-16
rotary axes................. 4-87, 7-146, 7-149
rotary scale .................................... 7-153 V
rotary table position......................... 4-88 validate ........................................... 3-52
var .................................................. 3-36
S variable ................ 3-36, 3-47, 3-51, 3-57
safeRetractDistance ....................... 7-164 Vector............................................. 3-42
seed post ........................................... 1-6 Vector Attributes ............................ 3-42
sequence number ........................... 4-127 Vector Object Functions ................. 3-43
setCoolant ....................................... 4-84 vectors .......................................... 6-144
setPrefix .......................................... 4-70 Visual Studio Code ......................... 2-13
Index 190
Autodesk CAM Post Processor Guide 8/28/19
Index
W Work Plane4-61, 4-78, 4-87, 4-89, 4-93, 7-149
workOffset ..................................... 4-77
Waterjet .......................................... 1-11
writeBlock .................................... 4-127
WCS ...................................... 4-60, 4-93
writeComment ... 4-74, 4-76, 4-98, 6-145
WCS Probing ................................ 8-172
writeDebug ................................... 6-146
while ............................................... 3-54
writeln ................................4-127, 6-145
Work Coordinate System4-78, 4-84, 8-172
writeRetract ................ 4-79, 4-95, 4-130
Index 191
Autodesk CAM Post Processor Guide 8/28/19