.NET

Reply
Contributor
Mitch_31
Posts: 17
Registered: ‎02-19-2007
Message 1 of 8 (227 Views)

Event AcadDocument_Activate() in DotNET

227 Views, 7 Replies
01-25-2012 07:37 AM

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

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

Re: Event AcadDocument_Activate() in DotNET

01-25-2012 07:48 AM 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
-------------------------------------------------------------------------
Contributor
Mitch_31
Posts: 17
Registered: ‎02-19-2007
Message 3 of 8 (222 Views)

Re: Event AcadDocument_Activate() in DotNET

01-25-2012 08:07 AM 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

 

 

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

Re: Event AcadDocument_Activate() in DotNET

01-25-2012 08:15 AM 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
-------------------------------------------------------------------------
Active Contributor
cincir
Posts: 32
Registered: ‎08-12-2011
Message 5 of 8 (217 Views)

Re: Event AcadDocument_Activate() in DotNET

01-25-2012 08:15 AM in reply to: Mitch_31

You can use 

public event DocumentCollectionEventHandler DocumentToBeActivated;

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

Contributor
Mitch_31
Posts: 17
Registered: ‎02-19-2007
Message 6 of 8 (209 Views)

Re: Event AcadDocument_Activate() in DotNET

01-25-2012 08:28 AM 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.

 

Active Contributor
cincir
Posts: 32
Registered: ‎08-12-2011
Message 7 of 8 (202 Views)

Re: Event AcadDocument_Activate() in DotNET

01-25-2012 09:15 AM 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.

Valued Mentor
AubelecBE
Posts: 373
Registered: ‎01-27-2010
Message 8 of 8 (194 Views)

Re: Event AcadDocument_Activate() in DotNET

01-25-2012 10:18 AM 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

 

You are not logged in.

Log into access your profile, ask and answer questions, share ideas and more. Haven't signed up yet? Register

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 to get help installing your software.

Ask the Community