Advanced Topics·

Leveraging the Entitlement API with AutoLISP & .NET Hybrid

How to invoke Autodesk’s Entitlement API from AutoLISP scripts and integrate with a C#/.NET backend for seamless licensing workflows.

Ahmed Elsayed
By Ahmed Elsayed
2 min readAdvanced

AutoLISP can call external .NET methods, allowing you to embed Entitlement API checks directly within Lisp routines. In this post, we’ll create a hybrid workflow: an AutoLISP command invokes a C# helper to validate and activate licenses via the Entitlement API.

AutoLISP to .NET licensing flow

1. Exposing .NET Helper via COM

In your C# class library, mark a helper class COM-visible:

EntitlementHelper.cs
using System.Runtime.InteropServices;
using Autodesk.Entitlement;

[ComVisible(true)]
[Guid("D4A2E5B1-3C7A-4F6E-8F1A-9B2C3D4E5F60")]
public class EntitlementHelper
{
    private readonly EntitlementApiClient _client;

    public EntitlementHelper()
    {
        _client = new EntitlementApiClient(
            "https://api.autodesk.com/entitlement/v1",
            Environment.GetEnvironmentVariable("ENTITLEMENT_API_KEY")
        );
    }

    public bool Validate(string token)
    {
        var resp = _client.ValidateTokenAsync(token).GetAwaiter().GetResult();
        return resp.IsValid;
    }

    public bool Activate(string token)
    {
        var machine = Environment.MachineName;
        var act = _client.ActivateAsync(token, machine).GetAwaiter().GetResult();
        return act.Success;
    }
}

Register the assembly for COM interop:

regasm /codebase EntitlementHelper.dll /tlb:EntitlementHelper.tlb

2. Calling from AutoLISP

Load the type library and call the COM methods:

(vl-load-com)
(setq helper (vlax-create-object "EntitlementHelper"))
(setq token (read-line (open "license.token" "r")))

(if (and
      (helper.Validate token)
      (not (helper.Activate token))
    )
  (princ "Warning: license validated but activation failed.")
  (princ "License validation failed. Plugin unavailable."))

This Lisp routine:

  1. Loads COM.
  2. Reads your token file.
  3. Calls Validate then Activate, printing errors.

3. Workflow Tips

  • Token Caching: Store the last valid token in memory to avoid redundant calls.
  • Error Reporting: Use princ or dialog boxes to inform users of license issues.
  • Offline Mode: Fallback to cached validation results when offline.
💡 Tip: Keep your COM GUID stable across versions to avoid re-registration hassles.

Introduction to Entitlement API

Overview of licensing concepts.

Getting Started with C#/.NET

SDK installation and setup.

Preparing Test Data

Crafting JSON fixtures and tests.

Official Entitlement API PDF

Desktop API reference documentation.

Next Steps

In Post #5, we’ll cover native ObjectARX integration using C++ and best practices for memory management.

Leave a Comment