CNC Simulator Pro

user guide
×
Menu
Index

6.3. $-commands and regions

These are the default standard codes used by default by our virtual machines. Please note that customized machines may have other codes and formats.
 
$-commands are simulation commands that control various aspects of the simulation and are not related to CNC codes. It's important to note that $-commands should not be transferred to a real CNC controller. You can write $-commands within parentheses, and the simulator will still read them. To make a block of $-commands collapsible and hidden from the CNC code, you can encapsulate them in a region.
 
 
Do you notice the little - (minus) sign before the region command at the first line? If you click it, the region will be collapsed, hiding the block of $-commands.
 
A collapsed region will show three dots and a + (plus) sign. If you click the plus sign, the region will expand.
 
You can see what a collapsed region hides without expanding it by hovering the mouse pointer over it.
 
 
When you open a CNC program from the disk, it always loads with its regions collapsed.
 
In the following table, we provide a list of built-in $-commands along with a brief explanation of their functions. It is important to note that many of these commands are not commonly used and are designed for special use in examples or for creating portable programs. To help you identify the most useful commands, we have highlighted the ones you are likely to use in red. However, if you are not an advanced user and do not need to learn all aspects of CNC Simulator Pro, you can skip over the commands highlighted in black. Even among the red commands, not all of them are essential to know. At a minimum, you should be familiar with the $AddRegPart command, which is required for placing workpieces on the table or in the chuck. If you are using CNC Simulator Pro solely for 3D printing, you can ignore the $-commands altogether.
 
$-command
 
Explanation
Format
Example
Machine type
$AddRegPart
Puts a workpiece from the user-defined workpiece registry in the Inventory Browser (F2) on the machine table (or in the chuck). The first number is the registry index for the workpiece you want to place. The three following numbers are the X, Y, and Z coordinates for where you want to put the workpiece. If omitted, it will be placed at the machine zero.
$AddRegPart # [#][#][#]
$AddRegPart 1 30 30
All machines except the 3D Printer
$AddEmbeddedRegPart
Puts a workpiece from the fixed embedded workpiece registry on the table. See $AddRegPart above for further explanation.
$AddEmbeddedRegPart # [#][#][#]
$AddEmbeddedRegPart 1 25 10
All machines except the 3D Printer
$AddDefinedPart
Puts a predefined workpiece on the table. Use $AddDefinedPart to define workpieces in the program.
$AddDefinedPart # [#][#][#]
$AddDefinedPart 1 10 10
Milling and Cutting machines
$BlockSpindleRot
Will block on-screen spindle rotation. This can be useful in the unlimited lathe if the visual rotation of the workpiece is not desired.
$BlockSpindleRot
$BlockSpindleRot
Lathe machines
$Inches
 
Enforce the use of Inch units. (To set millimeters or inches units, open the program settings dialog.)
$Inches
$Inches
All machines
$Millimeters
 
Enforce the use of Millimeter units. (To set millimeters or inches units, open the program settings dialog.)
$Millimeters
$Millimeters
All machines
$MillStock
 
 
Creates a mill stock material.
 
Length, Width, Height, Origin X, Origin Y, Origin Z
$MillStock # # # # # #
$MillStock 100 100 40 0 0 40
Milling machines
$MillTool
Creates a milling tool.
 
Diameter, Radius, Length
 
If radius = diameter/2, a ball mill is created. Otherwise, it will be flat.
 
$MillTool # # #
$MillTool 10 0 50
Milling machines
$MillToolDrill
Creates a drill tool.
 
Diameter, Tip angle, Length
$MillToolDrill # # #
$MillToolDrill 10 60 50
Milling machines
$SetView
$SetView is a special command to set the 3D view during the simulation. It should not be programmed manually as it contains too many parameters but rather be created using the menu action Tools – Misc - Insert Command - $SetView.
 
 
$SetView # # # # # # # # # # # # # # # #
$SetView 0.008132864,-
0.001045043,
0.002846713,
0,0.002991813,
0.004094983,
-0.007044114,0,
-0.000494922,
0.007581451,
0.00419715,
0,-0.1170392,
-0.01551898,
0.1104939,1
All machines
$Message
Displays a message on the 3D view during the simulation. The first parameter is a text string of the message to display. The next parameter is the number of seconds to show the message.
$Message $ #
$Message "Hello World!" 5
All machines
$Cutting
Set the solid workpiece cutting values, at runtime, in percent. Parameters are: FromLeft, FromRight, FromFront, FromBack, and FromTop.
$Cutting # # # # #
$Cutting  0 52 34 100 100
All machines except lathes
$Cutting
Set workpiece cutting. Parameters are: Left, Right, Open.
To show the whole part, left should be 0 and Right should be 100.
The last parameter is 0 to show the workpiece closed and 1 to show the inside.
$Cutting # # #
$Cutting 0 100 1
Lathe machines
$Pause
Will pause the simulation for a given number of milliseconds.
$Pause #
$Pause 4000
All machines
$StartStopWatch
Starts the internal stopwatch to measure the time for an operation. Please note that the time measured is simulation time and not machining time.
$StartStopWatch
$StartStopWatch
All machines
$ShowStopWatch
Stops the internal stopwatch and shows the time that has elapsed since the $StartStopWatch command was executed.
$ShowStopWatch
$ShowStopWatch
All machines
$Lathe
Enforces the use of a lathe machine. You will see an alarm if you run a program with this command on a machine that is not a lathe.
$Lathe
$Lathe (Alarm if not lathe machine)
Lathe machines
$Mill
Enforces the use of a milling machine. You will see an alarm if you run a program with this command on a machine that is not a milling machine.
$Mill
$Mill (Alarm if not a milling machine)
Milling machines
$SetupTool
This command is used to directly setup and use a milling tool without using the user or embedded registries. Parameters are:  TipAngle, ShaftDiameter, ShaftLength, ToolDiameter, ToolLength, and ToolTipType (0=Flat, 1=Ball, 2=Pointed)
$SetupTool # # # # # #
$SetupTool 50.00 3.00 10.00 1.00 10.00 2
Milling machines
$OverrideBufferQualitySetting
 
This special command is used to override the resolution setting for the solid buffer. The value given is the number of 3D pixels (voxels) per millimeter. A value of 1 will make each 3D pixel 1 cubic millimeter big. A value of 10 will make each 3D pixel 0.1 mm3 big. A value of 1 will create ugly results but will run fast. On the other hand, a value of 10 will create high-resolution workpieces but will run slow. We do not recommend using values higher than 10 as you could easily run out of memory due to huge material buffer allocation. Important: This command must come before the $AddRegPart command.
$OverrideBufferQualitySetting #
$OverrideBufferQualitySetting 10
All machines
$AddMillPart
This command is used to directly setup and use a milling workpiece without using the user or embedded registries. Parameters are: SizeX, SizeY, SizeZ, Xpos, Ypos, Zpos, PartColR, PartColG, PartColB, TopColR, TopColG, TopColB, MaterialStyle
Colors are in the range 0 - 255, where 255 is full brightness.
Material types are: 1 Plain, 2 Metal, 3 Plastic, 4 Wood, and 5 Semi-transparent.
$AddMillPart # # # # # # # # # # # # #
$AddMillPart 51.00 36.00 0.50 15.00 80.00 9.55 128 128 128 218 165 32 1
Milling machines
$DefineLatheWorkpiece
Define a lathe workpiece that can be fetched by using the command $AddDefinedPart. Parameters are: NameAndMaterial, Index, Length, Diameter, Inner diameter.
$DefineLatheWorkpiece $ # # # #
$DefineLatheWorkpiece "N:Part:M:Aluminium" 0 100.00 70.00 0.00
Lathe machines
$DefineMillWorkpiece
Define a mill workpiece that can be fetched by using the command $AddDefinedPart. Parameters are: NameAndMaterial, Index, SizeX, SizeY, SizeZ
$DefineMillWorkpiece $ # # # #
$DefineMillWorkpiece "N:Demo part 1 mm:M:Aluminium" 1 140.00 160.00 30.00
Milling and cutting machines
$DefineMaterial
Defines a material to be used by defined workpieces. Parameters are: MatrlName, Index, PartColR, PartColG, PartColB, TopColR, TopColG, TopColB, MaterialStype
Colors are in the range 0 - 255, where 255 is full brightness.
Material types are: 1 Plain, 2 Metal, 3 Plastic, 4 Wood, and 5 Semi-transparent.
$DefineMaterial $ # # # # # # # #
$DefineMaterial "N:Aluminium" 1 160 160 170 0 0 0 1
Milling machines
$From
Starts simulation from a given position. Parameters are: Xpos, Zpos in lathes and Xpos, Ypos, Zpos in milling machines.
$From # # (lathe)
$From # # # (milling)
 
Lathe and milling machines
$DefineMillTool
Defines a milling tool that can be fetched by the DT code letters. Parameters are: ToolName, Index, TipAngle, ShaftDiam, ShaftLength, ToolDiam, ToolLength, ToolTipType (0=Flat, 1=Ball, 2=Pointed)
$DefineMillTool $ # # # # # # #
$DefineMillTool "N:Drill mm" 5 120.00 0.00 0.00 8.00 50.00 2
Milling machines
$Toolpaths
Turn on or off the display of the tool paths during the simulation. (1=on, 0=off).
$Toolpaths #
$Toolpaths 1
All machines except the 3D Printer
$SetCuttingWidth
Used in cutting machines to define the cutting width.
$SetCuttingWidth #
$SetCuttingWidth 2
Cutting machines
$UseMaterial
Tells the simulator to override the material for the workpiece and use the specified one instead. The material must exist in the materials registry in the Inventory (F2) to avoid an alarm.
$UseMaterial $
$UseMaterial "ABS"
All machines
$UseEmbeddedMaterial
Tells the simulator to override the material for the workpiece and use the specified embedded one instead. The material must exist in the embedded materials registry to avoid an alarm.
$UseEmbeddedMaterial $
$UseEmbeddedMaterial "Steel"
All machines
$InvertLathePart
Flips the lathe workpiece in the chuck so that the machine can continue machining the other side of it.
$InvertLathePart
$InvertLathePart
Lathe machines
$LatheStock
 
 
 
Creates a lathe stock material.
 
Length, Diameter, Inner diameter, Z zero point
$LatheStock # # # #
$LatheStock 100 40 0 0
Lathe machines
$LatheToolButton
 
 
Creates a lathe button tool. Parameters are: Radius, Res, Res, Res, Res
(Res = not in use, reserved for future use.)
Note: Creates only the cutting insert, not the holder.
$LatheToolButton # # # # #
$LatheToolButton 10 0 0 0 0
 
Lathe machines
$LatheToolDrill
 
 
Creates a lathe drill tool. Parameters are: Diameter, Tip angle, Length
$LatheToolDrill # # #
$LatheToolDrill 10 60 60
Lathe machines
$LatheToolGroove
 
 
Creates a lathe groove tool. Parameters are: Res, Res, Length, Width, Res, Res, OA, Res
 
(Res = not in use, reserved for future use.)
OA = cutter angle (90 normally)
Note: Creates only the cutting insert, not the holder.
$LatheToolGroove # # # # # # # #
$LatheToolGroove 0 0 10 5 0 0 90 0
Lathe machines
$LatheToolStandard
 
Creates a standard lathe tool. Parameters are: BA, A, Res, IC, Res
 
(Res = not in use, reserved for future use.)
Note: Creates only the cutting insert, not the holder.
$LatheToolStandard # # # # #
$LatheToolStandard 15 45 0 14 0
Lathe machines
$LatheToolThread
 
Creates a lathe threading tool. Parameters are: Tip angle, Length, Width, OA
 
OA = cutter angle (90 normally)
Note: Creates only the cutting insert, not the holder.
$LatheToolThread # # # #
$LatheToolThread 60 10 10 90
Lathe machines
$AbsoluteCenters
Circle and arc centers are normally entered as incremental values. This command tells the simulator to expect absolute circle and arc center values.
0/1 = enable/ disable
$AbsoluteCenters #
$AbsoluteCenters 0
All machines
$SetG28pos
Set custom position for G28.
Important to use in the "unlimited" machines as they have their default zero position very far away.
$SetG28pos # # #
$SetG28pos 100 0 30
Milling and turning machines
$SetToolChangePos
Set custom tool change position.
$SetToolChangePos # # #
$SetToolChangePos 10 10 100
All machines except the 3D printer
$DefineDoffsetDiameter
Define a D offset in program.
$DefineDoffsetDiameter # #
$DefineDoffsetDiameter 1 10.2
 
Milling machines
$ReadTasDefinedTool
When your program has defined tools (for example, in programs created by SimCam), you call these tools with "DT". Using this command, you can skip the D and only use T, followed by the tool index number. For example, "T25". The simulator will treat all T values as defined tools.
$ReadTasDefinedTool
$ReadTasDefinedTool
Milling and turning machines
$RotateWorkpiece
This command rotates the workpiece around its Z-axis.
 
$RotateWorkpiece
$RotateWorkpiece
Milling machines
$Color
This command sets the surface color. Any new surface that gets exposed by a milling operation will have this color. The command expects three parameters: Amount of Red, amount of Green, and amount of Blue. Values are given in the range 0 to 255, where 255 is the brightest. $Color 0 0 0 will make the surface black, and $Color 255 255 255 will make it white. For mixing of other colors, Google "RGB Color Picker".
$Color R G B
$Color 200 125 90
Milling machines
$AutoColorMode
This command can be used to let the simulator automatically set surface colors depending on the tool index or the cutting depth.
There are four modes:
 
0. No automatic coloring (normal mode)
1. Color by tool index
2. Color by cutting depth
3. Color gradient, deeper is darker
 
See example 26 for more information.
$AutoColorMode #
$AutoColorMode 2
Milling machines
$DefineZeropoint
It is used to define temporary zero points.
Example: $DefineZeropoint "N:Name" 0 100 100 20
This will define zero point index 0 to X100 Y100 and Z20. Index 0 = G54, 1 = G55 etc.
Index 0 can also be called with G54.1 P0. After this command has been used, all G54-G59 and G54.1 calls will refer to the defined zero point and not to the ones in the zero point registry.
$DefineZeropoint $ # # # #
$DefineZeropoint "N:Name" 0 100 100 20
Milling machines
$TutorialLine
A special command to set titles of tutorials. You can read more about these here Creating customized tutorials in CNC Simulator Pro.
$TutorialLine $
$TutorialLine "We end the program with M30"
Milling and turning machines
$Title
A special command to set titles of tutorials. You can read more about these here Creating customized tutorials in CNC Simulator Pro.
$Title $
$Title "Demonstration Tutorial"
Milling and turning machines
$PreventEraseOnCutOff
By default, the simulator will erase everything to the right when the material has been cut through to simulate the part falling down. This command prevents that from happening.
$PreventEraseOnCutOff
$PreventEraseOnCutOff
Turning machines
$ReadTasEmbeddedTool
When your program wants to use the simulator embedded tools, you call these tools with "ET". Using this command, you can skip the E and only use T followed by the tool index number. For example, "T25". The simulator will treat all T values as embedded tools.
$ReadTasEmbeddedTool
$ReadTasEmbeddedTool
Milling and turning machines
$UseAltG92method
This activates an alternative G92 mode so that it makes the current tool position have the coordinates you specify.
$UseAltG92method
$UseAltG92method
All machines
$DefineLatheTool
Used by SimCam and by "Make program portable" to create in-program lathe tools. It is an advanced command that defines both the geometry of the tool holder and the insert.
$DefineLatheTool ...
$DefineLatheTool 1 4 20 30 90 20 20 20 0 8 0 0 255 140 0 0.806 0.806 -0.804 0.800 0 10.000 -30.000 IP: 1.372 -0.238 9.819 -8.691 9.819 -8.691 9.978 -8.918 10.050 -9.187 10.051 -9.802 10.029 -16.986 10.029 -16.986 9.980 -17.260 9.840 -17.500 9.627 -17.678 9.365 -17.772 9.087 -17.771 8.827 -17.675 0.263 -9.109 0.263 -9.109 0.104 -8.881 0.033 -8.612 0.006 -0.806 0.006 -0.806 0.053 -0.533 0.191 -0.292 0.404 -0.112 0.664 -0.016 0.942 -0.016 1.204 -0.110 HP: 2.276 -4.641 27.028 -27.140 27.028 -112.636 6.779 -112.636 6.779 -27.140 2.276 -22.636 2.276 -4.641
Turning machines
$DefineNonModalMacro
This command lets users create their own custom G, M, and other codes.
$DefineNonModalMacro $ # #
For more information, see Create your own codes
Milling, turning, and cutter machines
$DefineModalMacro
This command lets users create their own custom G, M, and other codes.
$DefineModalMacro $ # #
For more information, see Create your own codes
Milling, turning, and cutter machines
$CodeHelp
This command is used to create custom code help.
$CodeHelp # $
For more information, see Create your own codes
Milling, turning, and cutter machines
$ActivateMacroInterpreter
This command is used to temporarily enable the macro interpreter.
$ActivateMacroInterpreter
 
Milling, turning, and cutter machines
$GotoLabel
With this command, we can jump into the CNC program to a specified label.
$GotoLabel $
$GotoLabel "end"
Milling, turning, and cutter machines
$Include
This command is used to include files that can be run in the background to make custom definitions.
$Include $
$Include "myincludefile.cnc"
For more information, see Create your own codes
Milling, turning, and cutter machines
$SetSimSpeed
Set the speed of simulation. The value is 0 to 200, where 0 is slowest.
$SetSimSpeed #
$SetSimSpeed 20
 
$SetupToolpathLines
Can be used to set the color and width of toolpath lines.
0/1 = Feed lines or Rapid lines
R = Red amount 0 - 255
G = Green amount
B = Blue amount
W = Line Width
$SetupToolpathLines # # # # #
$SetupToolpathLines 0 40 70 240 4
 
$ChangeToolAutomatically
When this mode is active, M06 is not needed for tool changes.
$ChangeToolAutomatically
$ChangeToolAutomatically
Lathe
 
Note that these commands work even when they are inside parentheses. It is normally good to keep them in parentheses to avoid confusion with other software or CNC controllers.