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

Event AcadDocument_Activate() in DotNET

7 REPLIES 7
Reply
Message 1 of 8
Mitch_31
758 Views, 7 Replies

Event AcadDocument_Activate() in DotNET

Hi all,

I'm looking for a way to autostart my dotnet macro according to a certain drawing opening.

 

I know how to auto netload my dll

I know in vba using events to start the macro when my drawing is opened :

 

Private Sub AcadDocument_Activate()
   Start.MyVbaMacro
End Sub

 

But how do I manage it in DotNET? I don't want to use vbaenabler...

 

Thanks,

Michel

7 REPLIES 7
Message 2 of 8
Alfred.NESWADBA
in reply to: Mitch_31

Hi,

 

>> I know in vba using events to start the macro when my drawing is opened

To get EventHandler defined you first have to load an application. At least within one application you don't have a chance to get loaded only for specific drawings as the descission "load the DLL or not" has to be done by a program and so it has to be loaded at least the part that defines the EventHandler.

 

To automatically get dotNET applications loaded look to >>>this blog<<< to see how you can load a dotNET-DLL automatically.

 

And one primitive method (if you don't want to make changes to the registry) could be to write a LISP-command into the ACAD.LSP so the DLL get loaded with AutoCAD-startup:

(command "_-NETLOAD" "\\mypath\\mydll.dll")

 

- alfred -

------------------------------------------------------------------------------------
Alfred NESWADBA
Ingenieur Studio HOLLAUS ... www.hollaus.at ... blog.hollaus.at ... CDay 2024
------------------------------------------------------------------------------------
(not an Autodesk consultant)
Message 3 of 8
Mitch_31
in reply to: Alfred.NESWADBA

Thanks for the answer Alfred, the blog is helpfull...

 

AutoNetloading my dll is OK.

 

My problem is :

 

1) I open a specific drawing

2) my macro autostarts only when this specific drawing is opened.

 

In vba, I add vba code (AcadDocument_Activate) in this specific drawing, which trigger my macro.

 

Is it possible to add dotnet events in a spécific dwg?? It seems no... Is there another way??

 

Cheers,

Michel

 

 

Message 4 of 8
Alfred.NESWADBA
in reply to: Mitch_31

Hi,

 

>> Is it possible to add dotnet events in a spécific dwg??

No, you can load your DLL with the application with a defined event handler that catches every drawing-open ... then check if the DWG is a drawing of interest or not, so run your commands for this DWG (or not).

 

- alfred -

------------------------------------------------------------------------------------
Alfred NESWADBA
Ingenieur Studio HOLLAUS ... www.hollaus.at ... blog.hollaus.at ... CDay 2024
------------------------------------------------------------------------------------
(not an Autodesk consultant)
Message 5 of 8
cincir
in reply to: Mitch_31

You can use 

public event DocumentCollectionEventHandler DocumentToBeActivated;

 event of Application.DocumentManager. but you must run it in ApplicationContext.

Message 6 of 8
Mitch_31
in reply to: cincir

 

Hummm, Lovely DotNet automations ;-(((

 

I don't know the name of that drawing... Perhaps the user had to rename it according to naming convention purpose...

 

I think I'm going to make a classic Menu Button, and check first if the drawing contains the prerequisites...

 

Thanks for help.

M.

 

Message 7 of 8
cincir
in reply to: Mitch_31

if not my memory serves me wrong Database object has some fields for user defined values. you can check them also to determine if it is proper Document to process.

 

you are welcome.

Message 8 of 8
AubelecBE
in reply to: cincir

hi. i think you can use the var USERI1, USERI2 ... 5

this saved in the drawing so you need to check a value in this var when the doc opened

 

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