[Connect v17 C#] Issues With Key Ins in Addin Program Run From MS_DGNAPPS

Hi everyone, I hope someone can help me with the following issue:
I wrote a simple C# addin program that I intend to run automatically, via the MS_DGNAPPS config variable, when Connect is started and a dgn loaded. This addin program just needs to submit a few key in commands such as DMSG CLOSEDIALOG -79 to close the element selector dialog box and db=fakeu/fakepw@fakealias to connect the dgn file to our database.

Since this addin is loaded automatically via MS_DGNAPPS, I first put the session keyin calls in the addin's run method, which is run after the addin is loaded. The key ins didn't seem to take even though there were no errors. The element selector was open and not closed after the dgn file was fully loaded.

I figured that maybe these keyins were being submitted too early in the process of loading the dgn. I knew the addin class has event handlers, so I just assumed I would be able to find one for when the dgn file is fully loaded and I could just add the key ins there. I checked the documentation but was surprised to find out that no such event handler exists, as far as I can tell.

I tried many other event handlers including CmdWindowOpenEventHandler, ModelChangedEvent, BeforeNewDesignFileEvent etc.. But the behavior was no different than when I had the keyins in the run method.

When I used the NewDesignFileEvent event, it showed me that my theory was correct: Unlike the other events that I tried, with this event the element selector is visible on the screen when this event is fired. I could then see that when my code runs the element selector dialog does disappear, but for some reason Connect then shows the element selector dialog after it leaves my event handler while it finishes loading the dgn.

Note as test, I put my key ins into the LevelChangeEvent eventhandler in the addin class and then manually changed the level after the dgn file was fully loaded and my key ins worked perfectly, so I know my code is good. The issue is just the point the the process that my code is running when Connect is loading a dgn that is the issue.

Questions:
Am I missing something or is there an eventhandler for the addin class that fires when Connect fully loads a dgn file? This seems like such a basic requirement.

Is there possibly another way to automatically fire a key in command after Connect has fully loaded a dgn file? We do not want our users to have to manually key in commands.

Parents Reply Children
No Data