VBA
Discuss AutoCAD ActiveX and VBA (Visual Basic for Applications) questions here.
cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 

How to immediately activate my event handler in AutoCAD

2 REPLIES 2
SOLVED
Reply
Message 1 of 3
jan
Advocate
821 Views, 2 Replies

How to immediately activate my event handler in AutoCAD

Does anyone know the best way to ensure that an eventhandler inside an app is activated immediately when AutoCAD has opened the first document?

 

In the PackageContents.xml in C:\ProgramData\Autodesk\ApplicationPlugins\MyApplication.bundle I have set this:

<ComponentEntry AppName="MyApplication" Version="1.0.0" ModuleName="./Contents/Windows/MyApplication.dll" AppDescription="Some description" LoadOnAutoCADStartup="True">

 

However that does not activate my event handling function. Only after the user has called a command inside MyApplication the event handler works.

(I have checked that the variable APPAUTOLOAD is 14)

 

O know that I can make some workaround such as using (defun STARTUP::S() ...  in acad.lsp but to me that there must be a more elegant way of doing this?

 

Any ideas?

 

Regards

Jan Grenov

 

Tags (1)
2 REPLIES 2
Message 2 of 3
norman.yuan
in reply to: jan

It looks like you ask question on AutoCAD .NET API Add-in auto-loading. This forum group, in spite of its name "Visual Basic...", is traditionally for AutoCAD VBA/COM discussion. If you post to .NET forum group, you will get better responses.

 

Without seeing your code, it is a bit guessing: if in your code the said event handler is activated (hooed to an event) in your CommandMethod, then of course user has to call your command for the event handler to be hooked, regardless the DLL is auto-loaded or not.

 

If you want to start handling events as soon as your DLL is loaded (auto-loaded, or manually do "NETLOAD"), you can implement IExetensionApplication interface in your code. code in IExtensionApplication.Initialize() method runs as soon as the DLL is loaded into AutoCAD, which provides you the opportunity to set up your needed event handlers. Search "IExentionApplication in .NET forum discussion group and AotuCAD development online document.

Norman Yuan

Drive CAD With Code

EESignature

Message 3 of 3
jan
Advocate
in reply to: norman.yuan

Thanks a lot!
This was exactly what I was looking for.
... And next time I will try to address the correct (VB.NET) forum.

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

Post to forums  

Autodesk Design & Make Report

”Boost