CNCSimulator Pro

user guide
×
Menu
Index

6.3. $-commands and regions

These are the default standard codes that are used in our normal virtual machines. Please note that customized machines may have other codes and formats.
 
The $-commands are special simulation commands for controlling the various aspects of the simulation. They have nothing to do with CNC codes and should not be transferred to a real CNC controller. $-commands can be put within parenthesis and will still be read by the simulator. Blocks of $-commands can be hidden from the CNC code by encapsulating them in a region making the block collapsible.
 
 
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 hover 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 list and give a brief explanation of all built in $-commands. Please not that many of them are not for common use but rather made for special use in examples or when creating portable programs. We have colored the commands you will likely use in red. If you are not an advanced user that wants to learn all aspect of the CNCSimulator, you can skip over the commands colored in black. Not even all red command is a must to know. As a minimum, you have to know the $AddRegPart command as you will need it to place workpieces on the table (or in the chuck). If you are a 3D Printer only user, you can ignore the $-commands.
 
$-command
(codes valid from V1.0.6.5)
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 coordinate for where you want to place 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
Put 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 visual rotation of the workpiece is not desired.
 
 
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
$SetView
SetView is a special command to set the 3D-view during simulation. It should not be programmed manually as it contains too many parameters but rather be created using the menu action Tools – 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 simulation. First parameter is a text string of the message to display. 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 run-time in percent. Parameters are FromLeft, FromRight, FromFront, FromBack and FromTop.
$Cutting #####
$Cutting  0 52 34 100 100
All machines
$Cutting
Set workpiece cutting.
To show the whole part, left should be 0 and Right should be 100.<BR />
The last parameter is 0 to show the workpiece closed and 1 to show the inside.<BR />
 
$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 stop watch 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 stop watch 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 non-lathe machine.
$Lathe
$Lathe (Alarm if not lathe machine)
Turning machines
$Mill
Enforces the use of a milling machine. You will see an alarm if you run a program with this command on a non-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
$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, PartColG, TopColR, TopColG, TopColB, MaterialStype
$DefineMaterial [$]########
$DefineMaterial "N:Aluminium" 1 160 160 170 0 0 0 1
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 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 Browser (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 to continue machining the other side of it.
$InvertLathePart
$InvertLathePart
Turning 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.
$AbsoluteCenters
$AbsoluteCenters
All machines
$SetG28pos
Set custom position for G28.
$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
 
Milling and turning machines
$RotateWorkpiece
This command rotates the workpiece around its Z axis.
 
$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 giving 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
 
Milling machines
$DefineZeropoint
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[$][#][#][#] [#]
 
Milling machines
$TutorialLine
Special command to set titles of tutorials. You can read more about these here Creating customized tutorials in CNCSimulator Pro.
$TutorialLine[$]
 
Milling and turning machines
$Title
Special command to set titles of tutorials. You can read more about these here Creating customized tutorials in CNCSimulator Pro.
 
$Title
 
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
 
Lathe 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
 
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
 
 
 
Note that these commands works even when they are inside parentheses. It is normally good to keep them in parentheses to avoid confusion with other software or CNC controllers.