plane icon Welcome to Microsoft Flight Simulator’s SDK Q&A Platform!

You have questions regarding the SDK? DevMode Tools? SimConnect? You would like to submit an idea for future improvements, seek help or exchange knowledge? You’re in the right place.

Please take a moment to read the platform’s guidelines before you get started!


For HUDs issues management, please read the article here !

question

Kaiii3 avatar image
Kaiii3 asked Kaiii3 commented

SimConnect Event "ObjectAdded" trigger?

When is the SimEvent "ObjecteAdded" triggert? I have tested it with Live Traffic, Offline Traffic (BGL) as well as SimConnect based AI Traffic, but in all cases it was not triggert after a new AI Airplane was added in the Sim.

With the current issue (since SU5) that the Sim can crash when using lagacy (MDLX) models we are currently working on a workaround that will clear the local cache after a new SimObject was added (tests confimred that this is preventing the crash). When adding our Ai Objects va our own tool when can clean the cache before adding them but for a standalone workaround we need to know when the Sim added a SimObject by itself so the cache can be cleared for the next injection.

simconnect
10 |10000 characters needed characters left characters exceeded

Up to 5 attachments (including images) can be used with a maximum of 4.8 MiB each and 23.8 MiB total.

FlyingRaccoon avatar image
FlyingRaccoon answered Kaiii3 commented

Hello @Kaiii3

We checked your sample and found out you're not using the appropriate callback.
You need to have a callback for OnRecvEventObjectAddremove, not just for OnRecvEvent

private void Simconnect_OnRecvEventObjectAddremove(SimConnect sender, SIMCONNECT_RECV_EVENT_OBJECT_ADDREMOVE data)
{
    if (data.uEventID == (uint)EVENTS.SIMOBJECT_ADDED)
    {
        clearCache();
        Console.WriteLine("Clear: ObjectAdded");
    }
}

Regards,
Sylvain

2 comments
10 |10000 characters needed characters left characters exceeded

Up to 5 attachments (including images) can be used with a maximum of 4.8 MiB each and 23.8 MiB total.

FlyingRaccoon avatar image
FlyingRaccoon answered Kaiii3 commented

Hello.

The AITraffic SimConnect sample is using this event.
I was able to confirm it works with SimConnect based AI and LiveTraffic but I would assume it also works with offline traffic as well.

Did you check that sample?

Regards,
Sylvain

3 comments
10 |10000 characters needed characters left characters exceeded

Up to 5 attachments (including images) can be used with a maximum of 4.8 MiB each and 23.8 MiB total.

The sample is in C++, my Code is in C#. Will give it a go later the week.
0 Likes 0 ·
You could take a look at CsSimConnect then...
0 Likes 0 ·
Hey,


I ran the C++ sample and it worked. Running my project alongside did not trigger the C# SimConnect Event. I will send you the C#-Project.

0 Likes 0 ·

Write an Answer

Hint: Notify or tag a user in this post by typing @username.

Up to 5 attachments (including images) can be used with a maximum of 4.8 MiB each and 23.8 MiB total.