Interpreters development
  • Interpreters development
v3.0.4
Search Results for

    Show / Hide Table of Contents

    Interpreter debugging in Visual Studio Code

    To debug your own .NET-based (C#) G-code interpreters, do the following:

    1. Download and install the latest available version of Visual Studio Code (https://code.visualstudio.com/download).

    2. Install the C# for Visual Studio Code extension from the Visual Studio Code extension marketplace (https://marketplace.visualstudio.com/items?itemName=ms-dotnettools.csharp).
      C# for Visual Studio Code link

    3. After you click the Install button, VS Code (short for Visual Studio Code) opens on the Extensions tab. Just click the Install button next to the extension name.
      C# for Visual Studio Code Installation

    4. For more convenient editing of snci files, it is recommended (but not required) to install the XML Language Support by Red Hat extension (https://marketplace.visualstudio.com/items?itemName=redhat.vscode-xml).

    5. If you have not done so yet, download and install the latest version of ENCY (version 3 is required) from the official website (https://encycam.com/download/).

    6. Next, launch ENCY and select Create interpreter in the Utilities list.
      CreateInterpreter_En

    7. In the window that appears, click the Set ENCY file path button and set the path to the ency.exe file located in the ENCY installation directory (by default, 'C:\Program Files\ENCY Software\ENCY 3\Bin64\ency.exe').

      image2025-6-11_11-44-46
      This adds the 'NCKernelDir' environment variable to the Windows environment variables. To be able to launch Visual Studio Code from ENCY, the 'Path' environment variable must include the VS Code installation folder. The Visual Studio Code installer usually adds it by default.

      To debug the interpreter in ENCY Tuner, select the Interpreter manager item in ENCY Tuner (it opens the same interpreter creation window), click the Set ENCY Tuner 3 file path button in the window and select the ltuner.exe file in the bin64 folder of the ENCY Tuner installation folder. This sets the 'TunerDir' environment variable that the 'Launch Tuner' debug configuration uses to start ENCY Tuner.

      Note

      For changes to the Windows environment variables to take effect, after setting the path to the ency.exe executable file (for ENCY Tuner, ltuner.exe) and finishing the VS Code installation, sign out of Windows and sign in again, or at least start VS Code again from the Start menu or File Explorer rather than from a terminal opened earlier.

    8. Then launch ENCY again and select Create interpreter in the Utilities list. Now you can create a new interpreter by entering its name in the Name field and a directory in the Folder field; in this directory a folder named after the interpreter will be created with all the necessary source files.

    9. After you click the <Ok> button, a new Visual Studio Code window opens with the tab of the main source file of the interpreter, 'Interpreter.Core.cs'.
      image2025-6-11_13-2-56

      Important

      Before you start debugging, check what the Create interpreter item has filled in. If the SDK package version in the *.csproj file is a prerelease one (-dev, -rc) or a version of an older major version, the ID field in the *.snci file is filled with zeros or, for a descendant interpreter, ParentID contains the parent's LibraryID or ParentFileName is empty, fix these fields. If everything is already correct, skip this step. For what and how to check, see What to fix after creation.

    10. Then you can set a breakpoint on any method (for example, the constructor of the NCInterpreter class), switch to the 'Run and Debug' tab and click the 'Launch CAM' button (F5 key; for ENCY Tuner, select 'Launch Tuner').
      DebugInterpreter_En

    11. As a result, the interpreter is built from source, ENCY starts (with Launch Tuner, ENCY Tuner), and debugging of the source code begins.

    12. To check how the interpreter works, create a G-code based operation in the ENCY window that opens.
      GCodeBasedOperation_En

    13. Enter some NC program text in the <Job assignment> parameters panel of the G-code based operation, for example:

      G0 G17 X0 Y0 Z0
      X100
      Y100
      X0
      Y0
      
    14. Select the created interpreter in the <Strategy> operation parameters panel:
      SelectInterpreter_En

    15. And click the operation calculation button RunButton_En

    16. Execution should stop at the breakpoint you set. Now you can use Step Over (F10) on the toolbar to move through the lines of the interpreter code.
      InterpreterDebugging_En

    17. Finally, you can change the interpreter code in the Interpreter.Core.cs, Interpreter.Registers.cs and NewInterpreter.snci files as needed and debug it using all the features available in Visual Studio Code. If you are not yet familiar with the capabilities of VS Code, we recommend visiting the "Get Started" section of its official documentation (https://code.visualstudio.com/docs/getstarted/introvideos).

    18. Once you have written and debugged the source code of the interpreter, you can get and use the dynamic-link library (*.dll) and interpreter settings (*.snci) files. Just select 'Reveal in File Explorer' in the context menu of the corresponding files (in this case, NewInterpreter.dll and NewInterpreter.snci) in the Visual Studio Code Explorer. The interpreter files will then be selected in File Explorer, and you can copy them and, if necessary, send them to the customer.

      VS Code. 'Reveal in File Explorer'_En
      InterpreterFiles_En

    In this article