.NET

Reply
Contributor
texas1992
Posts: 18
Registered: ‎09-15-2011
Message 1 of 7 (162 Views)

Execute a custom command from a button

162 Views, 6 Replies
11-29-2011 05:22 PM

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.

*Expert Elite*
Alfred.NESWADBA
Posts: 8,963
Registered: ‎06-29-2007
Message 2 of 7 (147 Views)

Re: Execute a custom command from a button

11-30-2011 01:28 AM in reply to: texas1992

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 -

-------------------------------------------------------------------------
Alfred NESWADBA
Ingenieur Studio HOLLAUS ... www.hollaus.at
-------------------------------------------------------------------------
Contributor
texas1992
Posts: 18
Registered: ‎09-15-2011
Message 3 of 7 (141 Views)

Re: Execute a custom command from a button

11-30-2011 05:47 AM in reply to: Alfred.NESWADBA

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.

*Expert Elite*
Alfred.NESWADBA
Posts: 8,963
Registered: ‎06-29-2007
Message 4 of 7 (139 Views)

Re: Execute a custom command from a button

11-30-2011 06:15 AM in reply to: texas1992

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 -

-------------------------------------------------------------------------
Alfred NESWADBA
Ingenieur Studio HOLLAUS ... www.hollaus.at
-------------------------------------------------------------------------
Contributor
texas1992
Posts: 18
Registered: ‎09-15-2011
Message 5 of 7 (138 Views)

Re: Execute a custom command from a button

11-30-2011 06:21 AM in reply to: texas1992

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.

*Expert Elite*
Alfred.NESWADBA
Posts: 8,963
Registered: ‎06-29-2007
Message 6 of 7 (130 Views)

Re: Execute a custom command from a button

11-30-2011 07:08 AM in reply to: texas1992
Hi,
-------------------------------------------------------------------------
Alfred NESWADBA
Ingenieur Studio HOLLAUS ... www.hollaus.at
-------------------------------------------------------------------------
Active Contributor
btackes
Posts: 34
Registered: ‎05-13-2011
Message 7 of 7 (109 Views)

Re: Execute a custom command from a button

12-01-2011 05:51 AM in reply to: Alfred.NESWADBA

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

Announcements
Are you familiar with the Autodesk Expert Elites? The Expert Elite program is made up of customers that help other customers by sharing knowledge and exemplifying an engaging style of collaboration. To learn more, please visit our Expert Elite website.
Need installation help?

Start with some of our most frequented solutions or visit the Installation and Licensing Forum to get help installing your software.