Post Processor Training Guide
Post Processor Training Guide
VI
CAM Post Processor Guide 11/5/22
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.
Introduction to Post Processors 1-1
CAM Post Processor Guide 11/5/22
1.3 Finding a Post Processor
The first step in creating a post processor is to find an existing post that comes close to matching your
requirements and start with that post processor as a seed. You will never create a post processor from
scratch. You will find all the generic posts created by Autodesk on our online Post Library. From here
you can search for the machine you are looking for by the machine type, the manufacturer of the
machine or control, or by post processor name.
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.
Field Description
Use machine configuration Check this box to assign a Machine Configuration to the post
processor. Typically you would assign a Machine Configuration
to the Manufacturing Setup in Fusion 360. If a Machine
Configuration is assigned to the Manufacturing Setup, then this
You select the folder for the post processor and the post processor itself by pressing the button next
to the Post field. You can right click on the Linked menu in the Post Library dialog to add a new folder
to select post processors from. The new folder will be displayed in the Linked menu.
Field Description
Configuration Folder Specifies the folder location of the post processor you want to
run. You can press the button to open a folder browser
window to select the post processor. This field is only displayed
in the legacy dialog, but you can select the folder in the NC
Programs dialog by pressing the button next to the Post field.
Setup Used to select preinstalled post processor libraries or to select a
cascading post. A cascading post is usually a 3rd party post
processor or verification program that is run after the HSM post
processor. This field is only displayed in the legacy dialog.
Post Configuration Defines the post processor you want to run. The available posts
are listed in a dropdown menu. There are filters that will limit
the post processors listed, including a Search Text field,
Capabilities (milling, turning, etc.), and Vendors.
Output folder Specifies the folder for the output NC file. Pressing the
button opens a folder browser window to select the folder for the
NC file. The Open folder button opens a file browser in this
folder.
NC extension Contains the default file extension for the output NC file as
defined in the post processor. You can override the file
extension in this field.
1.5.2 NC Programs
NC Programs are supported in Fusion 360 and allow you to group operations together and assign a post
processor that is used for these operations. You create an NC Program by pressing the NC Program
menu or right clicking on a (group of) operation(s) and selecting Create NC Program from the list.
Pressing the Post Process button will bring up the NC Program dialog where you can create an NC
Program from the selected operations when the Post or OK button are pressed. It is important to note
that pressing the OK button will NOT post process the NC Program but will only save it.
The NC Program dialog contains two tabs, Settings and Operations. This is the same dialog that is
displayed when Post Processing from the menus.
You will also notice that when you post process against an NC Program that the NC Program dialog is
displayed. If you want to change any settings for post processing when using an NC Program, you must
edit the NC Program to make changes.
1. Allows a single generic post processor to be used for multiple machines with different
kinematics.
2. The post processor is assigned directly to the Machine Configuration.
3. The NC output folder is defined in the Machine Configuration.
4. Defines the unique multi-axis features for the machine.
5. Required for Machine Simulation.
6. Required for Operation Properties.
You can determine if a post processor supports a Machine Configuration by checking for the
activateMachine function inside of the post processor. If this function is not present, then the post
processor will most likely not accept or fully support a Machine Configuration. There are a number of
post processors that support Machine Configurations, such as the Fanuc, Haas Next Generation,
Heidenhain, Hurco, Siemens, and Tormach posts.
You assign a Machine Configuration to a CAM Setup when creating or editing the Setup and pressing
the Select… button. This will bring up the Machine Library dialog that allows you to select a machine
from the available configurations.
Once you find the Machine Configuration you want to use you can copy it into your Local folder or a
Linked Folder. You can do this by dragging the configuration onto the desired My machines folder or
Introduction to Post Processors 1-14
CAM Post Processor Guide 11/5/22
by copying and pasting it into the desired folder. You can only edit Machine Configurations stored in
one of the My machines folders.
The latest versions of Machine Configurations are available on our online Post Library. From here you
can search for the machine by the machine type, the manufacturer of the machine, or by machine name.
Once a Machine Configuration is selected, you can edit it by pressing the Edit... button in the Setup
dialog.
The areas of the Machine Configuration that are important for post processing are the Description,
Kinematics, Post Processing, and Multi-Axis settings. The information in the other areas can be
accessed by the post processor, but not all are used by the library post processors as of this writing.
Area Description
Description Describes the post processor, machine, manufacturer, and CNC control
of the configuration.
Kinematics Defines the machine kinematics of the moving axes. You can define up
to 3 linear axes, 2 rotary axes, and a single spindle. You can add/delete
an axis by right clicking on a component and selecting the appropriate
action. When you add an axis, it will be added after the component that
you clicked on.
The definition of the selected axis is displayed in the right pane of the
dialog, including the home position, rotation vector (orientation), range,
preference, and TCP setting. These fields apply directly to the
parameters of the createAxis function as described in the Multi-Axis
Post Processors chapter.
Post Processing This is where you will select the location of the post processor, the post
processor itself, and the output folder for the NC file. These will
become the defaults when post processing and for NC Programs.
Multi-Axis Defines the multi-axis capabilities of the control, along with how
retract/reconfigure operations are handled, and singularity settings.
These capabilities are described in the Multi-Axis Post Processors
chapter.
Machine Configuration Post Processor Settings
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.
Introduction to Post Processors 1-16
CAM Post Processor Guide 11/5/22
Finding HSM CAM Partners
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
• 2D
Introduction to Post Processors 1-19
CAM Post Processor Guide 11/5/22
• 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 link will take you to the Visual Studio Code installation page. Select the correct version for your
operating system.
This will download an installation program that you can run to do the actual install. Left click on the
installation program to execute it.
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.
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.
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.
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.
The Search flyout searches for a file in the opened files and in the files located in an open folder (refer
to the Explorer flyout to see how to open a folder). The Search dialog will be displayed when you press
the Search button.
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.
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.
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.
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 username that you logged in as. (id) is a unique and long name that changes
depending on the version of Fusion 360 that you have installed. You will usually select the folder
with the latest date.
Inventor C:\Program Files\Autodesk\Inventor CAM 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
Autodesk Post Processor Editor 2-44
CAM Post Processor Guide 11/5/22
need a custom CNC intermediate file you can delete it by right clicking on the CNC file and select
Delete CNC File.
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 CAM 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.
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
a = Math.floor(4.59); // a = 4
a = Math.PI; // a = 3.14159
a = Math.cos(toRad(45)); // a = .7071
a = toDeg(Math.acos(.866)); // a = 60
Sample Math Object Output
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.
There are also standalone numeric functions that are not part of the Number of Math objects. These are
listed in the following table.
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
JavaScript Overview 3-49
CAM Post Processor Guide 11/5/22
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
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.
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. You can reference the elements within an object using either the
name of the element (object.element) or by using a text string or variable (object["element"]) as the
name of the element. The following examples all reference the moveTime element of the status object.
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.
Attribute Description
forward Contains the forward vector
n1 Contains the length of the row vectors
of this matrix
n2 Contains the square root of this matrix
vector lengths
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.
The way that deferred variables work is by using text substitution in the output NC file. The initial text
string output to the NC file will include the name of the deferred variable enclosed by the defined
separator for defined variables, for example ##id##. After all processing is finished, the post engine will
scan the output NC file for the deferred variable text and replace it with the value stored in the deferred
variable. It is important to know this procedure, since deferred variables cannot be accessed before they
are defined in the post processor, the same as any other variable, except for when they are output to the
NC file.
Deferred variables are stored in the DeferredVariables object, which has the following properties. The
deferred variable properties are referenced as DeferredVariables.property.
The following sample code will calculate the cutting time for each tool for linear, circular, and canned
cycle moves. It will output these times in the tool list located in the header of the NC file.
JavaScript Overview 3-59
CAM Post Processor Guide 11/5/22
// collected state
var toolTime = new Array(); // define an array to store the tool cutting times.
Define the Tool Times Array
function onOpen() {
DeferredVariables.separator = "^&^"; // define a unique marker for deferred variables
…
var tools = getToolTable();
if (tools.getNumberOfTools() > 0) {
for (var i = 0; i < tools.getNumberOfTools(); ++i) {
var tool = tools.getTool(i);
var comment = "T" + toolFormat.format(tool.number) + " " +
"D=" + xyzFormat.format(tool.diameter) + " " +
localize("CR") + "=" + xyzFormat.format(tool.cornerRadius);
if ((tool.taperAngle > 0) && (tool.taperAngle < Math.PI)) {
comment += " " + localize("TAPER") + "=" + taperFormat.format(tool.taperAngle) +
localize("deg");
}
if (zRanges[tool.number]) {
comment += " - " + localize("ZMIN") + "=" +
xyzFormat.format(zRanges[tool.number].getMinimum());
}
comment += " - " + localize("TIME") + "=" +
DeferredVariables.get("tool" + tool.number, xyzFormat); // Output cutting time for tool
comment += " - " + getToolTypeName(tool.type);
writeComment(comment);
}
}
Output Tool Cutting Times in onOpen
function onSection() {
…
writeToolBlock("T" + toolFormat.format(tool.number), mFormat.format(6));
if (tool.comment) {
writeComment(tool.comment);
}
// initialize the cutting time if not previously defined
toolTime[tool.number] = toolTime[tool.number] ? toolTime[tool.number] : 0;
function moveIsCutting() {
return movement == MOVEMENT_CUTTING ||
movement == MOVEMENT_FINISH_CUTTING ||
movement == MOVEMENT_REDUCED;
JavaScript Overview 3-60
CAM Post Processor Guide 11/5/22
}
Determine if this Move is a Cutting Move
function onCyclePoint(x, y, z) {
…
// calculate the canned cycle cutting time
if (!cycleExpanded) {
toolTime[tool.number] += Math.abs(cycle.bottom - cycle.stock) / cycle.feedrate;
}
}
Calculate the Canned Cycle Cutting Time in onCyclePoint
function onSectionEnd() {
DeferredVariables.set("tool" + tool.number, toolTime[tool.number]);
Assign the Tool Cutting Time to the Deferred Variable
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.
JavaScript Overview 3-61
CAM Post Processor Guide 11/5/22
P Operator Operands Description
13 () Expression Overrides the assigned precedence of operators
12 ++ Integer Unary increment
-- Integer Unary decrement
~ Integer Unary bitwise complement
! Boolean Unary logical complement (not)
11 * Number Multiplication
/ Number Division
% Number Remainder
10 + Number, String Addition
- Number Subtraction
9 << Integer Bitwise shift left
>> Integer Bitwise shift right
8 < Number, String Less than
<= Number, String Less than or equal to
> Number, String Greater than
>= Number, String Greater than or equal to
7 == Any Equal to
!= Any Not equal to
=== Any Equal to and same variable type
!== Any Not equal to and same variable type
6 & Integer Bitwise AND
5 ^ Integer Bitwise XOR
4 | Integer Bitwise OR
3 && Boolean Logical AND
2 || Boolean Logical OR
1 = Any Assignment
+= Number, String Assignment with addition
-= Number Assignment with subtraction
*= Number Assignment with multiplication
/= Number Assignment with division
Expression Operators
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
bracket (}) at the start of the line following the body of code for each section as shown in the following
examples.
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 (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
The syntax of switch bodies will contain a single switch statement with a variable whose value
determines the code to be executed. case statements will be included in the switch body, with each one
containing the value that causes its body of code to be executed. The end of each case body of code
must have a break statement so that the next case body of code is not executed. A default statement can
be defined that contains code that will be executed if the switch variable does not match any of the case
values.
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
JavaScript Overview 3-64
CAM Post Processor Guide 11/5/22
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
Since conditional is a function, any function calls contained in the arguments will be processed even if
the expression equates to false. This means that if a modal is used to format a value, the value will be
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
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
while (expression) {
// body of loop
}
while 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.
The argument list is optional and contains identifiers that are passed into the function by the calling
routine. The arguments passed to the function are considered read-only as far as the calling routine is
concerned, meaning that any changes to these variables will be kept local to the called function and not
propagated to the calling routine. You use the return statement to return value(s) to the calling routine.
function writeComment(text) {
writeln(formatComment(text)); // text is accepted as an argument and passed to formatComment
JavaScript Overview 3-71
CAM Post Processor Guide 11/5/22
}
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(getProperty("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
JavaScript Overview 3-72
CAM Post Processor Guide 11/5/22
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.
While the global section is typically located at the top of the post processor, any variables defined
outside of a function are in the global section and accessible by all functions, even the functions defined
before the variable. You may notice global variables being defined in the middle of the post processor
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;
Entry Functions 4-75
CAM Post Processor Guide 11/5/22
Setting Description
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
description = "RS-274D";
vendor = "Autodesk";
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);
The properties can be displayed in multiple areas of HSM; when you use the Post Process dialog to run
the post processor, in an NC Program, under the Post Processing tab in the Machine Configuration, and
in the Post Process tab of an operation. When you Post Process from HSM or edit an NC Program you
may 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, the titles displayed in
the Property Table, the accepted input types, the default values assigned to each property, and settings
controlling the display attributes of the property in the property table.
// user-defined properties
properties = {
writeMachine: {
title: "Write machine",
description: "Output the machine settings in the header of the code.",
group: "general",
type: "boolean",
value: true,
scope: "post"
},
useSmoothing: {
title: "SGI / High Precision Mode",
description: "High-Speed High-Precision Parameter.",
type: "enum",
group: "preferences",
values:[
{title:"Off", id:"-1"},
{title:"Automatic", id:"9999"},
{title:"Standard", id:"0"},
{title:"High Speed", id:"1"},
Entry Functions 4-79
CAM Post Processor Guide 11/5/22
{title:"High Accuracy", id:"2"},
{title:"Special", id:"3"}
],
value: "-1",
scope: ["post", "operation"]
}, …
}
Property Table Definition
The following table describes the supported members in the properties object. It is important that the
format of the properties object follows the above example, where the name of the variable is first,
followed by a colon (:), and the members enclosed in braces ({}). The values property is an array and
its members must be enclosed in brackets ([]).
Property Description
title Description of the property displayed in the User Interface within the
Property column.
description A description of the property displayed as a tool tip when the mouse is
positioned over this property.
group The group name that this property belongs to. All properties with the same
group name will be displayed together in the User Interface. The groups are
defined by the groupDefinitions object discussed further in this chapter.
type Defines the input type. The input types are described in the following table.
value The default value for this property.
range The minimum and maximum allowable values for a numeric property
specified as an array ([-1000, 1000]).
values Contains a list (array) of choices for the enum, integer, or boolean input
types. It is not valid with any other input type. For boolean values, it should
be an array of 2 strings, with the first entry representing true and the second
representing false.
presentation Defines how a boolean will be displayed in the property table. Valid settings
are defined as a text string and can be “yesno” (Yes/No), “truefalse”
(True/False), “onoff” (On/Off), and “10” (1/0).
scope Tells the post which dialogs will display this property. Supported settings are
post, machine, and operation. The setting must be specified as a text string.
scope can be a single value or an array of the supported dialogs. Examples:
scope: “post”, scope: [“post”, “machine”]. There are caveats when
enabling a property in more than one dialog type as described in the
Property Scopes section of this chapter.
enabled Specifies the operation type where this property will be displayed in the HSM
operation dialog. This property only applies to operation properties and has
no effect on post and machine properties. The setting must be specified as a
text string or an array of text strings. Valid settings are “milling”, “turning”,
“drilling”, “probing”, “inspection”, and “additive”.
1. Operation property
2. Post property
3. Machine property
Therefore, if a property is defined as a post and an operation property, then the setting made in the Post
Process, and NC Program dialogs will be ignored by the post processor, only the setting made in each
separate operation will be used by the post processor. The only place you would be able to query the
Post Process property setting is in onOpen when using the getProperty function. For these reasons it is
highly recommended that operation properties are not defined in the post or machine scopes.
When specifying a property as a machine and post property, the setting made to the property in the
Machine Configuration dialog will become the default setting for the post property displayed in the
gotChipConveyor: {
title : "Use chip transport",
description: "Enable to turn on the chip transport for this operation.”,
group : "configuration",
type : "boolean",
value : false,
scope : "operation",
enabled : "milling"
},
Defining an Operation Property
To display operation properties in Fusion 360 or Inventor CAM it is required that a Machine
Configuration be assigned to the Manufacturing Setup. The reason is that the Machine Configuration
has a post processor assigned to it and the operation properties are obtained from this known post
processor.
The enabled parameter in the property definition specifies the operation type where this property will be
displayed in the HSM Operation dialog. This property only applies to operation properties and has no
effect on post and machine properties. The setting must be specified as a text string or an array of text
strings.
The post processor has a number of built-in property groups as defined in the following table. You can
reference these groups in the property definition without creating the group in the groupDefinition
object.
If a property does not fit into a predefined group, you can add to the built-in groups by defining these
groups within the groupDefinitions object. In the following example, the subSpindle group will be
displayed after the built-in configuration group and the looping group will be displayed after the built-in
preferences group. This is determined by the value assigned to the order property.
The following table describes the supported properties in the groupDefinitions object. It is important
that the format of the groupDefnitions object follows the above example, where the name of the group is
first, followed by a colon (:), and the properties enclosed in braces ({}).
Each group referenced in the properties definition and not one of the built-in property groups should be
defined in groupDefinitions.
Property Description
title Title of the group displayed in the Post properties table. The title is not
displayed in the legacy Post Process dialog.
description A description of the group displayed as a tool tip when the mouse is
positioned over this group name.
order A number defining the displayed placement of the group in the Post
properties table. For example, a value of less than 10 will be displayed first,
25 will display between the preferences and homePositions groups, and a
value of 70 will be displayed after the probing group.
collapsed Defines whether the group will be collapsed or expanded by default in the
Post properties table. true collapses the group and false expands the group.
Group Definition Settings
Arguments Description
property The property you want to retrieve the value of. It can be specified as a text
string (“useSmoothing”) or as a direct reference to the property
(properties.useSmoothing). It is recommended to use the text string syntax.
The getProperty function is used to obtain the value of a post processor property.
showSequenceNumbers = getProperty(“showSequenceNumbers”);
if (getProperty(properties.showSequenceNumbers) {
var smooth = section.getProperty(“useSmoothing”, false);
Sample getProperty Calls
The setProperty function is used to set the value of a post processor property.
setProperty("showSequenceNumbers", true);
setProperty(properties.showSequenceNumbers, true);
Sample setProperty Calls
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
base The base increment of the output value. For example, a value of .002 will
only output values on a .002 increment (.002, .004, .010, etc.). The default
is 0.
decimals Defines the number digits to the right of the decimal point to output. The
default is 6.
forceSign When set to true will force the output of a plus (+) sign on positive
numbers. The default is false.
inherit Inherits all properties from an existing FormatNumber.
minDigitsLeft The minimum number of digits to the left of the decimal point to output.
The default is 1.
minDigitsRight The maximum number of digits to the right of the decimal point to output.
The default is 0.
maximum The unsigned maximum value that can be output. Formatted positive values
will not be greater than this value and formatted negative values will not be
less than the negative value. For example, defining a maximum value of
The createFormat function creates a FormatNumber object. Once a FormatNumber 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 FormatNumber 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.
getBase() Returns the base increment of the format.
getDecimalSymbol() Returns the character used as the decimal point symbol.
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
Entry Functions 4-87
CAM Post Processor Guide 11/5/22
Function Description
4.5005 is "4.500", then the value returned from getError will be -
0.0005.
getForceSign() Returns true if the + sign is output in the formatted number.
getMaximum() Returns the maximum value that can be output.
getMinDigitsLeft() Returns the minimum number of digits to output to the left of the
decimal point.
getMinDigitsRight() Returns the minimum number of digits to output to the right of the
decimal point.
getMinimum() Returns the minimum value that can be output.
getMinimumValue() Returns the minimum value that can be formatted using this format,
for example, 1 for decimals:0, .1 for decimals:1, etc.
getNumberOfDecimals() Returns the maximum number of digits to output to the right of the
decimal point.
getOffset() Returns the number to add to the formatted number.
getPrefix() Returns the prefix of the formatted number.
getResultingValue(value) Returns the real value that the formatted output text string
represents.
getScale() Returns the scale to apply to the formatted number.
getSuffix() Returns the suffix of the formatted number.
getType() Returns the formatting type.
isSignificant(value) Returns true if the value will be non-zero when formatted.
setBase(base) Defines the base increment of the format.
setDecimalSymbol('symbol') Defines the character used as the decimal point symbol.
setForceSign(forceSign) Determines if the + sign is output in the formatted number.
setMaximum(max) Defines the maximum value that can be output.
setMinDigitsLeft(min) Defines the minimum number of digits to output to the left of the
decimal point.
setMinDigitsRight(min) Defines the minimum number of digits to output to the right of the
decimal point.
setMinimum(min) Defines the minimum value that can be output.
setNumberOfDecimals(number) Defines the maximum number of digits to output to the right of the
decimal point.
setOffset(offset) Defines the number to add to the formatted number.
setPrefix(prefix) Defines the prefix of the formatted number.
setScale(scale) Defines the scale to apply to the formatted number.
setSuffix() Defines the suffix of the formatted number.
setType() Sets the formatting type, FORMAT_INTEGER, FORMAT_REAL,
FORMAT_LZS, or FORMAT_TZS.
FormatNumber Functions
The following table shows how a value of 0 could be formatted depending on the format type and
settings for the minimum digits to the left and right of the decimal point.
Specifier Value
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.
inherit Inherits all properties from an existing FormatNumber.
The createOutputVariable function creates OutputVariable objects that are used to control the output of
a code. The codes can be output only when they are changed, as an absolute value, as an incremental
value, or as a directional value where the sign of the number determines a movement direction.
You can use the FormatNumber object, created from the createFormat function, 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 FormatNumber object is provided
as the second parameter. Supported specifiers are listed in the following table.
Specifier Value
control Determines when a formatted variable will be output. CONTROL_CHANGED
will format the number when it has changed from the previously formatted
value, CONTROL_FORCE will format the number each time, and
CONTROL_NONZERO will format the number only when it is not equal to
zero. If the number is not formatted, then a blank string will be returned.
current Defines the initial value to store in the output variable.
cyclicLimit Specifies the absolute range limit for the formatted value, for example it could
be 360 for a rotary axis.
cyclicSign Specifies the sign for a cyclic value and can be -1 (formatted numbers will
always be negative), 0 (formatted numbers can be both positive and negative),
or 1 (formatted numbers will always be positive).
onchange Defines the method to be invoked when the formatting of the value results in
output.
prefix Text string that prepends to the prefix defined in the format.
suffix Text string that appends to the suffix defined in the format.
tolerance Defines a tolerance used to determine when the number should be formatted. A
value must differ from the previous value by greater than this tolerance to be
output.
type Defines the output type of the variable. Can be one of the following.
• TYPE_ABSOLUTE – The number will maintain its value when
formatted.
• TYPE_INCREMENTAL – The formatted number will be an
incremental value from the previously formatted value.
• TYPE_DIRECTIONAL – The formatted number will be negative if the
value is less than the previously formatted value or will be positive if
the value is greater than the previously formatted value. This type is
usually used in conjunction with the cyclicLimit and cyclicSign
specifiers for rotary axes that are output on a rotary scale.
The onchange property 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.
Function Description
disable() Disables this variable from being output. Will cause the return value
from the format function to always be a blank string ("").
enable() Enables this variable for output. This is the default condition when the
variable is created.
format(value) Returns the formatted text string representation of the number. A blank
string will be returned when the value is the same as the stored value
when control is set to CONTROL_CHANGED, or generates a value of
0 when control is set to CONTROL_NONZERO.
getControl() Returns the control setting of the output variable.
getCurrent() Returns the value currently stored in this variable.
getCyclicLimit() Returns the absolute cyclic limit (rollover) of the output variable.
getCyclicSign() Returns the cyclic sign setting of the output variable.
getFormat() Returns the FormatNumber associated with this output variable.
getPrefix() Returns the prefix of the output variable.
getResultingValue(value) Returns the real value that the formatted output text string represents.
getSuffix() Returns the suffix of the output variable.
getTolerance() Returns the output tolerance of the output variable.
getType() Returns the output type of the variable.
get---() All get functions supported by the FormatNumber object can be called
from an OutputVariable object. These calls return the values stored in
the FormatNumber, for example getDecimals(), getScale(), etc. The
only get functions not supported are those with the same names as
OutputVariable functions, such as getPrefix().
isEnabled() Returns true if this variable is enabled for output.
setControl(control) Sets the control type, CONTROL_CHANGED, CONTROL_FORCE, or
CONTROL_NONZERO.
setCurrent(value) Sets the current value.
setCyclicLimit(value) Defines the rollover value (cyclic limit).
setCyclicSign(value) Defines the cyclic sign, -1 (formatted numbers will always be negative),
0 (formatted numbers can be both positive and negative), or 1
(formatted numbers will always be positive).
setFormat(format) Changes the FormatNumber object associated with this output variable.
setPrefix(prefix-text) Overrides the prefix of the variable.
setSuffix(suffix-text) Overrides the suffix of the variable.
setTolerance(value) Defines the output tolerance of the variable.
setType(type) Sets the formatting type, TYPE_ABSOLUTE,
TYPE_INCREMENTAL, or CONTROL_DIRECTIONAL.
set---() All set functions supported by the FormatNumber object can be called
from an OutputVariable object. These calls override the properties
Entry Functions 4-92
CAM Post Processor Guide 11/5/22
Function Description
stored in the FormatNumber associated with this OutputVariable, for
example setDecimals(3), setScale(2), etc. The only set functions not
supported are those with the same names as OutputVariable functions,
such as setPrefix().
The following table lists the specifiers supported by the deprecated output variable definitions. Some of
the specifiers are common to all three objects and some to a particular object.
The following table describes the functions assigned to the deprecated output variable objects. The
functions are properties of the Variable object(s) as listed.
Specifier Value
force When set to true forces the formatting of the value even if it does not change
from the previous value. The default is false.
strict When set to true requires that any code output using this modal must be present
in one of the defined groups. An error will be output if any code is output that
is not in one of the groups. Specifying false allows for codes not belonging to a
group to be output. Codes that do not belong to a group will always be output,
meaning they belong to a non-modal group.
Output Variable Properties
The code groups are defined as arrays of codes within an array. Each individual group is treated similar
to as if it was defined as a separate Modal variable.
Once a modal group is created, it can be used to create a formatted text string for output. The following
table describes the functions assigned to the modal group object. Group numbers are based on 0, so the
first group is referenced as 0, the second as 1, etc. The functions are properties of the defined
ModalGroup object and are prefixed by the name of the group, for example mClampModal.disable().
Function Description
addCode(group, code) Adds the specified code to the given group.
createGroup Adds a group to the end of the groups.
The following sample code shows how a single Modal Group can be used to define the clamping codes
for the rotary axes rather than creating two separate Modal variables to store the 4th and 5th axes
clamping codes.
case COMMAND_LOCK_MULTI_AXIS:
if (machineConfiguration.isMultiAxisConfiguration() &&
(machineConfiguration.getNumberOfAxes() >= 4)) {
writeBlock(mClampModal.format(10)); // unlock 4th-axis motion
if (machineConfiguration.getNumberOfAxes() == 5) {
writeBlock(mClampModal.format(12)); // unlock 5th-axis motion
}
}
return;
case COMMAND_UNLOCK_MULTI_AXIS:
if (machineConfiguration.isMultiAxisConfiguration() &&
(machineConfiguration.getNumberOfAxes() >= 4)) {
writeBlock(mClampModal.format(11)); // unlock 4th-axis motion
if (machineConfiguration.getNumberOfAxes() == 5) {
writeBlock(mClampModal.format(13)); // unlock 5th-axis motion
}
}
Sample Modal Group Code
// fixed settings
var firstFeedParameter = 500;
var useMultiAxisFeatures = false;
var forceMultiAxisIndexing = false; // force multi-axis indexing for 3D programs
var maximumLineLength = 80; // the maximum number of characters allowed in a line
var minimumCyclePoints = 5; // min number of points in cycle operation to consider for subprogram
var WARNING_WORK_OFFSET = 0;
var ANGLE_PROBE_NOT_SUPPORTED = 0;
Entry Functions 4-98
CAM Post Processor Guide 11/5/22
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.
Some of the variables that may be defined here are the maximum circular sweep, starting sequence
number, formats, properties that can be changed using a Manual NC command, etc.
if (getProperty("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.
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, the list of tools used in the program, and setup notes.
In the above code sample, the machine information is retrieved from the Machine Configuration, 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
The following code is used to output the notes from the first setup. The property showNotes is defined
in the properties, see the Operation Comments and Notes section to see how to define this property.
If your post needs to output the notes from multiple setups, then additional code outside of onOpen
needs to be added.
First, define the firstNote property in the collected state section of the post.
// collected state
…
var firstNote; // handles output of notes from multiple setups
Define the firstNote Global Variable
In the onParameter function define the logic to process the job-notes parameter.
And finally, implement the writeText function. It can be placed in front of the onParameter function.
This function can also be used to output the text from the Pass through Manual NC command.
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))
)
);
return;
}
}
}
Entry Functions 4-105
CAM Post Processor Guide 11/5/22
}
}
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.
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.
The output of the operation notes is normally handled by the post processor property showNotes.
// user-defined properties
properties = {
…
showNotes: {
title : "Show notes",
description: "Writes setup and operation notes as comments in the output code.",
type : "boolean",
value : false,
scope : "post"
},
…
}
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) {
…
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: {
title : "Preload tool",
description: "Preloads the next tool at a tool change (if any).",
type : "boolean",
value : true,
scope : "post"
}
}
Define the preloadTool Property
The first tool will be loaded on the last operation of the program.
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},
{id: COOLANT_THROUGH_TOOL, on: 88, off: 89},
{id: COOLANT_AIR},
{id: COOLANT_AIR_THROUGH_TOOL},
{id: COOLANT_SUCTION},
{id: COOLANT_FLOOD_MIST},
{id: COOLANT_FLOOD_THROUGH_TOOL, on: [8, 88], off: [9, 89]},
{id: COOLANT_OFF, off: 9}
];
Coolant Definition Table
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.
If a CAM Machine Configuration is defined the WCS can be selected using the number as expected by
the machine control. When a CAM Machine Configuration is not defined, then a simple value will be
displayed.
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.
wcsDefinitions is defined just after the coolants table at the top of the post processor.
var wcsDefinitions = {
useZeroOffset: false, // set to 'true' to allow for workoffset 0, 'false' treats 0 as 1
wcs :[
{name:"Standard", format:"G", range:[54, 59]}, // standard WCS, output as G54-G59
{name:"Extended", format:"G59.#", range:[1, 64]} // extended WCS, output as G59.7, etc.
// {name:"Extended", format:"G54 P#", range:[1, 64]} // extended WCS, output as G54 P7, etc.
]
};
Parameters Description
useZeroOffset Set to true to enable a work offset value of 0. Setting it to false will treat a
work offset of 0 as 1.
wcs Contains the definitions of the supported WCS formats.
name The name of the WCS output format. This will usually be Standard or
Extended. The name is displayed in the Format field of the Machine WCS
frame.
format The output format of the WCS. This is a text string that has an optional #
character that defines where the offset value will be placed. If # is not
specified, then the offset value will be placed at the end of the string. You can
also use multiple consecutive # characters to define the number of digits to
output with the WCS value, for example P## will output P01. Specifying $#
will place a # character in the output.
range Defines the valid range of work offsets for the defined format.
The post processor kernel will format the output WCS code based on the format defined in
wcsDefinitions. Both a string and number is available to the post processor in the section object.
Variable Description
section.wcs The output code of the work offset (G54, G51 P1, etc.).
section.workOffset The work offset number.
// wcs
if (insertToolCall) { // force work offset when changing tool
currentWorkOffset = undefined;
}
if (currentSection.workOffset != currentWorkOffset) {
writeBlock(currentSection.wcs);
currentWorkOffset = currentSection.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
determines the Work Plane method to use. This variable, along with other variables that control 3+2
operations, is defined with the machine configuration settings and functions towards the top of the post
processor.
Check the Programming Manual for your machine to determine if Euler angles are supported and the
order of rotations. The _R (rotated) variants of the Euler angles will use the modified orientation after
each rotation for each axis. The _S (static) variants will use the original coordinate system for all
rotations and is sometimes referred to as pitch, row, yaw.
The useMultiAxisFeatures and useABCPrepositioning variables can be controlled from the post
processor properties, simply adding a property with the same name. The activateMachine function
automatically checks for this property and will use it if it is defined.
properties = {
…
useMultiAxisFeatures: {
title: "Use G68.2",
description: "Enable to output G68.2 blocks for 3+2 operations, disable to output rotary angles.",
type: "boolean,
value: true,
scope:["machine", "post"],
group:"multiaxis"},
useABCPrepositioning: {
title: "Preposition rotaries",
description: "Enable to preposition rotary axes prior to G68.2 blocks.",
scope: ["machine", "post"],
group: "multiaxis",
type: "boolean",
value: true
},
…
Defining useMultiAxisFeatures and useABCPrepositioning as Properties
The code handling 3+2 operations is usually found in the defineWorkPlane function but can also be
defined as inline code within the onSection function. The preferred method is using the
Entry Functions 4-117
CAM Post Processor Guide 11/5/22
defineWorkPlane function, which controls the calculation and output of the rotary angles for multi-axis
and 3+2 operations. defineWorkPlane will be called from onSection.
The defineWorkPlane function is defined as follows and returns the initial rotary positions for multi-axis
and 3+2 operations.
defineWorkPlane(_section, _setWorkPlane)
Arguments Description
_section The operation (section) used to calculate the rotary angles.
_setWorkPlane true = output the rotary angle positions and adjust the output coordinates for
the 3+2 rotation. false = don’t output the rotary angle positions. The rotary
angles will still be calculated and the output coordinates will be adjusted for
the 3+2 rotation.
The defineWorkPlane Function
The function getWorkPlaneMachineABC is used to calculate the rotary axes positions that satisfy the
Work Plane. It will return the calculated angles of either the rotary axis or tilted plane positions.
getWorkPlaneMachineABC(workPlane, rotate)
Arguments Description
workPlane The work plane matrix used to calculate the rotary-angles. This variable is
typically section.workPlane.
rotate Enable to adjust the output coordinates for the work plane orientation. Disable
to just calculate the rotary angles and not adjust the XYZ coordinates for the
axis rotations.
Entry Functions 4-118
CAM Post Processor Guide 11/5/22
The getWorkPlaneMachineABC Function
This function is standard from post to post, but there are a couple of areas that may need to be modified.
The first step is to calculate the rotary angles based on the work plane orientation by calling the
getABCByPreference function.
Arguments Description
machineConfiguration The Machine Configuration. This parameter is only specified with the
section.getABCByPreference version.
workPlane The work plane matrix used to calculate the rotary-angles. This variable is
typically section.workPlane.
current The current rotary angles. This is usually the ABC position returned by
getCurrentDirection. In the first operation this value is set to a tool axis, so
the current rotary angles are defined as 0,0,0 in this case.
controllingAxis The axis used to determine the preferred solution in conjunction with the type
argument. It can be A, B, or C for a single axis, or ABC to consider all
defined rotary axes.
type The preference type as described in the Preference Type table.
options Options used to control the solution as described in the Controlling Options
table.
The getABCByPreference Function
There are two variations of the getABCByPreference function, one in the machineConfiguration object
and the other in the section object. The only difference between the two is that the section function
supports the ENABLE_LIMITS option, while the machineConfiguration function does not. The
ENABLE_LIMITS works with rotary tables that are perpendicular to the spindle vector and will adjust
Entry Functions 4-120
CAM Post Processor Guide 11/5/22
the rotary table position to bring the linear XYZ coordinates within their defined limits if possible. If it
is not possible to bring the machine within its limits, then the calculated rotary axis positions will be the
same as if ENABLE_LIMITS was not specified.
You must define the limits of the linear axes in the machine configuration when using
ENABLE_LIMITS. The limits can be defined as part of an external Machine Configuration or
hardcoded within the post processor if a Machine Configuration is not used.
Since the getABCByPreference function will return a rotary axis position even if the machine is not
within the defined linear limits, you must call the doesToolPathFitWithinLimits function to determine if
the calculated rotary axis position will keep the machine within limits for this operation.
Arguments Description
machineConfiguration The Machine Configuration.
abc The rotary angle positions used to determine if the linear XYZ axes are
within their defined limits.
The doesToolpathFitWithinLimits Function
The 3+2 operation coordinates may need to be adjusted for the rotary axes. This is done by calling
section.optimize3DPositionsByMachine with the rotary axes and optimization type. Most posts will use
the Tool Control Point (TCP) setting for each axis by using the OPTIMIZE_AXIS setting.
if (!currentSection.isOptimizedForMachine()) {
machineConfiguration.setToolLength(addToolLength ? getBodyLength(tool)); // define the tool length for
head adjustments
currentSection.optimize3DPositionsByMachine(machineConfiguration, abc, OPTIMIZE_AXIS);
}
Adjust the Coordinates for the Rotary Axes
It is important to know that the XYZ coordinates provided to the post processor for 3+2 are in the work
plane coordinate system, meaning they are in the XY-plane defined by the work plane. This is fine for
machines that support multi-axis features such as G68.2, CYCLE800, etc., but could be incorrect for
machines that do not support these features.
Arguments Description
machineConfiguration The active machine configuration.
abc The current rotary axis positions passed as a Vector.
optimizeType Optimization type as described in the following table.
Optimize3DPositionsByMachine Arguments
optimizeType Description
OPTIMIZE_NONE The coordinates will be the tool tip position (TCP).
OPTIMIZE_BOTH The coordinates will be adjusted for the table and head rotations.
OPTIMIZE_TABLES The coordinates will be adjusted for the rotary tables.
OPTIMIZE_HEADS The coordinates will be adjusted for the rotary heads.
OPTIMIZE_AXIS The coordinates will be adjusted based on the TCP setting for each axis as
defined in the createAxis command.
Optimization Types for 3+2 Operations
The logic that controls the Work Plane calculation is typically located in the defineWorkPlane section,
but can be in the onSection function for legacy post processors
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
machining to be on the back side of the table, so in this case you will want the X-axis pointing in the
negative direction.
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
function setWorkPlane(abc) {
if (is3D() && !machineConfiguration.isMultiAxisConfiguration()) {
return;
}
// 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.1 currentSection
The currentSection variable refers to the active section/operation. It is unspecified if used outside of the
scope of a section, for example in onOpen or onClose. In these functions you will need to access the
section directly using the getSection function.
4.4.2 getSection
value = getSection(sectionId)
Returns the section object associated with the specified section ID.
4.4.3 getNumberOfSections
value = getNumberOfSections()
4.4.4 getId
value = section.getId()
The getId function returns the ID of the provided section. It will be in the range of 0 through the number
of defined sections minus 1 (getNumberOfSections).
4.4.5 isToolChangeNeeded
value = isToolChangeNeeded([section], arguments)
Arguments Description
section Specifies the section to test for a tool change. If section is not specified, then
currentSection is assumed.
arguments Specifies one or more of the Tool object variables to use as criteria to
determine if a tool change is needed. This list of criteria can be number,
description, lengthOffset, or any other member of the Tool object.
Returns true if a tool change is required for the specified section. The comparison criteria are passed as
a list of arguments to the function and can be any valid Tool object variable.
Arguments Description
section Specifies the section to test for a Work Plane change. If section is not
specified, then currentSection is assumed.
Returns true if the work plane changes for the specified section as compared to the previous section.
4.4.7 isNewWorkOffset
value = isNewWorkOffset([section])
Arguments Description
section Specifies the section to test for a Work Offset change. If section is not
specified, then currentSection is assumed.
Returns true if the work offset changes for the specified section as compared to the previous section.
4.4.8 isSpindleSpeedDifferent
value = isSpindleSpeedDifferent([section])
Arguments Description
section Specifies the section to test for a change in the spindle speed or spindle mode.
If section is not specified, then currentSection is assumed.
Returns true if the spindle speed or spindle mode (RPM, SFM) differs from the previous section, false if
they are the same.
if (isSpindleSpeedDifferent ()) {
Determining if the Spindle Speed or Mode Changes Between Sections
4.4.9 isDrillingCycle
isDrillingCycle([section,] [checkBoringCycles])
Returns true if the section is a drilling operation, otherwise returns false. Milling cycles are not
considered a drilling cycle.
4.4.10 isTappingCycle
isTappingCycle([section])
Arguments Description
section Specifies the section to check for a tapping cycle. If section is not specified,
then currentSection is assumed.
4.4.11 isAxialCenterDrilling
isAxialCenterDrilling([section,] [checkLiveTool])
Arguments Description
section Specifies the section to check for an axial drilling cycle. If section is not
specified, then currentSection is assumed.
checkLiveTool When set to false, the live tool setting is ignored and will not be used in testing
for an axial center drilling operation, otherwise if set to true or not specified
operations using a live tool will not be considered as an axial center drilling
operation.
Returns true if the section is an axial drilling cycle, otherwise returns false. Axial drilling cycles are
considered drilling operations that are at X0 Y0 and are usually tested for on lathes.
4.4.12 isMillingCycle
isMillingCycle([section,] [checkBoringCycles])
Arguments Description
section Specifies the section to check for a milling cycle. If section is not specified,
then currentSection is assumed.
checkBoringCycles When set to true, boring cycles with a shift value will be considered a milling
cycle, otherwise if set to false or not specified shift boring cycles are not
considered milling cycles.
4.4.13 isProbeOperation
value = isProbeOperation([section])
Arguments Description
section Specifies the section to check for a probing operation. If section is not
specified, then currentSection is assumed.
Returns true if the section is a probing operation, otherwise return false. You can also check if the tool
type is set to TOOL_PROBE to determine if probing is active for an operation.
4.4.14 isInspectionOperation
value = isInspectionOperation([section])
Arguments Description
section Specifies the section to check for an inspection operation. If section is not
specified, then currentSection is assumed.
4.4.15 isDepositionOperation
value = isDepositionOperation([section])
Arguments Description
section Specifies the section to check for a deposition operation. If section is not
specified, then currentSection is assumed.
4.4.16 probeWorkOffset
value = section.probeWorkOffset
The probeWorkOffset variable contains the WCS number that is active during the probing operation. It
is the same as the probe-output-work-offset parameter.
4.4.17 getNextTool
tool = getNextTool([section,] [firstTool,] [arguments])
Arguments Description
section Specifies the section to use as the base tool. The next tool following the tool
used in this section will be returned. If section is not specified, then
currentSection is assumed.
firstTool Returns the first tool if the end of the program is reached when set to true.
Returns undefined if it is not specified or set to false and the end of the
program is reached.
arguments Specifies one or more of the Tool object variables to use as criteria to
determine the next tool. This list of criteria can be number, description,
lengthOffset, or any other member of the Tool object.
The getNextTool function returns the next tool used in the program based on the active tool in the
current section. You can pass number, description, diameter, or any other member of the tool object as
the criteria for determining if the tool is different than the current tool. This function will take any
var nextTool = getNextTool(true); // get next tool based on tool number, can return the first tool
var nextTool = getNextTool("description"); // get next tool based on tool description
Accessing the Next Tool
4.4.18 getFirstTool
tool = getFirstTool()
The getFirstTool function returns the first tool used in the program.
4.4.19 toolZRange
zRange = toolZRange()
The toolZRange function returns the Z-axis range for the active tool for the current and subsequent
sections that use this tool. It will return undefined if the tool orientation of the active section is not along
the Z-axis.
4.4.20 strategy
value = section.strategy;
The strategy variable is part of the section object and contains a string that represents the machining
strategy used for the section. It contains the same value as the operation-strategy parameter.
4.4.21 checkGroup
value = section.checkGroup(strategy-list)
Arguments Description
strategy-list A list of machining strategy groups to check, separated by commas.
Entry Functions 4-132
CAM Post Processor Guide 11/5/22
The checkGroup function returns true if the section machining strategy belongs to all of the strategy
groups specified in the strategy-list. The valid strategy groups are listed in the following table. Each of
these variables should be prefixed with STRATEGY_, for example STRATEGY_2D.
2D 3D ADDITIVE CHECKSURFACE
FINISHING HOLEMAKING INSPECTION JET
DRILLING MILLING MULTIAXIS PROBING
ROTARY ROUGHING SAMPLING SECONDARYSPINDLE
SURFACE THREAD TURNING
Strategy Groups (Prefixed with STRATEGY_)
4.5 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 (getProperty("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.6 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);
4.7 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
COMMAND_STOP_SPINDLE Stop spindle (M05)
Entry Functions 4-136
CAM Post Processor Guide 11/5/22
Command Description
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.9 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.10 onDwell
function onDwell(seconds) {
Entry Functions 4-138
CAM Post Processor Guide 11/5/22
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.11 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.
default The value to return if the requested parameter is not defined. If a default value
is not specified and the parameter is not defined, then undefined is returned.
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 so it is recommended that you check for the
parameter either by specifying a default value in the getParameter call or by 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.
default The value to return if the requested parameter is not defined. If a default value
is not specified and the parameter is not defined, then undefined is returned.
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')
When processing multiple setups at the same time some of the global parameters will change from one
setup to the next. The getGlobalParameter function though will always reference the parameters of the
first setup, so if you want to access the parameters of the active setup then you will need to use the
onParameter function rather than the getGlobalParameter function.
4.12 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.13 onSpindleSpeed
function onSpindleSpeed(speed) {
Arguments Description
spindleSpeed The new spindle speed in RPM.
Entry Functions 4-142
CAM Post Processor Guide 11/5/22
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.14 onOrientateSpindle
function onOrientateSpindle(angle) {
Arguments Description
angle Spindle orientation angle in radians.
The onOrientateSpindle function is not typically called. When a cycle that orientates the spindle is
expanded the onCommand(COMMAND_ORIENTATE_SPINDLE) function is called.
4.15 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.16 onMovement
function onMovement(movement) {
Entry Functions 4-144
CAM Post Processor Guide 11/5/22
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.17 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
Entry Functions 4-145
CAM Post Processor Guide 11/5/22
(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.
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 invokeOnRapid be called
instead. This will ensure that the post engine is notified of the move and the current position is set.
invokeOnRapid will then call onRapid with the provided arguments.
4.19 onLinear
function onLinear(_x, _y, _z, feed) {
Arguments Description
_x, _y, _z The tool position.
feed The feedrate.
The onLinear function handles linear moves (G01) at a feedrate while in 3-axis mode. The tool position
is passed as the _x, _y, _z arguments. The format of the onLinear function is pretty basic, it will handle
a change in radius compensation and outputs the linear move to the NC file.
4.20 invokeOnLinear
invokeOnLinear(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 invokeOnLinear be called instead. This
4.21 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.
// 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);
Please refer to the Multi-Axis Post Processors chapter for a detailed explanation on supporting a multi-
axis machine.
4.22 invokeOnRapid5D
invokeOnRapid5D(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.
It is possible that the post processor will need to generate multi-axis rapid positioning moves during the
processing of the intermediate file. An example would be when handling the retract/reconfigure
procedure. Instead of calling onRapid5D with the post generated moves, it is recommended that
invokeOnRapid5D be called instead. This will ensure that the post engine is notified of the move and
the current position is set. invokeOnRapid5D will then call onRapid5D with the provided arguments.
4.23 onLinear5D
function onLinear5D(_x, _y, _z, _a, _b, _c, feed, feedMode) {
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.
feed The feedrate value calculated for the multi-axis feedrate mode.
feedMode The active multi-axis feedrate mode It can be FEED_FPM,
FEED_INVERSE_TIME, or FEED_DPM.
Entry Functions 4-150
CAM Post Processor Guide 11/5/22
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.
It is important to know that the feedMode argument will not be present if multi-axis feedrates are not
defined either in an external Machine Configuration or within the post processor using the
setMultiAxisFeedrate function. The feed value will always be passed as the programmed feedrate in this
case.
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.24 invokeOnLinear5D
invokeOnLinear5D(x, y, z, a, b, c, feed);
Arguments Description
x, y, z The tool position.
It is possible that the post processor will need to generate multi-axis cutting moves during the processing
of the intermediate file. An example would be when handling the retract/reconfigure procedure. Instead
of calling onLinear5D with the post generated moves, it is recommended that invokeOnLinear5D be
called instead. This will ensure that the post engine is notified of the move and the current position is
set. invokeOnLinear5D will then call onLinear5D with the provided arguments.
The post engine will calculate the proper feedrate value and mode prior to calling onLinear5D.
4.25 onCircular
function onCircular(clockwise, cx, cy, cz, x, y, z, feed) {
Argument Description
clockwise Set to true if the circular direction is in the clockwise direction, false if
counter-clockwise.
cx, cy, cz Center coordinates of circle.
x, y, z Final point on circle
feed The feedrate.
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.
switch (getCircularPlane()) {
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), getFeed(feed));
break;
case PLANE_ZX:
writeBlock(gPlaneModal.format(18), gMotionModal.format(clockwise ? 2 : 3),
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 : 3),
xOutput.format(x), yOutput.format(y), zOutput.format(z),
jOutput.format(cy - start.y, 0), kOutput.format(cz - start.z, 0), getFeed(feed));
break;
default: // circular record is not in major plane
linearize(tolerance);
}
Circular Output Based on Plane
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
Function Description
getCircularCenter() Returns the center point of the circle as a Vector.
getCircularChordLength() Returns the delta linear movement of the circular interpolation record.
getCircularNormal() Returns the normal of the circular plane as a Vector. The normal is
flipped if the circular movement is in the clockwise direction. This
follows the righthand plane convention.
getCircularPlane() Returns the plane of the circular interpolation record, PLANE_XY,
PLANE_ZX, or PLANE_YZ. If the return value is -1, then the
circular plane is not a major plane, but is in 3-D space.
getCircularRadius() Returns the end radius of the circular motion.
getCircularStartRadius() Returns the start radius of the circular motion. This will be different
than the end radius for spiral moves.
getCircularSweep() Returns the angular sweep of the circular interpolation record in
radians.
getCurrentPosition() Returns the starting point of the circular move as a Vector.
getHelicalDistance() Returns the distance the third axis will move during helical
interpolation. Returns 0 for a 2-D circular interpolation record.
getHelicalOffset() Returns the distance along the third axis as a Vector. This function is
used when helical interpolation is supported outside one of the three
standard circular planes.
getHelicalPitch() Returns the distance that the third axis travels for a full 360-degree
sweep, i.e. the pitch value of the thread.
getPositionU(u) Returns the point on the circle at u percent along the arc as a Vector.
isFullCircle() Returns true if the angular sweep of the circular motion is 360
degrees.
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.
Most stock post processors are already setup to output the third axis with circular interpolation (it won't
be output for a 2-D circular move).
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);
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));
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 (getProperty("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
Entry Functions 4-158
CAM Post Processor Guide 11/5/22
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.26 invokeOnCircular
invokeOnCircular(clockwise, cx, cy, cz, x, y, z, i, j, k, feed);
Arguments Description
clockwise Set to true if the direction of the circular is in the clockwise direction, false if it
is counter-clockwise.
cx, cy, cz The center of the circle.
x, y, z The tool position.
i, j, k The normal vector of the circle.
feed The feedrate.
It is possible that the post processor will need to generate circular arcs during the processing of the
intermediate file. To do this invokeOnCircular can be called. Calling invokeOnCircular ensures that
the post engine is notified of the arc move and the current position is set. invokeOnCircular will then
call onCircular with the provided arguments and setting the proper circular variables.
4.27 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
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.28 onCyclePoint
function onCyclePoint(x, y, z) {
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
If a cycle is not supported and needs to be expanded by the post engine, then you can either remove the
entire case block for this cycle and it will be handled in the default block, or you can specifically expand
the cycle. The second method is handy when the canned cycle does not support all of the parameters
available in HSM, for example if a dwell is not supported for a deep drilling cycle on the machine, but
you want to be able to use a dwell.
case "deep-drilling":
if (P > 0) { // the machine does not support a dwell code, so expand the cycle
Entry Functions 4-160
CAM Post Processor Guide 11/5/22
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)
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)
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 will use the following parameters when they are expanded.
machineParameters. Description
drillingSafeDistance Specifies the safety distance above the stock when repositioning into
the hole for the chip-breaking and deep-drilling cycles.
spindleOrientation The spindle orientation angle after orientating the spindle.
spindleSpeedDwell Dwell in seconds after the spindle speed changes during a cycle.
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.
incrementalDepth The incremental pecking depth of the first cut.
incrementalDepthReduction The incremental pecking depth reduction per cut for pecking cycles.
minimumIncrementalDepth The minimum pecking depth of cut for pecking cycles.
numberOfSteps The number of horizontal passes for the thread-milling cycle.
Entry Functions 4-163
CAM Post Processor Guide 11/5/22
Parameter Description
plungeFeedrate The cutting feedrate. The same as feedrate.
plungesPerRetract The number of cuts before the tool will be fully retracted during a
chip-breaking cycle.
postioningFeedrate The feedrate used to position the tool during a gun-drilling cycle.
positioningSpindleSpeed The spindle speed used when positioning the tool during a gun-
drilling cycle.
repeatPass Set to true if the final pass should be repeated for circular-pocket-
milling and thread-milling cycles.
retract The plane where the tool will position to prior to starting the cycle
(feeding into the hole).
retractFeedrate The tool retraction feedrate, used when feeding out of the hole.
shift The distance to shift the tool away from the wall during a fine-boring
and back-boring cycle.
shiftDirection The direction in radians to shift the tool away from the wall during a
fine-boring and back-boring cycle. The shift direction will be PI
radians (180 degrees) from the wall plus this amount.
shiftOrientation The spindle orientation of the tool in radians when shifting the tool
away from the wall during a fine-boring or back-boring cycle.
stepover The horizontal stepover distance for circular-pocket-milling and
thread-milling cycles.
stock The top of the hole.
stopSpindle When set to 1, the spindle will be stopped during
positioning/retracting in a gun-drilling cycle.
threading Either right or left-handed threading for thread-milling cycles.
Cycle Parameters
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
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.
function getCommonCycle(x, y, z, r, c) {
forceXYZ(); // force xyz on first drill hole of any cycle
if (incrementalMode) {
zOutput.format(c);
Entry Functions 4-166
CAM Post Processor Guide 11/5/22
return [xOutput.format(x), yOutput.format(y),
"Z" + xyzFormat.format(z - r),
"R" + xyzFormat.format(r - c)];
} else {
return [xOutput.format(x), yOutput.format(y),
zOutput.format(z),
"R" + xyzFormat.format(r)];
}
}
…
case "drilling":
writeBlock(
gRetractModal.format(98), gCycleModal.format(81),
getCommonCycle(x, y, z, cycle.retract, cycle.clearance),
feedOutput.format(F)
);
break;
Pass Retract and Clearance Heights to getCommonCycle Function
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)),
pitchOutput.format(tool.threadPitch)
);
forceFeed(); // force the feedrate to be output after a tapping cycle with pitch output
break;
Entry Functions 4-167
CAM Post Processor Guide 11/5/22
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.29 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.30 onRewindMachine
function onRewindMachine(_a, _b, _c) {
Argument Description
_a, _b, _c Rotary axes rewind positions.
4.31.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.31.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.
/**
Writes the specified block.
Entry Functions 4-169
CAM Post Processor Guide 11/5/22
*/
function writeBlock() {
var text = formatWords(arguments);
if (!text) {
return;
}
if (getProperty("showSequenceNumbers")) { // add sequence numbers to output blocks
if (optionalSection) {
if (text) {
writeWords("/", "N" + sequenceNumber, text);
}
} else {
writeWords2("N" + sequenceNumber, text);
}
sequenceNumber += getProperty("sequenceNumberIncrement");
} else { // no sequence numbers
if (optionalSection) {
writeWords2("/", text);
} else {
writeWords(text);
}
}
}
Sample writeBlock Function
4.31.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.
4.31.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
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 = manualNC.length -1; i >= 0; --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(getProperty("toolBreakageTolerance"))
);
toolChecked = true;
}
Manual NC Commands 5-179
CAM Post Processor Guide 11/5/22
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 is not only called for all parameters defined in the intermediate file (see the
many calls to onParameter in the dump.cps post processor output) it also 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
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;
}
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.
Manual NC Commands 5-183
CAM Post Processor Guide 11/5/22
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.
The onPassThrough function handles the Pass through Manual NC command and is passed the text
entered with the command. The following sample code will accept a text string with comma delimiters
that will separate the text into individual lines.
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)
Debugging 6-184
CAM Post Processor Guide 11/5/22
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
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,
Debugging 6-185
CAM Post Processor Guide 11/5/22
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.
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,
Debugging 6-186
CAM Post Processor Guide 11/5/22
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.
Debugging 6-187
CAM Post Processor Guide 11/5/22
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.
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
The generic RS-274D Sample Multi-axis Post Processor is available to use as a sample for
implementing multi-axis support in any post processor. It supports CAM defined and hardcoded
Machine Configurations. You can use this post processor for testing rotary axes configurations and for
copying functionality into your custom post processor.
The scale:DEG parameter specifies that the rotary axes angles will be output in degrees. If you require
the output to be in radians, then omit the scale setting.
You will also need to add the following code to the top of the onOpen function to call the machine
configuration functions.
function onOpen() {
// define and enable machine configuration
receivedMachineConfiguration = machineConfiguration.isReceived();
if (typeof defineMachine == "function") {
defineMachine(); // hardcoded machine configuration
}
activateMachine(); // enable the machine optimizations and settings
Copy this Code to the Top of the onOpen Function
The variables at the top of the machine configuration code control certain aspects of multi-axis logic
within the post processor.
Multi-Axis Post Processors 7-189
CAM Post Processor Guide 11/5/22
/ Start of machine configuration logic
var compensateToolLength = false; // add the tool length to the pivot distance for nonTCP rotary heads
Variable Description
compensateToolLength This variable is only used for rotary head configurations that do not support
TCP. When it is enabled, the body length of the tool (tool body length) will
be added to the pivot distance. Rotary head configurations are discussed in
detail in the Adjusting the Points for Offset Rotary Axes section.
Multi-axis Settings
The hardcoded machine configuration can be found in the defineMachine function.It includes all
applicable settings that are found in the Machine Configuration and contains the following sections of
code.
function defineMachine() {
// if (!receivedMachineConfiguration) { // CAM machine configuration takes precedence
if (true) { // hardcoded machine configuration takes precedence
// define machine kinematics
var useTCP = false; // TCP support
var aAxis = createAxis({coordinate:X, table:true, axis:[1, 0, 0], offset:[0, 0, 0], range:[-120, 30],
cyclic:false, preference:-1, tcp:useTCP});
var cAxis = createAxis({coordinate:Z, table:true, axis:[0, 0, 1], offset:[0, 0, 0], cyclic:true, reset:0,
tcp:useTCP});
machineConfiguration = new MachineConfiguration(aAxis, cAxis);
Define Machine Kinematics
The rotary axes can be customized to match the machine configuration using the parameters in the
createAxis command.
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,
.7071, .7071]. 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.
createAxis Parameters
The order in which the axes are defined in the new MachineConfiguration call is important and must use
the following order.
// Same table/table setup, without TCP, top and center of C-axis is defined as the origin
var bAxis = createAxis({coordinate:Y, table:true, axis:[0, 1, 0], offset:0, 0, -12.5], range:[-120,120],
tcp:false, preference:1});
var cAxis = createAxis({coordinate:Z, table:true, axis:[0, 0, 1], cyclic:true, tcp:false});
machineConfiguration = new MachineConfiguration(bAxis, cAxis);
setMachineConfiguration(machineConfiguration);
The determination if the output coordinates should be at the pivot point of the rotary heads or the virtual
tooltip position (as if the tool is vertical) is decided by the setVirtualTooltip function. This setting is
only applied to rotary heads that do not support TCP. The virtual tooltip position is described in the
Adjusting the Points for Offset Rotary Axes section.
// multiaxis settings
if (machineConfiguration.isHeadConfiguration()) {
machineConfiguration.setVirtualTooltip(false); // translate the pivot point to the virtual tool tip
for nonTCP rotary heads
}
Virtual Tooltip Setting
It is possible on some machine configurations that the limits of the rotary axes will be exceeded and the
tool has to be retracted and the rotary axes repositioned to within the limits of the machine. The
following code defines the required settings for the retract/reconfigure logic. It is described in the
Rewinding of the Rotary Axes when Limits are Reached section.
Multi-Axis Post Processors 7-192
CAM Post Processor Guide 11/5/22
// retract / reconfigure
var performRewinds = false; // set to true to enable the retract/reconfigure logic
if (performRewinds) {
machineConfiguration.enableMachineRewinds(); // enables the retract/reconfigure logic
safeRetractDistance = (unit == IN) ? 1 : 25; // additional distance to retract out of stock, can be
overridden with a property
safeRetractFeed = (unit == IN) ? 20 : 500; // retract feed rate
safePlungeFeed = (unit == IN) ? 10 : 250; // plunge feed rate
machineConfiguration.setSafeRetractDistance(safeRetractDistance);
machineConfiguration.setSafeRetractFeedrate(safeRetractFeed);
machineConfiguration.setSafePlungeFeedrate(safePlungeFeed);
var stockExpansion = new Vector(toPreciseUnit(0.1, IN), toPreciseUnit(0.1, IN),
toPreciseUnit(0.1, IN)); // expand stock XYZ values
machineConfiguration.setRewindStockExpansion(stockExpansion);
}
Retract/Reconfigure Settings
Multi-axis machines that do not support TCP will usually require inverse time or degree per minute
feedrates. The mulit-axis feedrate format is defined in the following section of code. Multi-axis
feedrates are discussed in more detail in the Multi-Axis Feedrates section.
// multi-axis feedrates
if (machineConfiguration.isMultiAxisConfiguration()) {
machineConfiguration.setMultiAxisFeedrate(
useTCP ? FEED_FPM : getProperty("useDPMFeeds") ? FEED_DPM :
FEED_INVERSE_TIME,
9999.99, // maximum output value for inverse time feed rates
getProperty("useDPMFeeds") ? DPM_COMBINATION : INVERSE_MINUTES, //
INVERSE_MINUTES/INVERSE_SECONDS or DPM_COMBINATION/DPM_STANDARD
0.5, // tolerance to determine when the DPM feed has changed
1.0 // ratio of rotary accuracy to linear accuracy for DPM calculations
);
}
Multi-Axis Feedrates Definition
The home position of the machine can be defined in the defineMachine function. The home positions
are used in the writeRetract function when positioning the machine in machine coordinates (G53) or
WCS coordinates (G00).
/* home positions */
// machineConfiguration.setHomePositionX(toPreciseUnit(0, IN));
// machineConfiguration.setHomePositionY(toPreciseUnit(0, IN));
// machineConfiguration.setRetractPlane(toPreciseUnit(0, IN));
Defining the Machine Home Coordinates
The optimizeMachineAngles2 function calculates the rotary axes angles and adjusts the XYZ coordinates
for the rotary axes if TCP is not supported. The following values are passed to the
optimizeMachineAngles2 function.
Value Description
OPTIMIZE_NONE Don't adjust the coordinates for the rotary axes. Used for TCP mode.
OPTIMIZE_BOTH Adjust the coordinates for the rotary axes. For rotary heads that do
not support TCP it is possible that the tool length has to be added to
the tool end point coordinates. This scenario is discussed further in
the Adjusting the Points for Rotary Heads section of this chapter.
OPTIMIZE_TABLES Adjust the coordinates for rotary tables. No adjustment will be made
for heads.
OPTIMIZE_HEADS Adjust the coordinates for rotary heads. No adjustment will be made
for tables.
OPTIMIZE_AXIS Adjust the coordinates for the rotary axes based on the TCP setting
associated with the defined axes. This is the required setting for
CAM defined Machine Configurations and hardcoded Machine
Configuration that define the tcp variable in the createAxis
definitions.
Settings for Adjusting the Input Coordinates for the Rotary Axes
Rotary head adjustments that require that the tool length be added to the offset distance of the axis
cannot be adjusted using the optimizeMachineAngles2 function, since the tool length will vary from tool
to tool. Instead, the Section function optimizeMachineAnglesByMachine is called for each section. This
is also true for post processors that may change the Machine Configuration during the processing of the
// calculate the ABC angles and adjust the points for multi-axis operations
// rotary heads may require the tool length be added to the pivot length
// so we need to optimize each section individually
if (machineConfiguration.isHeadConfiguration() && compensateToolLength) {
for (var i = 0; i < getNumberOfSections(); ++i) {
var section = getSection(i);
if (section.isMultiAxis()) {
machineConfiguration.setToolLength(getBodyLength(section.getTool())); // define the tool
length for head adjustments
section.optimizeMachineAnglesByMachine(machineConfiguration, OPTIMIZE_AXIS);
}
}
} else { // tables and rotary heads with TCP support can be optimized with a single call
optimizeMachineAngles2(OPTIMIZE_AXIS);
}
Rotary Axes Calculations and Coordinate Transformation
If the call to calculate the rotary axes and adjust the input coordinates is not made then the tool end point
and tool axis vector will be passed to the onRapid5D and onLinear5D multi-axis functions.
The initial rotary axes positions must be calculated prior calling the positionABC function. The function
getInitialToolAxisABC() is used to obtain the initial rotary axes positions for multi-axis operations.
if (currentSection.isMultiAxis()) {
var abc = section.getInitialToolAxisABC();
positionABC(abc, true);
}
Calculate Initial Rotary Angles for a Multi-axis Operation
function onLinear5D (_x, _y, _z, _a, _b, _c, feed, feedMode) {
if (!currentSection.isOptimizedForMachine()) {
error(localize("This post configuration has not been customized for 5-axis simultaneous
toolpath."));
return;
}
if (pendingRadiusCompensation >= 0) {
error(localize("Radius compensation cannot be activated/deactivated for 5-axis move."));
return;
}
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);
var f = feedOutput.format(_feed);
if (x || y || z || a || b || c) {
writeBlock(gFeedModeModal.format(fMode), 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(gfFeedModeModal.format(fMode), MotionModal.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.
A rotary scale on the other hand 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.
For controls that require a sign to designate the direction the rotary axis will move, you will need to
define the rotary axis on a linear scale. Yes, it sounds counterintuitive, but the output variable will
handle converting the linear scale value to a signed rotary scale value.
The createOutputVariable function can be used to output a directional value for a rotary axis on a rotary
scale.
It is important to know how the offsets are applied to each style of rotary axis. For rotary heads
remember the head rider axis is defined first and then the head carrier axis. When the carrier and rider
heads share a common pivot point, then only the offset for the rider 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 carrier
Multi-Axis Post Processors 7-199
CAM Post Processor Guide 11/5/22
axis offset is defined as the offset from the rider pivot point. Most machines will use a common pivot
point for both rotary axes.
When defining an offset rotary table, defining the offset is all that is needed before the rotary angles and
transformed coordinates are calculated.
For offset heads on machines that do not support TCP there are a couple of more function calls that may
be needed.
It is possible that the tool length needs to be added to the offset of the head rider axis defined in the
createAxis function. On small hobbyist machines it could be that the tool will always be the same length
and can then be defined as part of the offset. On machines that use different tool lengths you will need
to inform the post engine of the tool length to be added to the pivot distance prior to calculating the
Multi-Axis Post Processors 7-200
CAM Post Processor Guide 11/5/22
offset coordinates for the section. This is done by calling the machineConfiguration.setToolLength
function with the length of the tool from the tool end point to the tool stop position used to define the
offset for the head.
The post processor will typically use the Overall length of the tool as defined in the CAM system as the
tool length.
The output of the offset head coordinates can either be at the pivot point of the axis or the tool end point
when the rotary axes are at 0 degrees (the tool is vertical). You would normally setup the machine with
the tool tip at Z0. In this case the output coordinates will be at the virtual tool tip, meaning that the
coordinates will be where the tool tip position would be when the rotary axes are at 0 degrees, even
when the axes are tilted.
Value Description
OPTIMIZE_BOTH Adjust the coordinates for both tables and heads.
OPTIMIZE_TABLES Adjust the coordinates for rotary tables only.
OPTIMIZE_HEADS Adjust the coordinates for rotary heads only.
optimizeType Values
// calculate the machine XYZ position from the tool tip position
var xyz = machineConfiguration.getOptimizedPosition(toolTip, abc, TCP_XYZ, OPTIMIZE_BOTH,
false);
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
Multi-Axis Post Processors 7-204
CAM Post Processor Guide 11/5/22
Variable Description
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
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
Multi-Axis Post Processors 7-205
CAM Post Processor Guide 11/5/22
the machine, eliminating 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. cyclic is 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 required. Please note that the physical limits of the
machine may be a numeric limit of the control instead of a physical limit, such as 9999.9999.
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 automatic rewind capabilities in your post. The bulk of the
feature is handled by the post processor kernel, but there are some variables and functions that are
required in your post. The variables used for retract/reconfigure are either defined in the CAM Machine
Configuration settings or in the defineMachine function for hardcoded machine configurations.
// retract / reconfigure
var performRewinds = false; // set to true to enable the retract/reconfigure logic
if (performRewinds) {
machineConfiguration.enableMachineRewinds(); // enables the retract/reconfigure logic
safeRetractDistance = (unit == IN) ? 1 : 25; // additional distance to retract out of stock
safeRetractFeed = (unit == IN) ? 20 : 500; // retract feed rate
safePlungeFeed = (unit == IN) ? 10 : 250; // plunge feed rate
machineConfiguration.setSafeRetractDistance(safeRetractDistance);
machineConfiguration.setSafeRetractFeedrate(safeRetractFeed);
machineConfiguration.setSafePlungeFeedrate(safePlungeFeed);
var stockExpansion = new Vector(toPreciseUnit(0.1, IN), toPreciseUnit(0.1, IN), toPreciseUnit(0.1, IN)); //
expand stock XYZ values
machineConfiguration.setRewindStockExpansion(stockExpansion);
}
Retract/Reconfigure Settings Defined in defineMachine
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..
Multi-Axis Post Processors 7-206
CAM Post Processor Guide 11/5/22
safeRetractDistance Defines the distance to be added to the retract position when the tool is
positioned past the stock material to safely remove it from the stock. If it
is set to 0, then the tool will retract to the outer stock plus the stock
expansion.
safeRetractFeed Specifies the feedrate to retract the tool prior to rewinding the rotary axis.
safePlungeFeed Specifies the feedrate to plunge the tool back into the part after rewinding
the rotary axis.
stockExpansion The tool will retract past the defined stock by default. You can expand
the defined stock on all sides by defining the stockAllowance vector,
which contains the expansion value for X, Y, and Z.
Variables that Control Tool Retraction
You will need to copy the retract/reconfigure functions from a post that supports this logic into your
post. These functions are defined in the following section of code and include the designated functions.
The onRewindMachineEntry function 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 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 onMoveToSafeRetractPosition 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
onMoveToSafeRetractPosition function.
The onRotateAxes function is used to position the rotary axes to their new position as calculated by the
post engine. _a, _b, _c define the new rotary axis position. _x, _y, _z should be ignored and not used.
/** Rotate axes to new position above reentry position */
function onRotateAxes(_x, _y, _z, _a, _b, _c) {
// position rotary axes
xOutput.disable();
Multi-Axis Post Processors 7-208
CAM Post Processor Guide 11/5/22
yOutput.disable();
zOutput.disable();
invokeOnRapid5D(_x, _y, _z, _a, _b, _c);
xOutput.enable();
yOutput.enable();
zOutput.enable();
}
Position the Rotary Axes
The onReturnFromSafeRetractPosition 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.
// position in XY
forceXYZ();
xOutput.reset();
yOutput.reset();
zOutput.disable();
invokeOnRapid(_x, _y, _z);
// position in Z
zOutput.enable();
invokeOnRapid(_x, _y, _z);
}
Return from Safe Position after Repositioning Rotary Axes
Multi-axis feedrate calculations are handled by the post engine and and will work with all machine
configurations; table/table, head/head, and head/table. One capability of the multi-axis feedrate
calculation is that it considers the actual tool tip movement in reference to the rotary axes movement and
Multi-Axis Post Processors 7-209
CAM Post Processor Guide 11/5/22
not just the straight-line movement along the programmed tool tip, creating more accurate multi-axis
feedrates. In the following picture the move along the arc caused by the movement of the rotary axis
(green arc) is used in the calculation instead of the straight-line move generated by HSM (blue line).
Multi-axis feedrate support is handled in the CAM Machine Configuration or in the defineMachine
function for a hardcoded machine configuration.
// multi-axis feedrates
if (machineConfiguration.isMultiAxisConfiguration()) {
machineConfiguration.setMultiAxisFeedrate(
useTCP ? FEED_FPM : getProperty("useDPMFeeds") ? FEED_DPM : FEED_INVERSE_TIME,
9999.99, // maximum output value for inverse time feed rates
getProperty("useDPMFeeds") ? DPM_COMBINATION : INVERSE_MINUTES, //
INVERSE_MINUTES/INVERSE_SECONDS or DPM_COMBINATION/DPM_STANDARD
0.5, // tolerance to determine when the DPM feed has changed
1.0 // ratio of rotary accuracy to linear accuracy for DPM calculations
);
}
Enabling Multi-Axis Feedrates
Variable Description
feedMode FEED_INIVERSE_TIME (inverse time), FEED_DPM (degrees per
minute), or FEED_FPM (programmed feedrate).
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 gFeedModeModal
modal variable will also need to be defined for support of G93/G94 output if it does not already exist.
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 receive and output the feedrate mode and to
output the feedrate value using the correct format.
if (x || y || z || a || b || c) {
writeBlock(gFeedModeModal.format(fMode), 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(gFeedModeModal.format(fMode), gMotionModal.format(1), f);
}
}
}
onLinear5D Required Changes
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
}
Reset FPM Mode in onSectionEnd
It is possible that your machine control does not support standard inverse time or DPM feedrates. If this
is the case you will need to write your own function to handle multi-axis feedrates. The
getMultiAxisMoveLength function will assist in the movement length calculations required for
Multi-Axis Post Processors 7-212
CAM Post Processor Guide 11/5/22
calculating multi-axis feedrates. It takes the current position for the linear and rotary axes and will
calculate the tool tip, linear axes, and rotary axes lengths of the move from the previous location.
getMultiAxisMoveLength will return MoveLength obect, which can then be accessed using the following
functions to obtain the different move lengths.
Function Description
getRadialToolTipMoveLength Calculated tool endpoint movement along the actual tool path.
getLinearMoveLength Combined linear delta movement.
getRadialMoveLength Combined rotary delta movement.
MoveLength Functions
It can be supported in the control, for example using G12.1 on Fanuc style controls or handled within the
post processor. Machine control polar interpolation is typically supported on Mill/Turn machines.
This section describes how to implement post processor generated polar interpolation support in your
post and how to activate it using a Manual NC command. The Haas Next Generation post processor has
polar interpolation implemented and can be used as a reference and to copy code from into your post.
The required polar interpolation variables and functions can be copied from the Haas Next Generation
post processor. These functions are bounded by the Start of polar interpolation and End of polar
interpolation comments.
var polarDirection = new Vector(1, 0, 0); // vector to maintain tool at while in polar interpolation
Define the Axis Line for Polar Interpolation
You may have to modify the setPolarFeedMode to set the proper feedrate mode for polar interpolation.
If your machine does not support TCP, then this function can be blank and the same feedrate mode for
multi-axis and polar interpolation operations will be used.
function setPolarFeedMode(mode) {
if (machineConfiguration.isMultiAxisConfiguration()) {
machineConfiguration.setMultiAxisFeedrate(
!mode ? multiAxisFeedrate.mode : getProperty("useDPMFeeds") ? FEED_DPM :
FEED_INVERSE_TIME,
multiAxisFeedrate.maximum,
!mode ? multiAxisFeedrate.type : getProperty("useDPMFeeds") ? DPM_COMBINATION :
INVERSE_MINUTES,
multiAxisFeedrate.tolerance,
multiAxisFeedrate.bpwRatio
);
if (!receivedMachineConfiguration) {
setMachineConfiguration(machineConfiguration);
}
}
}
setPolarFeedMode to Use when TCP is Supported
function setPolarFeedMode(mode) {
}
setPolarFeedMode to Use when TCP is Not Supported
cancelTransformation();
if (_setWorkPlane) {
if (activeG254) {
Multi-Axis Post Processors 7-217
CAM Post Processor Guide 11/5/22
writeBlock(gFormat.format(255)); // cancel DWO
activeG254 = false;
}
forceWorkPlane();
positionABC(abc, true);
}
} else {
Calculating the Initial ABC Position for Polar Interpolation in defineWorkPlane
Polar interpolation converts a 3-axis operation to a multi-axis operation, so it must be treated as such.
This means that the rotary axis must be unlocked prior to the initial positioning move, but not clamped
afterwards. This is handled in the setWorkPlane function.
There could be code in the onCommand function for unlocking the rotary axis that may need to be
changed also.
case COMMAND_UNLOCK_MULTI_AXIS:
var outputClampCodes = getProperty("useClampCodes") || currentSection.isMultiAxis()
|| isPolarModeActive();
if (outputClampCodes && machineConfiguration.isMultiAxisConfiguration() &&
(machineConfiguration.getNumberOfAxes() >= 4)) {
Unlocking the Rotary Axis During Polar Interpolation in onCommand
defineWorkPlane(currentSection, false);
forceAny();
Enabling Polar Interpolation in onSection
if (currentSection.isMultiAxis() || isPolarModeActive()) {
writeBlock(gFeedModeModal.format(94)); // inverse time feed off
if (currentSection.isOptimizedForMachine()) {
// the code below gets the machine angles from previous operation. closestABC must also be set
to true
currentMachineABC = currentSection.getFinalToolAxisABC();
}
if (operationSupportsTCP) {
disableLengthCompensation(false, "TCPC OFF");
}
}
…
setPolarMode(currentSection, false);
Enabling Polar Interpolation in onSection
Drilling cycle locations will still call onCyclePoint during polar interpolation, so modifications must be
made to output the rotary axis with the cycle positions. This is done by making the following
modification to the getCommonCycle function for the first point of a cycle operation.
function getCommonCycle(x, y, z, r, c) {
forceXYZ();
if (incrementalMode) {
zOutput.format(c);
return [xOutput.format(x), yOutput.format(y),
"Z" + xyzFormat.format(z - r),
"R" + xyzFormat.format(r - c)];
} else {
return [xOutput.format(x), yOutput.format(y),
zOutput.format(z),
"R" + xyzFormat.format(r)];
}
}
}
Formatting the Polar Interpolation Cycle Position in getCommonCycle
In the onCyclePoint function you need to format the cycle location for polar interpolation for the 2nd
through final cycle point.
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
###############################################################################
Error: The probe cycle 'probing-xy-outer-corner' is machine specific and must always be handled in
the post configuration.
Error in operation: 'WCS Probe1'
Failed while processing onCycle() for record 280.
###############################################################################
Machine Specific 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.
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-partial-boss Probes the outer wall of a circular boss that is not a
complete 360 degrees
probing-xy-circular-hole Probes the inner wall of a circular hole
probing-xy-circular-partial hole Probes the inner wall of a circular hole that is not a
complete 360 degrees
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.
probing-xy-outer-corner Probes an outer corner. Modifies the origin and rotation
of the part.
probing-x-plane-angle Probes a wall at an angle to the X-axis. Modifies the
rotation of the part.
probing-y-plane-angle Probes a wall at an angle to the Y-axis. Modifies the
rotation of the part.
Probing Cycles
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’.
retract The height to feed from to the probing level and to retract the probe to
after probing is finished.
stock The top of the part.
toleranceAngle The acceptable angular deviation of the geometric feature.
tolerancePosition The acceptable positional deviation of the geometric feature.
toleranceSize The acceptable size deviation of the geometric feature.
width1 The width of the boss or hole being probed.
The following functions support angular probing and safe probe positioning. They 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.
Function Description
approach Converts the cycle approach string to a number (-1/1).
setProbeAngleMethod Determines the output method (G68, G54.4, rotational)
for angular probing cycles.
setProbeAngle Outputs the rotational blocks for angular probing cycles.
This output may have to be modified to match your
control.
protecedProbeMove Positions the probe in a protected mode (P9810).
getProbingArguments Formats the standard codes for all probing cycles based
on the probing cycle parameters. This function is usually
located after the onCyclePoint function and may have to
be modified to match your control.
Required Probe Functions
function setProbeAngleMethod() {
…
function protectedProbeMove(_cycle, x, y, z) {
…
}
The core logic for probing is in the onCyclePoint function. The first part of the code to copy into your
post is at the top of the onCyclePoint function.
if (isProbeOperation()) {
if (!useMultiAxisFeatures && !isSameDirection(currentSection.workPlane.forward, new Vector(0,
0, 1))) {
if (!allowIndexingWCSProbing && currentSection.strategy == "probe") {
error(localize("Updating WCS / work offset using probing is only supported by the CNC in the
WCS frame."));
return;
}
}
if (printProbeResults()) {
writeProbingToolpathInformation(z - cycle.depth + tool.diameter / 2);
inspectionWriteCADTransform();
inspectionWriteWorkplaneTransform();
if (typeof inspectionWriteVariables == "function") {
inspectionVariables.pointNumber += 1;
}
}
protectedProbeMove(cycle, x, y, z);
}
Required Probing Code at Top of onCyclePoint
All probing operations are considered a separate operation and are not modal. The following code in the
onCyclePoint function should directly follow the required probing code you just added and needs to be
modified as shown in the highlighted code to support probing.
if (isFirstCyclePoint() || isProbeOperation()) {
if (!isProbeOperation()) {
Adding Support for Probing 8-226
CAM Post Processor Guide 11/5/22
// return to initial Z which is clearance plane and set absolute mode
repositionToCycleClearance(cycle, x, y, z);
}
Required Modifications for Probing Support
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:
Add the following code to the onCycleEnd function to end the probing operation.
function onCycleEnd() {
if (isProbeOperation()) {
zOutput.reset();
gMotionModal.reset();
writeBlock(gFormat.format(65), "P" + 9810, zOutput.format(cycle.retract)); // protected
retract move
} else {
…
}
The gRotationModal modal is used to manage the output of the rotation codes (G68, G68.2, etc.). It is
possible that this variable is already defined in the post processor, but may have to be updated to support
probing. It should be defined as shown.
The following variables are used to control the output of probing features probing output and should be
defined in the fixed settings section at the top of the post processor.
var allowIndexingWCSProbing = false; // specifies probe WCS with tool orientation is supported
var probeVariables = {
outputRotationCodes: false, // defines if it is required to output rotation codes
probeAngleMethod : "OFF", // OFF, AXIS_ROT, G68, G54.4
compensationXY : undefined
};
Add to Fixed Settings Section
Variable Description
allowIndexingWCSProbing Some controls do not allow for WCS probing operations when the tool
orientation is at an angle the XY-plane, i.e. the rotary tables are not at 0
degrees. If this is the case for your machine, then disable this variable
by defining it to be false. If WCS probing is allowed when the rotary
axes are not at 0 degrees, then set this variable to true.
outputRotationCodes Controls the output of the angular probing codes. This variable is
controlled by the post processor and should be set to false.
probeAngleMethod Defines the angular probing method to use. This method is usually
defined by the post processor in the setProbingAngleMethod function
and can be controlled by a post processor property. It should be set to
OFF. Other valid values are AXIS_ROT (used when a C-axis rotary
table is defined), G68 (the standard rotation method), or G54.4 (based
on the post processor property useG54x4).
compensationXY Controls the output of the XY compensation variables in angular
probing. This variable is controlled by the post processor and should be
set to undefined.
Probing Settings
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.
var probeOutputWorkOffset = 1;
if (tool.type != TOOL_PROBE) {
var outputSpindleSpeed = insertToolCall || forceSpindleSpeed || isFirstSection() ||
rpmFormat.areDifferent(spindleSpeed, sOutput.getCurrent()) ||
(tool.clockwise != getPreviousSection().getTool().clockwise);
…
}
Don’t Output Spindle Speed with a Probe Tool
if (isProbeOperation()) {
validate(probeVariables.probeAngleMethod != "G68", "You cannot probe while G68
Rotation is in effect.");
validate(probeVariables.probeAngleMethod != "G54.4", "You cannot probe while workpiece
setting error compensation G54.4 is enabled.");
writeBlock(gFormat.format(65), "P" + 9832); // spin the probe on
inspectionCreateResultsFileHeader();
} else {
// surface Inspection
if (isInspectionOperation() && (typeof inspectionProcessSectionStart == "function")) {
inspectionProcessSectionStart();
}
}
// define subprogram
subprogramDefine(initialPosition, abc, retracted, zIsOutput);
retracted = false;
Adding Support for Probing 8-229
CAM Post Processor Guide 11/5/22
}
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;
}
Disable Coolant for Probing Operations
The probe should be turned off and angular probing codes output in the onSectionEnd function.
function onSectionEnd() {
…
if (isProbeOperation()) {
writeBlock(gFormat.format(65), "P" + 9833); // spin the probe off
if (probeVariables.probeAngleMethod != "G68") {
setProbeAngle(); // output probe angle rotations if required
}
}
}
singleResultsFile: {
title : "Create single results file",
description: "Set to false if you want to store the measurement results for each probe / inspection
toolpath in a separate file",
group : 0,
type : "boolean",
value : true,
scope : "post"
}
Add a Property to Control the Output of the Probe Results into a Single or Multiple Files
function getPointNumber() {
…
}
function inspectionWriteCADTransform() {
…
}
function inspectionWriteWorkplaneTransform() {
…
}
function writeProbingToolpathInformation(cycleDepth) {
…
}
Include the Probing Results Functions
In the onClose function you will need to close the probe results file.
if (isDPRNTopen) {
writeln("DPRNT[END]");
writeBlock("PCLOS");
isDPRNTopen = false;
if (typeof inspectionProcessSectionEnd == "function") {
inspectionProcessSectionEnd();
}
}
Closing the Probing Results File
The Pitch Circle Diameter (PCD) probing cycles are an addition to Geometry Probing that do not exist
in WCS Probing. Like all other probing cycles, the PCD cycle types are stored in the cycleType
variable.
cycleType Description
probing-xy-pcd-hole Probes holes around a PCD.
probing-xy-pcd-boss Probes bosses around a PCD.
Pitch Circle Diameter (PCD) Probing Cycles
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
numberOfSubfeatures Number of geometric entities in a PCD probing operation.
pcdStartingAngle The starting angle of the first geometric entity to be probed in a PCD
probing operation.
toolDiameterOffset Defines the tool diameter offset register used to machine the feature.
toolLengthOffset Defines the tool length offset register used to machine the feature.
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.
The probeMultipleFeatures variable instructs the post engine that multiple geometric entities can be
probed in a single operation. The probing logic in all posts now support this feature, so it should be set
to true. It should be defined with the other post engine variables (allowedCircularPlanes, highFeedrate,
etc.).
If the control supports PCD probing cycles be sure to include cases for these cycles in onCyclePoint,
where the other probing cycle code is located.
case "probing-xy-pcd-hole":
protectedProbeMove(cycle, x, y, z);
writeBlock(
gFormat.format(65), "P" + 9819,
"A" + xyzFormat.format(cycle.pcdStartingAngle),
"B" + xyzFormat.format(cycle.numberOfSubfeatures),
"C" + xyzFormat.format(cycle.widthPCD),
"D" + xyzFormat.format(cycle.widthFeature),
"K" + xyzFormat.format(z - cycle.depth),
"Q" + xyzFormat.format(cycle.probeOvertravel),
getProbingArguments(cycle, false)
);
if (cycle.updateToolWear) {
error(localize("Action -Update Tool Wear- is not supported with this cycle."));
return;
}
break;
case "probing-xy-pcd-boss":
protectedProbeMove(cycle, x, y, z);
writeBlock(
gFormat.format(65), "P" + 9819,
"A" + xyzFormat.format(cycle.pcdStartingAngle),
Adding Support for Probing 8-233
CAM Post Processor Guide 11/5/22
"B" + xyzFormat.format(cycle.numberOfSubfeatures),
"C" + xyzFormat.format(cycle.widthPCD),
"D" + xyzFormat.format(cycle.widthFeature),
"Z" + xyzFormat.format(z - cycle.depth),
"Q" + xyzFormat.format(cycle.probeOvertravel),
"R" + xyzFormat.format(cycle.probeClearance),
getProbingArguments(cycle, false)
);
if (cycle.updateToolWear) {
error(localize("Action -Update Tool Wear- is not supported with this cycle."));
return;
}
break;
PCD Probing Support in onCyclePoint
Inspection streamlines the manufacturing process by letting you identify problem areas and decide on
any rework needed early 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 INSPECTION/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 Post Library for Autodesk Fusion 360, or modify your current milling
post which is already set up for your machine to add in the inspection functionality. You will need to
add support for probing to your post processor before adding the inspection capabilities.
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 following parameters are inspection specific and are prefixed with the operation: string. They are
referenced using the getParameter("operation:parameter ") function.
Parameter Description
inspectUpperTolerance The lower limit distance at which an inspected point is considered
within tolerance of the model.
inspectSurfaceOffset The positive or negative distance from the model from where
inspection points are measured.
inspectUpperTolerance The upper limit distance at which an inspected point is considered
within tolerance of the model.
Inspection Parameters
You can also search the online Post Library for Autodesk Fusion 360 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 capabilities located after the onClose or onTerminate function to the end of
the file and add this code to the end of your post processor.
capabilities = |= CAPABILITY_INSPECTION;
description = "HAAS - Next Generation Control Inspect Surface";
longDescription = "Generic post for the HAAS Next Generation control with inspect surface
capabilities.";
Copy From this Code to the End of the File for Core Surface Inspect Logic
At the end of the onSection function, but before any subprograms are defined, add the following code.
At the start of the onSectionEnd function add the following code. The writeBlock statement in this
example will differ between the machine post processors.
You will of course need a model that you want to print to start with. For the examples in this manual we
will use the Fusion Keychain model provided as a CAM sample with your installation of Fusion 360.
This model contains subtractive manufacturing operations which can be combined with Additive
manufacturing operations as long as your machine supports both capabilities.
You will see the ADDITIVE tab on the MANUFACTURE ribbon. Selecting this tab will display the
Additive menus.
Additive Menus
Once you find your machine you may need to select the post processor and Print Settings that
correspond to this machine. The machines in the Fusion 360 Library should all be assigned to the
correct post processor for each machine, so it is rare that you would need to change the post processor.
If necessary, you can select/change the post processor by right clicking on the Prusa i3 MK3 machine
and choosing Change the selected post.
The Post Library dialog will then be displayed. Select the Fusion 360 library and check the Additive
box to display only the post processors supporting the Additive capabilities. You will want to select the
Prusa I3 MK2 machine. You will need to drag this post processor into to your Local library if you plan
on editing it.
You can also create linked folders on your computer to store both the machines and post processors.
You do this by right clicking on the Linked menu and selecting the Link Folder menu. A browser will
be displayed allowing you to select a folder to place your machines/posts.
To select the Print Settings for the printer, right click on the Prusa i3 MK3 machine and choose Select a
print setting. This will bring up the Print Setting Library dialog allowing you to either select an existing
print setting or creating a custom print setting. Print Settings must be stored in the Local library in order
to create or edit them.
Once the Print Setting is in your local library you can edit it by pressing the button. Press the to
create a new Print Setting, you will be prompted to select an existing Print Setting to use as the template
for the new Print Setting.
To create an Additive setup, press the Setup menu, change the Operation Type to Additive, and select the
configuration for your machine by pressing the Select… button under Machine.
If you have not already assigned a post processor to this machine you will need to do so now. Do this
by pressing the Edit… button under the Machine prompt. The Machine Configuration will display,
change the Post location to Personal – local, and select the prusa.cps post processor from the Post
Processor drop down menu.
You can select and/or edit the Print Settings directly from the Setup dialog when creating the Additive
Setup. The Print Settings are specific to the creation of the Additive toolpaths, with settings to modify
Additive Capabilities and Post Processors 9-244
CAM Post Processor Guide 11/5/22
the bed temperature, nozzle temperature, layer thickness, infill style, etc. You can also create your own
default print settings by giving them a new name.
After creating the Setup you should see a representation of the machine base and envelope with the part
located on it. Feel free to rename the new setup to Additive so you know that this is an additive
operation. If you were going to do both additive and subtractive operations in the same model, then you
will want to move the Additive setup above the Subtractive setup.
If the part is not in the location on the machine where you want it, you can easily reposition it using the
POSITION menus.
Positioning Menus
To simulate the Additive toolpath press the Simulate button in the ACTIONS menus. Additive toolpaths
simulate in the same manner as Subtractive toolpaths, but it is recommended that you place the cursor
over the green slide bar at the bottom of the window, hold down the left mouse button, and move the
mouse to the left and right to visualize the Additive process.
Once you create a copy of the Machine Configuration in your Local folder you will need to edit it and
describe your machine. Be sure to give it a unique name and description and go through all sections to
properly define the machine.
After creating your Machine Configuration you will need to copy a seed post into a local folder, for
example prusa.cps, and give it a meaningful name. You can then assign this post processor to your
machine. You can also select the default output folder for your G-code files when posting.
The Temperature Tower properties are typically used to test new filaments in order to identify the best
printing temperatures. These properties are listed in the Temperature Tower group.
Variable Description
bedTemp Temperature of bed.
commands Post processor defined variable that defines the codes that are output for
additive commands.
Extruder An unnamed object that contains the extruder definition. This object is
obtained by calling the getExtruder function.
layerCount Number of printed layers for entire printing operation.
machineConfiguration The Machine Configuration definition.
numberOfExtruders Number of extruders used.
partCount Number of bodies created during printing.
printTime The amount of time the print should take.
settings Post processor defined variable that defines settings specific to additive
machines.
Global Additive Variables
The post processor defined variables are defined in the getPrinterGeometry function from the
machineConfiguration settings and are typically in all Additive post processors.
The following table defines the variables accessible using the getExtruder function
var settings = {
useG0 : true, // use G0 or G1 commands for rapid movements
maximumExtruderTemp: 260 // specifies the maximum extruder temperature
};
settings Definition
The following table defines the unique or modified Entry Functions for Additive post processors. You
can reference the table in the subtractive Entry Functions section for a description of the common entry
functions.
Many of the entry functions will get their arguments and settings from either the Machine Configuration
or Print Settings. These dialogs can be accessed by pressing the right mouse button when over the
Additive setup and selecting Edit.
This will display the Setup dialog, where you can select to edit either the Machine Configuration
(described in the previous section) or Print Settings. You can also display the Print Settings dialog by
pressing the Print Settings button in the Additive menus.
The common global variables found in an Additive post are defined in the Additive Variables section.
9.5.2 onOpen
function onOpen()
The onOpen function is called at the start of post processing and is used to define settings and output
startup blocks. It usually varies from machine to machine.
1. Define settings
2. Output machine and program description
3. Output initial startup codes
function onOpen() {
setFormats(MM); // machine require input code in MM
// output machine and program description
if (typeof writeProgramHeader == "function") {
writeProgramHeader();
}
9.5.3 onSection
function onSection() {
The onSection function is called at the start of each Additive operation and outputs the starting codes for
an Additive operation. It usually varies from machine to machine.
function onSection() {
9.5.4 onClose
function onClose() {
The onClose function is called at the end of the last operation. It is used to output the end-of-program
codes. It usually varies from machine to machine.
function onClose() {
// output end-of-program codes
writeBlock("G4 ; wait");
xOutput.reset();
yOutput.reset();
if (getProperty("printerModel") == "i3mk2mk3") {
writeBlock(gMotionModal.format(1), xOutput.format(0),
yOutput.format(toPreciseUnit(200, MM)), "; home X axis");
} else if (getProperty("printerModel") == "mini") {
writeBlock(gMotionModal.format(1), xOutput.format(0),
yOutput.format(toPreciseUnit(150, MM)), "; home X axis");
}
writeBlock(mFormat.format(84), "; disable motors");
}
Sample onClose Function
9.5.5 onBedTemp
function onBedTemp(temp, wait) {
Arguments Description
temp The bed temperature in Celsius.
wait Set to true when the machine should wait for the bed to warm up.
Additive Capabilities and Post Processors 9-256
CAM Post Processor Guide 11/5/22
The onBedTemp function is called multiple times during a toolpath. At the start of the operation
onBedTemp is called with wait set to false to start heating the bed. It is called a second time prior to the
start of the toolpath with wait set to true so that the machine waits for it to reach the targeted
temperature. It will also be called at the end of the program to turn off the heating of the bed.
The maximum bed temperature is defined in the Limits tab when defining the Machine Configuration in
Fusion 360. The onBedTemp function is common to most additive posts.
9.5.6 onExtruderTemp
function onExtruderTemp(temp, wait, id) {
Arguments Description
temp The extruder temperature in Celsius.
wait Set to true when the machine should wait for the extruder to warm up.
id Extruder number to set the temperature for. The first extruder is 0.
The onExtruderTemp function is called multiple times during a toolpath. At the start of the operation
onExtruderTemp is called with wait set to false to start heating the extruder. It is called a second time
prior to the start of the toolpath with wait set to true so that the machine waits for it to reach the targeted
temperature. It will also be called at the end of the program to turn off the heating of the extruder.
The desired extruder temperature is defined in the Extruder tab of the Print Settings dialog. The
maximum extruder temperature is set in the Extruder Configuration tab when defining the Machine
Configuration in Fusion 360. The onExtruderTemp function is common to most additive posts.
9.5.7 onExtruderChange
function onExtruderChange(id) {
Arguments Description
id Extruder number to activate. The first extruder is 0.
The onExtruderChange function handles a switch between extruders, similar to a tool change in a
subtractive machine. The number of extruders is defined in the Information tab when defining the
Machine Configuration in Fusion 360. The onExtruderChange function is common to most additive
posts.
function onExtruderChange(id) {
if (id > machineConfiguration.getNumberExtruders()) {
error(subst(localize("This printer does not support the extruder '%1'."), integerFormat.format(id)));
return;
}
writeBlock(getCode(commands.extruderChangeCommand), tFormat.format(id));
activeExtruder = id;
forceXYZE();
}
Sample onExtruderChange Function
9.5.8 onExtrusionReset
function onExtrusionReset(length) {
Arguments Description
length Length of the additive material used for the active extruder.
The onExtrusionReset function will be called to reset the length of the used additive material when the
active extruder changes. At the beginning of the program it will be called with a value of 0 and when
switching between one extruder and another it will pass the length of additive material used for the
newly activated extruder. The onExtruderChange function is common to most additive posts.
function onExtrusionReset(length) {
if (getProperty("relativeExtrusion")) {
Additive Capabilities and Post Processors 9-258
CAM Post Processor Guide 11/5/22
eOutput.format(0);
eOutput.format(0);
}
eOutput.reset();
writeBlock(gFormat.format(92), eOutput.format(length));
}
onExtrusionReset Function
9.5.9 onFanSpeed
function onFanSpeed(speed, id) {
Arguments Description
speed The fan speed as a percentage of the default speed in the range of 0-255.
id Extruder number to set the fan speed for, typically the active extruder.
The onFanSpeed function is used to turn on and off the fan used for cooling the extruded material. The
fan is controlled starting at the layer after the number of disabled layers defined in the Cooling tab of the
Print Settings dialog. The onFanSpeed function is common to most additive posts.
9.5.10 onAcceleration
function onAcceleration(travel, printing, retract) {
Arguments Description
travel The travel acceleration, used for positioning moves.
printing Printing acceleration, used for extrusion moves.
retract Retract acceleration, used for extruder retract moves.
The onAcceleration function is invoked when the acceleration changes in an Additive toolpath. The
acceleration values are provided in (velocity_change/seconds)².
onAcceleration Function
9.5.11 onMaxAcceleration
function onMaxAcceleration(x, y, z, e) {
Arguments Description
x The maximum acceleration along X.
y The maximum acceleration along Y.
z The maximum acceleration along Z.
e The maximum acceleration of the extrusion.
The onMaxAcceleration function is invoked when the maximum axis acceleration changes in an
Additive toolpath. The acceleration values are provided in (velocity_change/seconds)².
onMaxAcceleration Function
9.5.12 onJerk
function onJerk(x, y, z, e) {
Arguments Description
x The X-axis jerk.
y The Y-axis jerk.
z The Z-axis jerk.
e The extruder jerk.
The onJerk function is invoked when the axis jerk changes in an Additive toolpath. The jerk control
values are provided in velocity_jerk/seconds.
// jerk control
function onJerk(x, y, z, e) {
writeBlock(mFormat.format(205), "X" + integerFormat.format(x), "Y" + integerFormat.format(y),
Additive Capabilities and Post Processors 9-260
CAM Post Processor Guide 11/5/22
"Z" + integerFormat.format(z), "E" + integerFormat.format(e));
}
onJerk Function
9.5.13 onLayer
function onLayer(layer) {
Arguments Description
Layer Current layer being printed.
The onLayer function is called for every printed layer and passes in the active layer. It can be used to
output a comment prior to the toolpath for each layer and/or to increment a counter on the machine
control to show the printing progress. The onLayer function is common to most additive posts.
function onLayer(num) {
if (typeof executeTempTowerFeatures == "function") {
executeTempTowerFeatures(num);
}
writeComment("Layer : " + integerFormat.format(num) + " of " +
integerFormat.format(layerCount));
}
Sample onLayer Function
9.5.14 onParameter
function onParameter(name, value) {
Arguments Description
name Parameter name.
value Value stored in the parameter.
The onParameter function behaves the same as it does in a Subtractive post processor, but there is one
parameter that is specific to Additive machines. This is the feedRate parameter that defines the travel
speed that the machine will move when positioning without extruding material and for extruder changes.
The onParameter function is common to all additive posts.
Arguments Description
_x, _y, _z The tool position.
The onRapid function handles positioning moves, which do not extrude the additive material. The
output of the onRapid function usually outputs a single block for the positioning move. The onRapid
function is common to all additive posts.
9.5.16 onLinearExtrude
Arguments Description
_x, _y, _z The tool position.
_f The feedrate.
_e Length of additive material to extrude during the move.
The onLinearExtrude function handles linear moves that extrude the additive material. The tool
position, feedrate and length of material to extrude are passed as the arguments. The onLinearExtrude
function is common to all additive posts.
9.5.17 onCircularExtrude
function onCircularExtrude(_clockwise, _cx, _cy, _cz, _x, _y, _z, _f, _e) {
Argument Description
_clockwise Set to true if the circular direction is in the clockwise direction, false if
counter-clockwise.
_cx, _cy, _cz Center coordinates of circle.
_x, _y, _z Final point on circle
_f The feedrate.
_e Length of additive material to extrude during the move.
The onCircularExtrude function handles circular moves that extrude the additive material. The tool
circle parameters, position, feedrate and length of material to extrude are passed as the arguments. The
onCircularExtrude function is common to all additive posts.
function onCircularExtrude(_clockwise, _cx, _cy, _cz, _x, _y, _z, _f, _e) {
var x = xOutput.format(_x);
var y = yOutput.format(_y);
var z = zOutput.format(_z);
var f = feedOutput.format(_f);
var e = eOutput.format(_e);
var start = getCurrentPosition();
var i = iOutput.format(_cx - start.x, 0);
var j = jOutput.format(_cy - start.y, 0);
switch (getCircularPlane()) {
case PLANE_XY:
writeBlock(gMotionModal.format(_clockwise ? 2 : 3), x, y, i, j, f, e);
break;
default:
linearize(tolerance);
}
}
onCircularExtrude Function
9.6.1 getExtruder
function getExtruder(id) {
Arguments Description
id Extruder number to get information about.
The getExtruder function returns the Extruder variable, which includes information about the specified
extruder. Unlike the entry functions where the extruder base is 0, in the getExtruder function the first
extruder is referenced as id=1, the second as id=2, etc.
9.6.2 isAdditive
function isAdditive() {
Returns true if any of the operations in the part are Additive in nature.
9.6.3 executeTempTowerFeatures
function executeTempTowerFeatures(num) {
Arguments Description
num The event that triggered the need to change the temperature. It is set to 1 on
the first call and then successive numbers on the remaining calls.
The executeTempTowerFeatures function is defined in the post processor and sets the temperature based
on the event specified by num. The initial value is 1 and ascends by 1 in each successive call. The
executeTempTowerFeatures function is common to all additive posts that support Temperature Tower
features.
var nextTriggerValue;
var newTemperature;
var maximumExtruderTemp = 260;
function executeTempTowerFeatures(num) {
if (settings.maximumExtruderTemp != undefined) {
You will see the ADDITIVE tab on the MANUFACTURE ribbon. Selecting this tab will display the
Additive menus.
Once you find your machine you will need to select the post processor that corresponds to this machine.
You can select/change the post processor by right clicking on the Autodesk Generic DED machine and
choosing Select a post.
The Post Library dialog will then be displayed. Select the Fusion 360 library and check the Additive
box to display only the post processors supporting the Additive capabilities. For training purposes, you
will select the Deposition sample post processor. This post processor is not a full post processor, but
Deposition Capabilities and Post Processors 10-267
CAM Post Processor Guide 11/5/22
rather a template used to modify an existing post processor to include Deposition support. The post
modification will be discussed later in this chapter.
You can also create linked folders on your computer to store both the machines and post processors.
You do this by right clicking on the Linked menu and selecting the Link Folder menu. A browser will
be displayed allowing you to select a folder to place your machines/posts.
To create an Additive setup, press the Setup menu, change the Operation Type to Additive, and select the
configuration for your machine by pressing the Select… button under Machine.
If you have not already assigned a post processor to this machine you will need to do so now. Do this
by pressing the Edit… button under the Machine prompt. The Machine Configuration will display,
select the Post Processing menu, press the … button and then select the Deposition sample post
processor.
Feel free to rename the new setup to Deposition so you know that this is a deposition operation. If you
are going to do both deposition and subtractive operations in the same model, then you will want to
move the Deposition setup above the Subtractive setup.
A proper tool should be selected for depositing the material. Fusion 360 supports Electric Arc Wire,
Laser Powder, and Laser Wire Deposition tools. If you don’t already have deposition tools defined, you
can create one using the normal method for creating a tool by pressing the + menu in the Select Tool
form.
You will need to select the base the Feature being built lies on and the Feature itself. You can also
generate multi-axis deposition moves by specifying a Forward Tilt and/or a Sideways Tilt.
Deposition Capabilities and Post Processors 10-270
CAM Post Processor Guide 11/5/22
For this exercise you can select the bottom surface of the keychain as the Base and the body of the
keychain as the Feature. The remaining tabs/fields in the Feature Construction form are similar to other
milling operations.
To simulate the Deposition toolpath press the Simulate button in the ACTIONS menus. Deposition
toolpaths simulate in the same manner as Subtractive toolpaths, but it is recommended that you place the
cursor over the green slide bar at the bottom of the window, hold down the left mouse button, and move
the mouse to the left and right to visualize the Deposition process.
The sample deposition post processor is broken up into separate sections, the first being code that will be
placed into existing functions, new code to be added to your post processor, and code that is common to
all other post processors used to create the sample output.
case TOOL_DEPOSITING_ELECTRIC_ARC_WIRE:
Deposition Capabilities and Post Processors 10-273
CAM Post Processor Guide 11/5/22
// insert startup codes for electric arc wire here
commands = {
deposition : {on:mFormat.format(101), off:mFormat.format(103)},
processEquipment: {
on: [ // commands to turn on process equipment
formatWords(gFormat.format(90), formatComment("ABSOLUTE MODE")),
formatWords(gFormat.format(300), "F" + processParameter.gasFlowRate,
formatComment("SHIELD GAS FLOW RATE")),
formatWords(gFormat.format(301), "V" + processParameter.arcCurrent,
formatComment("ARC VOLTAGE")),
formatWords(gFormat.format(302), "A" + processParameter.arcVoltage,
formatComment("ARC CURRENT")),
formatWords(gFormat.format(303), "S" + processParameter.wireSpeed,
formatComment("WIRE SPEED")),
formatWords(mFormat.format(304), formatComment("PROCESS ON"))],
off: [ // commands to turn off process equipment
formatWords(mFormat.format(305), formatComment("PROCESS OFF")),
formatWords(gFormat.format(303), "S0", formatComment("WIRE STOP")),
formatWords(gFormat.format(300), "F0000", formatComment("GAS OFF"))]
}
};
break;
Commands to Turn On and Off Deposition
Function Modification
onSection Add code to define the deposition commands, write the deposition
operation head, and enable the deposition operation.
onSectionEnd Add code to disable the deposition operation.
onMovement Add a call to onMovementDeposition for a deposition operation.
Modification of Existing Functions for Deposition Support
function onSection() {
// #### Add the code below into the onSection function of your postprocessor ####
if (isDepositionOperation()) {
setDepositionCommands(); // setup for deposition process parameters
writeDepositionHeader(tool);
writeProcessEquipmentCommands(true);
}
// Important note, make sure that you disable the spindle speed output for deposition
// operations in your postprocessor.
Deposition Capabilities and Post Processors 10-274
CAM Post Processor Guide 11/5/22
}
Enable a Deposition Operation in onSection
function onSectionEnd() {
// #### Add the code below into the onSectionEnd function of your postprocessor ####
if (isDepositionOperation()) {
writeProcessEquipmentCommands(false);
}
}
Disable a Deposition Operation in onSectionEnd
// #### If your postprocessor does not have the onMovement function, you have to add the
// entire function below. ####
function onMovement(movement) {
// #### Add the code below into the onMovement function of your postprocessor. ####
if (isDepositionOperation()) {
onMovementDeposition(movement);
}
}
Call onMovementDeposition from onMovement
Index 276
Autodesk CAM Post Processor Guide 11/5/22
Index
do/while ........................................... 3-70 getABCByPreference ......... 4-119, 7-198
doesToolPathFitWithinLimits ....... 4-121 getCircularCenter ........................... 4-156
download a post ................................. 1-3 getCircularChordLength ................ 4-156
drilling cycles................................. 7-219 getCircularNormal ......................... 4-156
drillingSafeDistance ...................... 4-162 getCircularPlane ............................ 4-156
dump.cps ..................4-140, 5-180, 6-184 getCircularRadius .......................... 4-156
getCircularStartRadius ................... 4-156
E getCircularSweep ........................... 4-156
editor ................................1-8, 1-11, 2-23 getCommonCycle ............... 4-166, 7-219
else ................................................... 3-63 getCoolantCodes ................. 4-113, 8-230
enableMachineRewinds ................. 7-193 getCurrent ........................................ 4-92
entry function ................................. 6-184 getCurrentDirection ............ 4-119, 7-198
Entry functions...................... 4-73, 9-253 getCurrentPosition ......................... 4-156
Euler ............................................... 4-123 getEuler2 ............................. 4-117, 4-123
Euler Angle Order............................ 4-117 getExtruder ......................... 9-251, 9-264
Euler angles ................................... 4-116 getFinalToolAxisABC ................... 7-198
eulerConvention ............................. 4-116 getFirstTool......................... 4-111, 4-132
executeManualNC ......................... 5-178 getFramePosition ........................... 4-125
executeTempTowerFeatures .......... 9-264 getGlobalFinalToolAxis ................ 7-198
expanded cycles .................. 4-160, 4-162 getGlobalInitialToolAxis ............... 7-198
expandManualNC .......................... 5-175 getGlobalParameter ....................... 4-141
expression ............ 3-61, 3-66, 3-68, 3-73 getGlobalZRange ........................... 4-103
expression operators ........................ 3-62 getHeaderDate ............................... 4-102
extension .......................................... 4-75 getHeaderVersion .......................... 4-102
Extruder .............................. 9-250, 9-251 getHelicalDistance ......................... 4-156
getHelicalOffset ............................. 4-156
F getHelicalPitch .................... 4-156, 4-157
getId ............................................... 4-127
Feature Construction ....... 10-265, 10-270 getInitialToolAxisABC....... 7-196, 7-198
Feedrate............................... 4-153, 9-263 getLinearMoveLength ........ 7-213, 7-215
fixed settings ........................... 4-98, 4-99 getMinimumValue ........................... 4-88
for ...................................3-68, 3-69, 3-70 getMultiAxisMoveLength ............. 7-212
Force tool change ........................... 4-110 getNextSection ............................... 4-133
forceABC ....................................... 4-171 getNextTool ........................ 4-111, 4-131
forceAny ........................................ 4-171 getNumberOfSections4-103, 4-105, 4-127, 4-
forceFeed ....................................... 4-171 141
forceMultiAxisIndexing ................ 4-116 getNumberOfTools ........................ 4-103
forceXYZ ....................................... 4-171 getOptimizedPosition .................... 7-202
format .4-86, 4-87, 4-90, 4-92, 4-95, 4-97 getOptimizedTCPMode ................. 7-198
formatComment ............................. 4-138 getParameter .................................. 4-140
FormatNumber ........................ 4-87, 4-90 getPolarPosition ............................. 7-215
function ................ 3-47, 3-66, 3-71, 3-72 getPositionU ....................... 4-156, 4-158
fused filament fabrication .............. 9-239 getProbingArguments .................... 8-225
getProperty ............................. 4-81, 4-85
G
getRadialMoveLength ................... 7-213
G-code................................................ 1-1 getRadialToolTipMoveLength ...... 7-213
Geometry Probing .......................... 8-231
Index 277
Autodesk CAM Post Processor Guide 11/5/22
Index
getResultingValue..........3-68, 4-88, 4-92 isLastCyclePoint ............................ 4-166
getSection .... 4-103, 4-105, 4-126, 4-141 isLastSection .................................. 4-133
getTool ........................................... 4-105 isMillingCycle ............................... 4-130
getToolTypeName ......................... 4-103 isMultiAxis .................................... 4-123
getWorkPlaneMachineABC4-118, 4-123 isMultiAxisConfiguration ... 4-123, 7-198
gFeedModeModal .......................... 7-211 isNewWorkOffset .......................... 4-128
Global Section ...................... 4-74, 9-254 isNewWorkPlane ................ 4-107, 4-128
global variable ...............3-47, 4-74, 4-99 isOptimizedForMachine ..... 7-196, 7-198
gRotationModal ............................. 8-227 isPolarModeActive ........................ 7-215
groupDefinitions ..................... 4-80, 4-83 isProbeOperation ........................... 4-130
isProbingCycle ............................... 4-166
H isSignificant ..................................... 4-88
hasGlobalParameter ....................... 4-141 isSpindleSpeedDifferent ................ 4-128
hasParameter .................................. 4-140 isSpiral ........................................... 4-157
helical interpolation ............ 4-156, 4-157 isTappingCycle .............................. 4-129
helical move ..................................... 4-75 isToolChangeNeeded .......... 4-107, 4-127
high feedrate ....................... 4-145, 4-149
J
highFeedMapping ............................ 4-75
highFeedrate .................................... 4-75 JavaScript ......................................... 3-45
home position................................. 4-172
HSM Post Processor Editor ............. 3-46 K
kernel settings .................................. 4-75
I
if 3-63, 3-65 L
incremental ...................................... 4-94 Laser ................................................ 1-22
indentation ....................................... 3-46 layerCount...................................... 9-250
Initial Position ..................... 4-110, 4-125 legal.................................................. 4-75
insertToolCall ..................... 4-110, 4-133 Length Offset ................................. 4-110
Inspect Surface............................... 8-234 linear scale ..................................... 7-199
intermediate file ...................... 1-1, 9-253 linearize.......................................... 4-157
Inverse Time ....................... 7-209, 7-215 linked folders .................... 9-241, 10-268
inverseTimeOutput ........................ 7-211 local variables .................................. 3-47
invokeOnCircular .......................... 4-159 log .................................................. 6-187
invokeOnLinear ............................. 4-148 longDescription.............................. 4-102
invokeOnLinear5D ........................ 4-152 looping statements ........................... 3-68
invokeOnRapid .............................. 4-147
invokeOnRapid5D ......................... 4-150 M
is3D ................................................ 7-198
isAdditive ....................................... 9-264 machine configuration ................... 7-189
isAxialCenterDrilling .................... 4-129 Machine Configuration1-13, 4-82, 7-190, 9-240,
isDepositionOperation ................... 4-131 9-248, 10-266
isDrillingCycle ............................... 4-128 machineConfiguration4-102, 4-103, 9-250
isFirstCyclePoint............................ 4-166 machining plane ............................. 4-159
isFullCircle .................................... 4-156 Manual NC..................................... 5-180
isHelical ......................................... 4-157 Manual NC command4-99, 4-134, 4-136, 4-137,
isInspectionOperation .................... 4-130 4-139, 4-140
Index 278
Autodesk CAM Post Processor Guide 11/5/22
Index
Manual NC Command ................... 5-174 onCycle .......................................... 4-159
mapToWCS ..................................... 4-75 onCycleEnd ......................... 4-168, 8-227
mapWorkOrigin ............................... 4-76 onCyclePoint4-160, 7-219, 8-223, 8-226, 8-235
Math Object ..................................... 3-49 onDwell............................... 4-139, 5-176
Matrix .............................................. 3-56 onExtruderChange ......................... 9-258
Matrix Object Assignments ............. 3-56 onExtruderTemp ............................ 9-257
Matrix Object Attributes .................. 3-57 onExtrusionReset ........................... 9-258
Matrix Object Functions .................. 3-58 onFanSpeed .................................... 9-259
matrixes.......................................... 6-186 onImpliedCommand ........... 4-135, 4-137
maximumCircularRadius ...... 4-76, 4-155 onJerk ............................................. 9-260
maximumCircularSweep4-76, 4-99, 4-155 onLayer .......................................... 9-261
mill/turn ........................................... 1-20 onLinear ....... 4-143, 4-146, 4-147, 4-148
milling .............................................. 1-19 onLinear5D4-151, 4-153, 7-196, 7-211, 7-219
minimumChordLength ......... 4-76, 4-155 onLinearExtrude ............................ 9-262
minimumCircularRadius....... 4-76, 4-155 onManualNC............5-175, 5-177, 5-178
minimumCircularSweep ....... 4-76, 4-155 onMaxAcceleration........................ 9-260
minimumRevision............................ 4-76 onMovement .................................. 4-145
Modal Groups .................................. 4-95 onMoveToSafeRetractPosition ...... 7-207
ModalGroup ..................................... 4-96 onOpen .......................4-99, 7-189, 9-255
model origin ..................................... 4-75 onOrientateSpindle ........................ 4-143
MoveLength ................................... 7-213 onParameter4-139, 4-142, 5-176, 5-180, 8-228,
movement ...................................... 4-145 9-261
moveToSafeRetractPosition .......... 7-208 onPassThrough ................... 5-177, 5-183
multi-axis1-16, 3-56, 4-149, 4-151, 7-188 onRadiusCompensation ................. 4-143
multi-axis ....................................... 4-100 onRapid ........ 4-143, 4-145, 4-147, 9-262
Multi-Axis Feedrates .......... 7-209, 7-213 onRapid5D ... 4-149, 4-150, 7-196, 7-219
onReturnFromSafeRetractPosition 7-207
N onRewindMachine ......................... 4-169
NC file extension ............................. 4-75 onRewindMachineEntry ................ 7-207
NC Program ............................ 1-11, 4-77 onRotateAxes ................................. 7-207
next tool ......................................... 4-111 onSection .................4-106, 4-134, 9-255
number .................................... 3-48, 3-72 onSectionEnd4-107, 4-108, 4-133, 4-134, 8-230
Number Objects ............................... 3-48 onSpindleSpeed ............................. 4-143
numberOfExtruders ....................... 9-250 onTerminate ................................... 4-135
Operation Comment....................... 4-108
O Operation Notes ............................... 4-109
Operation properties ........................ 4-82
object....................................... 3-53, 3-72 Operation Properties ........................ 1-13
offset tables and heads ................... 7-199 operators .......................................... 3-61
onAcceleration ............................... 9-259 optimize3DPositionsByMachine ... 4-122
onBedTemp.................................... 9-257 optimizeMachineAngles2 .............. 7-194
onchange .......................................... 4-91 optimizeMachineAnglesByMachine7-194
onCircular ................4-143, 4-153, 4-159 optional skip................................... 4-169
onCircularExtrude.......................... 9-263 output units ...................................... 4-76
onClose ....................4-134, 4-135, 9-256 OutputVariable ....................... 4-90, 4-91
onCommand4-136, 4-143, 4-162, 5-176, 5-179
onComment..............4-137, 5-176, 6-188
Index 279
Autodesk CAM Post Processor Guide 11/5/22
Index
P RS-274D Sample Multi-axis Post Processor ... 7-
188
parametric feedrates ....................... 4-145
parseFloat ......................................... 3-49 S
parseInt ............................................ 3-49
partCount ....................................... 9-250 section ............................................ 4-126
pendingRadiusCompensation ........ 4-144 seed post........................................... 1-17
permittedCommentChars ............... 4-138 sequence number ........................... 4-169
pivot point ...................................... 7-200 setCoolant ...................................... 4-113
Plasma .............................................. 1-22 setCurrentABC .............................. 7-198
Polar interpolation ......................... 7-213 setCurrentPositionAndDirection.... 7-215
polarDirection ............................... 7-216 setMachineConfiguration .............. 7-194
post kernel ........................................ 3-47 setMultiAxisFeedrate ..................... 7-193
Post Library ....................................... 1-2 setPolarFeedMode ......................... 7-216
post processor2-40, 9-240, 9-244, 9-249, 10- setPolarMode ................................. 7-215
267, 10-269 setPrefix ........................................... 4-97
post processor documentation.......... 3-45 setProbeAngle ................................ 8-225
Post Processor Forum ............... 1-2, 1-16 setProbeAngleMethod ................... 8-225
Post Processor Ideas ................. 1-2, 1-16 setProperty ....................................... 4-85
Post Properties ................................. 2-41 setSingularity ................................. 7-204
preloadTool .................................... 4-111 setSuffix ........................................... 4-97
Print Settings ............9-240, 9-244, 9-254 settings ................................ 9-250, 9-252
printTime ....................................... 9-250 setToolLength ................................ 7-201
probeMultipleFeatures ................... 8-233 setup .......................4-142, 9-243, 10-268
probeWorkOffset ........................... 4-131 setVirtualTooltip ................. 7-192, 7-202
Probing ........... 1-22, 8-220, 8-231, 8-234 setWordSeparator ............... 4-100, 4-169
program comment .......................... 4-100 setWorkPlane ................................. 4-123
program name ...... 1-8, 1-11, 4-76, 4-100 setWriteInvocations .............. 2-41, 6-185
programComment .......................... 4-101 setWriteStack ........................ 2-41, 6-186
programName ................................ 4-101 showNotes............................ 4-104, 4-109
programNameIsInteger ......... 4-76, 4-100 simulate ............................. 9-247, 10-271
properties ............. 1-9, 1-11, 4-79, 9-249 singleLineCoolant .......................... 4-112
Property Table ..... 3-53, 4-77, 4-98, 4-99 singularity ...................................... 7-203
protecedProbeMove ....................... 8-225 spatial ............................................... 3-49
spindle codes .................................. 4-112
R spindleOrientation.......................... 4-162
spindleSpeedDwell ........................ 4-162
radians ................................... 3-49, 7-189
spiral interpolation ......................... 4-157
radius compensation4-145, 4-147, 4-151, 4-153
spiral move....................................... 4-75
range ................................... 7-199, 7-206
stock transfer .................................... 1-21
rapid ................................................. 4-75
strategy ......................4-83, 4-132, 4-133
real value .......................................... 3-68
string ..............................3-46, 3-49, 3-72
repositionToCycleClearance .......... 4-166
String Object Functions ................... 3-50
retract .................................. 4-108, 4-125
switch ...................................... 3-64, 3-70
return ....................................... 3-71, 3-72
rotary axes ...................................... 7-189 T
Rotary Axis Order.......................... 7-191
rotary scale ..................................... 7-199 tapping cycles ................................ 4-167
Index 280
Autodesk CAM Post Processor Guide 11/5/22
Index
TCP ................................................ 7-209 Vector .............................................. 3-53
Template ........................................ 5-183 Vector Attributes ............................. 3-54
toDeg................................................ 3-49 Vector Object Functions .................. 3-55
tolerance .....................4-76, 4-155, 4-157 vectors ............................................ 6-186
tool axis ....................4-149, 4-151, 7-203 virtual tool tip ................................ 7-202
Tool change ................................... 4-110 Visual Studio Code .......................... 2-23
tool length offset ............................ 4-125
toolZrange ...................................... 4-132 W
toolZRange .................................... 4-111 Waterjet ............................................ 1-22
toPreciseUnit......................... 3-49, 4-170 WCS ...........................4-75, 4-113, 4-133
toRad ................................................ 3-49 WCS Probing ................................. 8-221
toUnit ............................................... 3-49 wcsDefinitions ............................... 4-113
try/catch ........................................... 3-67 while ................................................ 3-69
typeof ............................................... 3-66 Work Coordinate System4-107, 4-113, 8-221
Work Plane4-76, 4-107, 4-115, 4-118, 4-123, 4-
U 133
undefined ......................................... 3-47 workOffset ..................................... 4-106
unit ..................... 1-8, 1-11, 4-100, 4-106 writeBlock...................................... 4-169
useABCPrepositioning .................. 4-116 writeComment4-101, 4-102, 4-103, 4-138, 6-
useMultiAxisFeatures .................... 4-116 188
usePolarMode ................................ 7-216 writeDebug .................................... 6-188
User Settings .................................... 2-26 writeln ................................. 4-169, 6-187
writeNotes ........................... 4-104, 4-140
V writeRetract .. 4-107, 4-135, 4-172, 7-193
validate ............................................. 3-67 writeSectionNotes .......................... 4-109
var .................................................... 3-47 writeSetupNotes ............................. 4-104
variable ..... 3-47, 3-61, 3-66, 3-71, 9-250
Index 281
Autodesk CAM Post Processor Guide 11/5/22