Autoload Commands

Autoload Commands

Anonymous
Not applicable
766 Views
7 Replies
Message 1 of 8

Autoload Commands

Anonymous
Not applicable
Hi,

I need to create a few new commands for AutoCad 2007 in VB.NET and also make an installation package that adds them to a new toolbar on machines with AutoCAD 2007 already installed.

I am not too clear on how to make the toolbar and commands available as soon as the installation package has finished.

From what I have read on the forums, there are two ways of doing this.

1 - From within the installation package add keys to the registry like so..

HKLM\Software\Autodesk\AutoCAD\R17.0\ACAD-5001:409\Applications
\myApp
"DESCRIPTION"="myApp"
"LOADER"="C:\\wherever\\myApp .dll"
"LOADCTRLS"=dword:00000002
"MANAGED"=dword:00000001

SubKey:< br>myApp\Commands
"StartmyApp"="StartmyApp"

(As seen in http://discussion.autodesk.com/thread.jspa?messageID=4531456)


2 - Create a shortcut that forces acad.exe to run with the argument /b somescriptfile.scr, and in that script file include the line:

(command "netload" "C:\\wherever\\myCommands.dll")


I am new to AutoCAD programming, but somehow, neither of these two ways seem ideal, so my question is, Is there a better way of doing it ?

Is there are script file that AutoCAD always executes by default where I could put the "(command "netload"..etc" line and taht way save me from having to create the shorcut and script file ?


Thanks in advance,

Julian
0 Likes
767 Views
7 Replies
Replies (7)
Message 2 of 8

Anonymous
Not applicable
The registry setting is probably the best way. One suggestion when you create the registry key is to read the Autodesk.AutoCAD.Runtime.SystemObjects.DynamicLinker.ProductKey property that contains the beginning portion of that registry path which will make your code a bit more robust if AutoCAD is updated. Also make sure you read the different values for LOADCTRLS - it determines what events (ACAD startup, command execution, etc.) will trigger your application loading.
0 Likes
Message 3 of 8

Anonymous
Not applicable
Thanks smc,

Yes, If I dont have to hardcode the registry path, the registry way, does begin to look like the better option.

Although I am finding very little info on the ProductKey property. It would be great if you have an example on how to obtain it.

But you have definitely put me on the right track.

Thanks again

julian
0 Likes
Message 4 of 8

Anonymous
Not applicable
Code attached (Visual Basic code for .NET 2.0, ACAD2005)
0 Likes
Message 5 of 8

RonnieWilkins
Advocate
Advocate
You can only use 'Autodesk.AutoCAD.Runtime.SystemObjects.DynamicLinker.ProductKey' if you are running inside of AutoCAD, thus defeats the purpose of having application immediately available after installation.

Instead store 'HKEY_LOCAL_MACHINE\SOFTWARE\Autodesk\AutoCAD\' and then iterate each version 'R16.2', 'R17.0', etc., then vertical 'ACAD-4001:409'. Under each vertical is the Applications folder you will need to add your app to.

Using this method you can create a console app and run it from the Commit and Uninstall portions of the installer.
Ronnie Wilkins, Jr.
0 Likes
Message 6 of 8

Anonymous
Not applicable
I require an initial netload of the application first for the user - hence, I have the ProductKey value available. If you would prefer to avoid this, RWilkins solution is best. The code should still work fine though, there is just some extra logic necessary at the beginning to find all the AutoCAD product keys to add it to.
0 Likes
Message 7 of 8

Anonymous
Not applicable
Thanks a lot guys.

I´ll blend your answers to make it work.

julian
0 Likes
Message 8 of 8

Anonymous
Not applicable
Thanks a lot guys.

I´ll blend your answers to make it work.

julian
0 Likes