Mastercam NET-Scripting extension README
This extension automates the setup process for running and debugging C# scripts in the Mastercam environment.
Features
To use this extension, open an empty folder in VS Code. Open the command palette (Ctrl+Shift+P) and choose Initialize Mastercam Script Environment. See "Configuring the extension" task in the Documentation section.
Requirements
The extension requires that Mastercam 2023 be installed on your workstation. Earlier versions of Mastercam are not supported. Download Mastercam from the following link:
https://www.mastercam.com/downloads/
This extension is intended to be used for C# scripts (.csx files). An extension to support C# development must be installed. The C# for Visual Studio Code extension from Microsoft is a common choice. You can download it from the following link:
https://marketplace.visualstudio.com/items?itemName=ms-dotnettools.csharp
Mastercam must be configured to enable communication with the extension. See "Configuring Mastercam to enable debugging" in the Documentation section.
The following files need to be in the same folder as the scripts. This is accomplished when you complete the "Configuring the extension" task in the Documentation section.
Documentation
Configuring the extension
After downloading and installing the extension, follow these steps so that it will work with Mastercam. This procedure copies the omnisharp.json and launch.json files to their proper places.
- Click the Explorer button, then Open Folder.
- Navigate to the folder that contains your scripts. For example, this folder contains the sample scripts installed with Mastercam (\Shared Mastercam 2023\NET-Scripts).
- Select View, Command Palette (Ctrl+Shift+P).
- Select Initialize Mastercam Script Environment.
The extension is now ready to be used with Mastercam.
Configuring Mastercam to enable debugging
Before you can debug scripts inside Mastercam, you need to configure Mastercam so that the necessary support DLL is loaded when Mastercam starts. This lets the debugger and Mastercam communicate with each other.
- Launch Mastercam.
- Select File, Configuration.
- Go to the Start/Exit page.
- Select the Startup option.
![Configuring Mastercam to use the IPCServer.dll]
- Click the folder button and navigate to the \chooks\MCNetScripting folder. This is located in the folder where Mastercam is installed. The default location is: \Program Files\Mastercam 2023\Mastercam\chooks\MCNetScripting
- Select IPCServer.dll.
- Save the .config file and close Mastercam.
This procedure modifies the .config file for your default units (inch or metric). If you wish, complete these steps again for the .config file that supports the other units.
Enabling debugging support in your scripts
Follow the steps in this section to enable access to Mastercam resources. Sample scripts installed with Mastercam have these lines commented out. In these cases, simple uncomment the lines.
Include the r# directive as shown. This directive is not necessary when using the NET-Script editor in Mastercam but is required when using other editors or debuggers.
// NOTE: Update paths to reference your Mastercam 2023 path
#r "C:\Program Files\Mastercam 2023\Mastercam\NETHook3_0.dll"
This example shows Mastercam’s default installation folder. If Mastercam is installed in a different location on your workstation, use the correct path to the NETHook3_0.dll for your workstation.
Import the required namespaces. These statements are not necessary when using the NET-Script editor in Mastercam but are required when using other editors or debuggers. For example:
// Using for External Editor
#region Namespace Import
using System;
using Mastercam.IO;
using Mastercam.Curves;
#endregion
If you are using the sample scripts installed with Mastercam, these statements are already present in the code, all you need to do is uncomment them.
Extension Settings
There are no VS Code settings associated with this extension.
Known Issues
There are no known issues with this extension.