Demo CNC code

Ok, here is a portable demo CNC program that has some of the new features of version Copy and paste, hit play and enjoy!


M98 P9999 L1 (Call data block)
T1 M6
G0 X15 Y15 Z2
G1 Z-5 F250 S2000 M3
G2 X30 Y85 R15
G1 X85
G0 Z2
T2 M6
G0 X30 Y30 Z2
G81 Z-20 R1 M3 M8
G28 Z5 (New command)
O9999 (Data block defining registry data)
(Created for virtual machine: MillingCenterMM.machine)
($OverrideBufferQualitySetting 6)
($Message “This program uses locally defined tools, workpieces, zero points and materials.” 4 0)
($DefineMillWorkpiece “N:Tutorial1:M:Golden” 0 100.00 100.00 10.00)
($DefineMillWorkpiece “N::M:” 1 200.00 80.00 20.00)
($DefineMillWorkpiece “N::M:” 2 20.00 120.00 20.00)
($DefineMaterial “N:Golden” 0 128 128 128 218 165 32 1)
($DefineMillTool “N:Flat mill 1” 0 0.00 0.00 0.00 10.00 50.00 0)
($DefineMillTool “N:Drill” 1 60.00 0.00 0.00 10.00 50.00 2)
($DefineMillTool “N:” 2 80.00 0.00 0.00 2.00 20.00 2)
($DefineZeropoint “N:” 0 30.00 30.00 45.00)
($AddRegPart 1, 30, 30, 35)
($AddRegPart 2, -20, 40)
($AddRegPart 3, 10 20 20.1)
($AddRegPart 3, 130, 20 20.1)

Portable CNC code

What is it and why do I need it?


Well, as you know, programs that use local settings like zero points, tools and workpieces will not run well on another computer because the settings there will probably be very different. If you want to send a program to a friend, you need to make it portable first. Same goes if you want to send a program you want to discuss with us at Maybe you have made a very cool demo and want to send it to us so we can include it as a sample? (Please do).

With the latest version ( it is possible to make programs portable by using the menu function Tools – Make program portable.

What the function does it that it creates a sub program with tools, zero points and workpieces definitions. Instead of using your local settings when running, the CncSimulator will use the tools, zero points and workpieces defined in the sub program.

The sub program is sort of “ugly” as it is full of strange CncSimulator specific commands. That’s why we hide it away at the end of the program to not distract the user. Feel free to move other CncSimulator specific command that you use to the subprogram too. This will give your CNC program a clean look with all “strange stuff” collected in the sub program. The function will automatically add a call to the sub program in the first row. The sub program number will always be 9999 so avoid that number if you plan to make your program portable.

Please note that this function currently only works for milling programs.

3D buffer quality

As you all (hopefully) know by now, you can set the 3D solid buffer quality in the Simulation Settings to Low, Medium and High.


The quality you will be able to use depends on your computer hardware and your demand for speed during simulation. In some situations, for example when milling small parts the High setting will not give enough resolution. Also, users with fast computers and huge amount of RAM memory will want to run a higher setting. With the new version ( we have added a simulator command called $OverrideBufferQualitySetting. You can add it to the start of your program to customize your quality setting. For example, a value of 10 will give a buffer with 10 buffer points per unit. It will also slow down your simulation of course. You can play with this override setting but remember, you can easily create a memory overflow with a too high setting.

This zoomed in part was milled with the Medium setting, look at the edges of the arc and the hole.


This is the same part with $OverrideBufferQualitySetting 10.



Open and close doors

Here is a tips about two M-codes we have forgot to put in the help file (will be added later).

M20 Open machine doors
M21 Close machine doors

Of course, they only work on machines that have doors! 😉
Have fun!

Enlarge font

Do you for some reason need to enlarge the text in the CncSimulator Editor? Do this by right clicking the text editor area and select “Options”. Then select “Fonts and Colors” and set any font size you need. At the moment it is not possible to save the setting though.