I have created a dll that I can run from the command line just fine. However, I have been asked to do the following:
When the user opens a drawing a button will appear.
When the user clicks on the button the command contained in the dll will be executed.
I don't know how to do this and haven't been able to find much on this. Does anyone know how to do this? Any help would be appreciated. I am using AutoCAD 2011.
Thanks.
Hi,
you can use the events from the DocumentCollection-object (Autodesk.AutoCAD.ApplicationServices.Application.DocumentManger). If there is a document opened or a new one created you may get the EventHandler raising.
Just to think for your workflow: Check the situation that when AutoCAD just started you application is not loaded as long as you are working with NETLOAD.
HTH, - alfred -
I'm not sure that I understand. I thought that there would be a way to create a custom button that would basically execute the netload and then my custom command.
Are there any examples of this anywhere?
Thanks for your reply.
Hi,
>> I thought that there would be a way to create a custom button that would basically execute the netload
That I don't understand ... ;(
As long as your application is not loaded ... who or what should create a "custom button"?
Well you can create a menu that is loaded, that menu has a button to load your app. But there is not function in the AutoCAD menues that will react when a drawing get's loaded. So there is also no chance to get this menu-part/button to "popup when a drawing is loaded" (that was your wish (so I understood the first message).
- alfred -
Thanks, Alfred.
Can I add a button to an existing menu that when the user clicks the button the custom command that I have created will get loaded and executed? If so, how do I do this?
I'm sorry that I am slow but I am very new to AutoCAD.
Thanks again.
Use this macro behind your button to run your command where dll full path is the full path to your dll file (should be local) I run AutoCAD Electrical so mine is "C:/Program Files/Autodesk/Acade 2012/mydll.dll". and command is the command you want to run.
C: NETLOAD;"dll full path" command