Attention Mastercam C# and VB.NET Programmers

If you are a Mastercam Third Party programmer, or you dabble in .NET programming, you may be interested to know about our new Mastercam NETHook templates for Visual Studio 2010 and Visual Studio 2010 Express Edition. NETHooks allow you to extend and/or automate some of your Mastercam functionality using the .NET programming language.

This NETHook template will help you set up new projects with the necessary function calls and resources to create a custom NETHook. Every time you create a new NETHook you have to implement the same functions call and resources over and over. This template does it all for you, eliminating the redundancy. It also includes a resource file with icons, which can be used to create MC toolbar buttons.

The steps below will walk you through how to use the new Mastercam X5 C# Project Template. (Please note that you can click on the illustrations to bring up larger images. Then click your browser Back button to return to the blog.)

1. Open Visual Studio 2010 and select New Mastercam NETHook Project.

2. A new NETHook project is created.

3. Check to make sure that the reference to Mastercam NETHook API is valid; if it is broken you will see a yellow icon with an exclamation mark. If this is the case, delete the reference and add a new reference. Browse to your Mastercam installation folder and select the NETHook2_0.dll.

4. The project contains the required Run overridden method and additional optional methods, as well as a user defined method.

5. A default Function Table (.ft) file is also created.

6. Edit the Function Table with the name of your NETHook project.

7. A resource file is also created. This file contains 4 images for toolbar buttons; one for small image and the other for large image, and a string table containing two strings used for toolbar button tooltips.

8. We need to rename the FT file with the same name as the project.

9. We are now ready to compile our NETHook. Select Build / Build Solution from Visual Studios menu. The project should build successfully and create your NETHook and export a copy of your Function Table.

10. Copy your NETHook (NETHook.dll in this example) to a new folder. For example C:Program Files (x86)mcamx5chooksExampleNETHook

11. Copy your Function Table (NETHook.ft in this example) to your Mastercam CHooks folder. For example C:Program Files (x86)mcamx5chooks

12. Launch Mastercam and select the Settings / Customize menu to display the dialog as shown and select NETHook from the category (this corresponds with the Category section of your function table) and you will see your two icons.

13. Drag and drop each icon onto the Mastercam toolbar area to create a new toolbar.

14. Click on either of the buttons to execute the applicable method contained in your NETHook.

You have now successfully created a Mastercam X5 C# NETHook! You can download the templates below:

Visual Basic.NET
http://visualstudiogallery.msdn.microsoft.com/d40d0cd0-928d-4785-8c51-f1d15e43710a

C#
http://visualstudiogallery.msdn.microsoft.com/1c365df0-a7ee-4394-84cd-b1df6230350b

Leave a Comment

*