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
Solved! Go to Solution.
Solved by norman.yuan. Go to Solution.
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