I was interested in the integration between Autocad and vb.net.
The task is to let autocad automatically draw using vb.net code.
The final project will allow me to automatically create cables drawing, starting from tmeplates and a csv file with info (and of course my plugin).
“user friendly” is the keyword for me. I don’t like the implementations where the user has to type commands on autocad to install the plugin, and then to use it.
For this reason i had 2 problems:
1) Find a method to let my users to easy install the plugin
2) Develop a easy to use plugin with graphic interface.
I found the solution and I want to share it with you.
EDIT: @David wolfe answered with a solution to automatically start the plugin in autocad 2012 and earlier, but my factory has only licenses for autocad 2011 and later.
EDIT: @david wolfe wrote an answer to this question to automatically install the plugin in Autocad 2012 and higher, but i deal even with autocad 2011 and autocad 2000, then I found the following solution.
Problem 1 SOLUTION:
the autocad plugin developed in vb.net is a dll file.
To automatically load it when autocad is launched, autocad needs that the system registry is modified.
To do it, i prefer a method that doesn’t use autocad.
I created a new “Windows Forms Application” project (called INSTALLER) in vb.net, in the default form i added 2 buttons: one that registers the plugin, and one that removes the plugin. Note: In this sample i decided that the dll plugin file must be placed in the same folder of the exe application that we are going to create(the INSTALLER).
Here it is the code for our plugin installer/remover.
First of all create a module and paste this code:
(some of the comments and messages inside the code are in italian, you can easily translate them in your language with google translate)
Now you only need to call the RegisterModule() and UnregisterModule() Subroutines in order to register or unregister our plugin.
This is my GUI for the Installer:
Problem 2 SOLUTION:
To create an easy to use plugin, i think that the best is to use a graphical user interface.
For this reason i created a palette, with buttons, dropdown menus and pictures.
Each time that autocad is opened our plugin will be automatically loaded, and our palette created.
The following code is an easy implementation where the palette could be personalized by you with your button and your code.
First of all create a new project (create a Windows Control Library) and add the reference to the following components:
(depending on your version of autocad this path may change)
C:\Program Files\Autodesk\AutoCAD 2011\acdbmgd.dll
C:\Program Files\Autodesk\AutoCAD 2011\acmgd.dll
Then create a class and paste this code (note:there is some code of my implementation, like structures, but you can easily clear it up upon your needs. loadDatabase, for example is my custom routine that you may not need):
Then in our userControl, switch from graphic view to code view and paste this code:
Compile everything, copy the generated dll file in the installer path previously created and test it.
Now you are ready to add on your palette your graphic buttons, code and whatever you want to do with it.
This is the GUI of my palette on autocad:

How to distribute it: I put in a folder the installer exe, the dll plugin, a readme file and eventually the templates or other files needed by your custom plugin.
Then I Zip this folder and send it by e-mail to my users.
By this way, the users only need to unzip the folder in their hard disk (in a not temporary path), to open the exe and to press “REGISTER PLUGIN” button. FINISH!
Now the user can open autocad and use the plugin.