• CAMAPI
  • API Documentation
Show / Hide Table of Contents
  • Supported programming languages
    • C#
    • Delphi
    • C++
  • Tutorial lessons
    • Lesson 1 - general introduction to the extension ideology using the example of a C# project
    • Lesson 2 - connecting the SDK to a Delphi project using the build system
    • Lesson 3 - connecting the SDK to a C++ project using the build system
    • Lesson 4 - demonstration of methods for unloading an extension during main application is running
    • Lesson 5 - Creating a custom operation
    • Lesson 6 - Creating a C# application to interact with geometry in main application
    • Lesson 7 - Creating a C# application to connect to main application for managing it
  • System extensions
    • Extension.Util.Common.Dll
    • Extension.Util.Common.Exe
  • Debugging of extensions
    • Debugging a .NET extension using Visual Studio Code
    • Debugging a Delphi extension using RAD Studio
    • Debugging a C++ extension using Visual Studio
  • Entry points
    • Utilitiy in main form
    • Executor for utility in main form
    • New item to the operation's context menu
  • Machining Tools Import
    • Preparing the environment
    • Working with the tool library
    • Working with cutting tools
      • Milling Tools
      • Turning Tools
      • Custom Axial Shaped Tools
    • Working with the tool holder
  • API Documentation
  • External applications
    • Connecting in a C# application
    • Connecting in a Delphi application
    • Connecting in a C++ application

Preparing the environment

The following is an example of how to prepare environment to work with machining tools import API, using the example of creating a console application in Visual Studio in C#.

  1. Download and install the latest .NET SDK x64 from the official site.
  2. To work with the source files, download and install the latest available version of Visual Studio Code.
  3. Run the installed Visual Studio Code and install "C# Dev Kit for Visual Studio Code" extension.

  1. If you have not yet, download and install the latest SprutCAM.

  2. In Visual Studio Code, open an existing or create a new directory for your new project. When prompted to "Do you trust the authors of the files in this folder?", click on "Yes, I trust the authors".

  3. Open the VS Code terminal view.

  4. In the terminal view insert the "dotnet new console --framework net8.0" command and press enter (change the net8.0 version if you have a different SDK version).

  • After executing this command, the following source files should appear in your working directory:

  • The .csproj file will have the same name as the working folder.

  1. Open the .csproj source file and change its contents as shown below:
<Project Sdk="Microsoft.NET.Sdk">
  <PropertyGroup>
    <TargetFramework>net8.0-windows</TargetFramework>
    <OutputType>Exe</OutputType>
  </PropertyGroup>
  
  <ItemGroup>
    <PackageReference Include="SprutTechnology.CAMAPI.SDK.Net" Version="18.2.1" />
  </ItemGroup>
</Project>
  • Set existing DLL location paths according to your CAM environment. If you cannot find the DLL libraries, make sure the CAM client is installed.
  • Pay attention to the target framework of your solution, it must match the format net8.0-windows (or higher SDK version).
  1. Open the Program.cs source file and change its contents as shown below:
using System;
using System.IO;
using MachinigToolsImportTypes;
using STMachiningToolsImportHelper;
using STTypes;

namespace STConsoleApp 
{
  class Program 
  {
    private static string assemblyPath = 
      @"C:\Program Files\[CAM_Path]\" + MTIMachiningToolsImportHelper.DllName;

    static void Main(string[] args)
    {
      if (!File.Exists(assemblyPath)) {
        Console.WriteLine("The {0} source file is not found", assemblyPath);
        return;
      }

      try {
        var importer = MTIMachiningToolsImportHelper.CreateImporter(assemblyPath);
        //Use "importer" to create new tool items, to open an existing or create new machining tools libraries
          
      } 
      catch (Exception ex) {
        Console.WriteLine(ex.Message);
      } 
      finally {
        MTIMachiningToolsImportHelper.FinalizeImporter();
      }
    }
  }
}

Change the "assemblyPath" variable to existing the "Bin64" folder location path according to your CAM environment. Now you can use the "importer" instance to create new tool items, to open an existing or create new machining tools libraries, and more. Pay attention to the call of the FinalizeImporter function, this function is always called before exiting the main program.

  1. Switch to the "Run and Debug" panel and press to the "Generate C# Assets for Build and Debug" button.
  • Now you can start debugging your application:

If you have set all the paths correctly, then this example should work without an error.

⭐ Congratulations, you have set up your development environment. ⭐

Helpful links:

  • GitVerse: Machining tool import API examples

Continue to read:

  • Working with the tool library
  • Working with cutting tools
In this article
Back to top Generated by DocFX