Skip to main content

Esprit Macro With .NET

Edit: I’m having some issues with a second tutorial, so at this point I don’t think this process below is correct.  2nd Edit:  This code should work fine, the issue was when I started using COM objects from Esprit.  There are a few gotchas that need to be taken care of.  I think the primary reason I had issues was due to writing the macro in C# instead of VB (the language the Esprit tutorials have).  I may be writing about it in the future.  If you are interested right now, send a message, or post in the forums.

This post will be a little more special interest them most of my posts. I recently started learning how to create macros for a program called Esprit (D.P. Technology). It’s a “CAD/CAM” program.

They still use COM/VBA as their plug-in interface, so to write a plug-in in .NET there are a few things that need to be taken care of. Their tutorial that comes with the program goes over setting everything up, but It misses a few steps. Well more likely, it was written for the one the earlier versions of Visual Studio, but anyways I will go over the steps necessary to get a “Hello World” running.

– Create a new Visual Studio project (Class Library), call it DotNETAddInTutorial1 as the tutorial from Esprit called it.

This tutorial goes over a simple hello world plug-in using Visual Studio 2005
– Go into the IDE menu Project->DotNETAddInTutorial1 Properties…
— Under the “application” tab, click the “Assembly Information…” button to the right. The pop-up will have a check-box at the bottom that says “Make Assembly COM-Visible” Check that. (important!) Click OK to close that pop-up window.
— Under the “Build” tab, check the “Register for COM interop” too

– Right click on References in the Solution Explorer window in the IDE. Select “Add Reference…”
– Select the COM tab and add these 4 references (Esprit Type Library, EspritCommands Type Library, EspritConstants Type Library, Microsoft Add-In Designer), take note that the Esprit ones will have version numbers in the name.

– Double click your Class1.cs file in the Solution Explorer so you can edit it.
Here is how the file should look:

using System;
using System.Collections.Generic;
using System.Text;
using Extensibility;
using System.Windows.Forms;

namespace DotNETAddInTutorial1
{
    public class Class1 : IDTExtensibility2
    {
        void IDTExtensibility2.OnAddInsUpdate(ref Array custom)
        {
            //throw new Exception("The method or operation is not implemented.");
        }

        void IDTExtensibility2.OnBeginShutdown(ref Array custom)
        {
            //throw new Exception("The method or operation is not implemented.");
        }

        void IDTExtensibility2.OnConnection(object Application, ext_ConnectMode ConnectMode, object AddInInst, ref Array custom)
        {
            MessageBox.Show("Add-In Tutorial 1 Connect", "", MessageBoxButtons.OK);
        }

        void IDTExtensibility2.OnDisconnection(ext_DisconnectMode RemoveMode, ref Array custom)
        {
            MessageBox.Show("Add-In Tutorial 1 Disconnect", "", MessageBoxButtons.OK);
        }

        void IDTExtensibility2.OnStartupComplete(ref Array custom)
        {
            //throw new Exception("The method or operation is not implemented.");
        }
    }
}


Here is a nice tip:

public class <strong>Class1 </strong>: <em>IDTExtensibility2</em>{}

If that is all you type into the class, you will see a blue squiggly line under the word Class1. If you right click on IDTExtensibility2 and select “Implement Interface”->”Implement Interface Explicitly,” Visual Studio 2005 will automatically generate the function tabs needed. Otherwise if you read the Esprit Documentation about this, they have a list of functions that you can type in by hand (their tutorials are in VB.NET only though).

From there you can build your solution. Copy the files in from the project’s Bin/Release folder into probably the folder “C:\Program Files\D.P.Technology\ESPRIT\AddIns\DotNETAddInTutorial1”

The last thing you need to do is create a registry file so you can let Esprit know of your plugin.
Create a text file and name it install.reg.
Right click on it and select edit.

Windows Registry Editor Version 5.00

[HKEY_LOCAL_MACHINE\SOFTWARE\D.P.Technology\ESPRIT\AddIns\DotNETAddInTutorial1.Class1]
"Description"="Test Add-in using .NET C#."
"FriendlyName"="Cool Testing Add-on"
"LoadBehavior"=dword:00000001
"CincomVersion"=dword:00000000
"NETInterOpDlls"="DotNETAddInTutorial1.dll"
"COMDlls"="DotNETAddInTutorial1.dll"



I’ve noticed that the last two lines are NOT needed, but I just leave them in there anyways.

Once you’ve save the file you can right click on it again to merge it into the registry. The other option would open up regedit and do it by hand. Notice that DotNETAddInTutorial1.Class1 specifically specifies the project name and class file to call.

That’s it!

Popular posts from this blog

ChatGPT is a new, and faster, way to do programming!

Currently ChatGPT is in a free “initial research preview” . One of its well known use cases at this point is generating software code. I’ve also just used it to write most of this article… Well, actually a future article about cleaning up SRT subtitle files of their metadata faster than I have been by hand with Notepad++ and its replace functionality. Update: I recorded a screencast of writing the SRT subtitle cleaner application loading and processing portion. I relied heavily on ChatGPT for code. It was a fun process! https://youtu.be/TkEW39OloUA ChatGPT, developed by OpenAI, is a powerful language model that can assist developers in a variety of tasks, including natural language processing and text generation. One such task that ChatGPT can help with is creating an SRT cleaner program. SRT, or SubRip Subtitle, files are commonly used to add subtitles to video files. However, these files can become cluttered with unnecessary information, such as timing lines or blank spaces. To clean...

Theme error in 2010s Android App after AppCompat Migration

I plan on releasing a lot of my old work as GPL open source, but most of it has aged to the point that it no longer functions, or if it does work it’s running in compatibility mode. Basically it’s no longer best practices. Not a good way to start off any new public GPL projects, in my opinion. The current project I’m working on is an Android app that calculates star trails meant to help photographers get or avoid that in their night time photos. For now I’m going to skip some of the import process because I didn’t document it exactly. It’s been mostly trial and error as I poke around Android Studio post import. The Android Studio import process… Removing Admob Google Play code before the project would run at all. After removing dependencies, it kind of worked, but when running it in the emulator it shows a pop-up message saying that the app was developed for an old version of Android. Going through the process of updating code to match current best practices… I had the IDE convert the ...

Blogger Notable theme pop-up header issue fix (thanks to Gemini Pro)

I've made a few half hearted attempts over the years to to fix Blogger's Notable theme's rendering of the pop-up header that shows up when you scroll down the page a decent amount and then pull back to reveal that secondary header. On Chrome mobile I noticed a gray box that forms next to the magnifying glass icon. I never looked in detail on  Chrome desktop, but it had an issue as well which I'll detail below.  If you are looking for a solution and don't want all of the extra talk about how I was able to find it, here it is:  .centered-top-container .sticky .main_header_elements { overflow : hidden !important ; } I decided to try using Gemini Pro 2.5 to see if it was capable of finding the issue and giving me a fix. Turns out that it was able, but it took a bit of collaboration back and forth to find the actual problem.  Here is a modified article I asked it to give me based on our debugging chat (it was very colorful in the article which I scaled back a lot, ...