spinner
{{ menu }}

Templates

CNC Macro Simulator II supports templates! What are templates? Templates are the game changer in the CNC industry! They allow code reuse, make the program smaller and more readable, but at the same time they are not a compatibility issue as they will be converted to pure g-code* on the fly. Moreover, they allow you to use arguments that allow you to pass a given value to template. Remember that you can nest templates as many times as you want!

So how to use them? It's so easy, just take a look:

Write or open the program in the editor

Save as template (the @ symbol will be added automatically)

To use it, add "@" before the template name (for example, the template name was a circle, followed by an @circle)

To edit it, just select your template in "Open template", edit it and save it by selecting “save”.

Good to know

You can also pass a value using arguments, see an example below:

Inside of your template code:

#100 = #diameter #101 = #xLocation #102 = #yLocation

Important

Arguments must start with the # symbol, and the next symbol must be a letter (for example:#radius, #strategy2)

then call your template:

@circle diameter=100 xLocation=0 yLocation=0

Isn't that amazing? By using words that you understand, the arguments become self-explanatory which will make it easier for you and the person working with your programs.

Important

Remember that the template system is a new tool and is constantly being tested and improved, so always back up your programs!

*If the program contains a macro, it should be converted to pure g-code using the "export" option.