• 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

C# support in CAMAPI

Support factory class

After the managed DLL is loaded into the main application's memory, it is analyzed for the presence of the namespace CAMAPI with the ExtensionFactory class inside. This class must implement the IExtensionFactory. interface. The main application will interact with the loaded DLL through an object of this interface.

This interface provides method to create instances of extensions, so main application will call this method.

// ReSharper disable once CheckNamespace
namespace CAMAPI;

using Extensions;
using ResultStatus;

/// <summary>
/// Factory for creating extensions. Namespace and class name always should be CAMAPI.ExtensionFactory,
/// so CAMAPI will find it
/// </summary>
public class ExtensionFactory : IExtensionFactory
{
    /// <inheritdoc />
    public void OnLibraryRegistered(IExtensionFactoryContext context, out TResultStatus ret)
    {
        ret = default;
    }

    /// <inheritdoc />
    public void OnLibraryUnRegistered(IExtensionFactoryContext context, out TResultStatus ret)
    {
        ret = default;
    }
    
    /// <summary>
    /// Create new instance of our extension
    /// </summary>
    /// <param name="extensionIdent">
    /// Unique identifier, if out library has more than one extension. Should accord with
    /// value in settings json, describing this library
    /// </param>
    /// <param name="ret">Error to return it, because throw exception will not work</param>
    /// <returns>Instance of out extension</returns>
    public IExtension? Create(string extensionIdent, out TResultStatus ret)
    {
        try
        {
            // write your code to create new instance
        }
        catch (Exception e)
        {
            ret.Code = TResultStatusCode.rsError;
            ret.Description = e.Message;
        }
        return null;
    }
}

Connecting the SDK

You have to include actual version of SDK as package reference.

<PackageReference Include="SprutTechnology.CAMAPI.SDK.Net" Version="18.2.0" />
In this article
Back to top Generated by DocFX