.NET
cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 

Execute a custom command from a button

6 REPLIES 6
Reply
Message 1 of 7
texas1992
720 Views, 6 Replies

Execute a custom command from a button

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.

6 REPLIES 6
Message 2 of 7
Alfred.NESWADBA
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 ... blog.hollaus.at ... CDay 2024
------------------------------------------------------------------------------------
(not an Autodesk consultant)
Message 3 of 7
texas1992
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.

Message 4 of 7
Alfred.NESWADBA
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 ... blog.hollaus.at ... CDay 2024
------------------------------------------------------------------------------------
(not an Autodesk consultant)
Message 5 of 7
texas1992
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.

Message 6 of 7
Alfred.NESWADBA
in reply to: texas1992

Hi,
------------------------------------------------------------------------------------
Alfred NESWADBA
Ingenieur Studio HOLLAUS ... www.hollaus.at ... blog.hollaus.at ... CDay 2024
------------------------------------------------------------------------------------
(not an Autodesk consultant)
Message 7 of 7
btackes
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

Can't find what you're looking for? Ask the community or share your knowledge.

Post to forums  

Autodesk DevCon in Munich May 28-29th


Autodesk Design & Make Report

”Boost