FSX:SE SimConnect removes my AI object

I have a system set up that loads a number of AI object(s) from a list specified in a plain txt file. They get read in and loaded as soon as the main user object has been loaded from FSX's FLT file.

When I load the AI object just after the main user object, it is read in and loaded, and the new object ID is issued and everything seems fine... except, immediately after, server rejects the AI object by issuing "ObjectRemoved " system event and removes the object.

To check my sanity level, I rigged a little Sleep() command to cause a pause, and if I give it about 3.5 seconds of wait time, everything loads properly.

Also, I rigged the AI loading on a custom key press, and again, everything works ok.

The related SDK demo AI Objects and Waypoints loads AI objects on key press, so I never noticed this. It seems as if the system needs a bit of time to put everything on screen, and then perhaps it is ready to accept AI objects. Is there a system event that would notify me when the "picture"appears upon loading the sim? SimStart, SimStop and Sim events are unreliable (as per SDK's own admmission) as they get fired several times during the sim loading.

Any insight on this would be really helpful!


Resource contributor
Are you doing this from a gauge or module? Keep in mind that each gets loaded twice - I think the first time is just checking for dependencies, but the stuff in module_init and module_deinit does get executed. If you're using a gauge, you could try waiting until you get an instance of PANEL_SERVICE_PRE_UPDATE or PANEL_SERVICE_PRE_DRAW before you load the AI stuff.
In any event, the quick and dirty solution might be to subscribe to the 4sec event and wait until you get at least one instance of it before you load anything.
Hi, thanks!!

This is my own DLL module, not a gauge. Yeah, I already have the 4sec event trigger set up so I'll probably have to go down that route until I can figure out something more elegant.

At first I thought it is some kind of an AI LOD trigger that gets rid of the very far AI objects (which could easily be the case, since my objects are in orbit), so to make sure this isn't the case, I set the Init structure to locate the AI object near my aircraft... but no help there.
I implemented the load on 1sec event trigger and it works nicely. Just as I thought, it starts counting at or around the moment the sim visually appears. I wish it had a 0.1s trigger, I think that would solve it nicely ;)

[EDIT] Oh! 6Hz! let's try that...
[EDIT] I managed to squeeze 4/6th of a second (0.6666s)... It wouldn't go for 0.5 seconds. Funny how there is obviously some kind of a critical timing issue here. I can live with this, although I'll still keep an eye out for a more elegant solution.
Last edited:


Resource contributor
I was thinking a little more about this...
If you keep the timing that tight, is it going to work on my P3-866 with the kick-ass nVidia 128 Mb GF3 PCI graphics card?
I was thinking a little more about this...
If you keep the timing that tight, is it going to work on my P3-866 with the kick-ass nVidia 128 Mb GF3 PCI graphics card?
LOL I thought I had the crappiest FSX machine on the planet, but you sir are really brave to fly with 15yr old hardware :D

I actually realised the very same thing, and created a user-defined parameter that lets user set a number of 6Hz steps as "wait time" before the load happens. In my previous post I indicated that 4 steps (0.66s) was working, but just after that I realised it was 50-50 of the time this worked. So I implemented a delay parameter which I set to 12 (2 seconds) in my case, just to be sure it loads every time and it doesn't annoy me. People with monster gear can adjust this down to their liking ;)

However... STILL open to a more elegant solution. I'd love to know (Anyone from LMart/P3D camp?) the inner workings of this, and how to properly address it.


Resource contributor
Well, I was really kidding about using that kind of hardware myself, but it did occur to me, as it did you, that someone using older hardware might have issues with timing.
Was going to suggest the very thing you chose yourself.

Alright... yes, I noticed that sometimes I have difficulties detecting sarcasm :D.

Back to the topic, I wonder if it would be worth posting this on P3D Forum?
Last edited:
I do have the same issue: http://www.fsdeveloper.com/forum/th...-removed-directly-after-adding-it-why.439356/

I have not yet found a pattern or root cause. However.
After the AI failed (added -> removed) I can add it some time later.
Thanks for weighing in on this. As I was mentioning, my "solution" was to wait 2 seconds before adding objects. It works well, never fails... but there is that annoying pause and then the "POOF" the AI object materialises, making it look rather unrealistic. Too bad...
Misho, sorry for the interuption on this forum, but what is the correct forum to reach you regarding Terrabuilder Pro? I've tried several other forums, but have had no reply.
SimStart/stop is fully reliable in my experience, just that at the first loading you'll get a Start then immediate Stop, followed by another Start. I just wait until the second start to add my initial objects and flag to the rest of my code FSX is running. I've never encountered problems with instant removals doing it that way.

You also get one Stop message if the user exits to the menus, and one Start when they return. Then if terrain is re-loaded, one Stop then one Start after it's done. I'm not sure what happens if you try to add objects when you're in "SimStop" state, but I don't.

The only other "ObjectRemoved" message I've seen (other than from my RemoveObject requests) is if I place or move an object completely underground (or inside a mountain).

If you use the AI to move objects, I think you'll also get a "removed" message if they are outside the "reality bubble." However, if you release the object's AI with SimConnect_AIReleaseControl() when you get the SIMCONNECT_RECV_ID_ASSIGNED_OBJECT_ID message (for example if you plan to move the objects around yourself), at least I've found they don't get auto-removed even if beyond the bubble.
Last edited:
Your "completely underground" comment got me thinking... and I think you might be onto something here. When I load my objects, I assign them a completely "empty" (zeroed-out) SIMCONNECT_DATA_INITPOSITION structure (only so that SimConnect_AICreateSimulatedObject has something) and then I assign it my own position. I think that first init zero position causes it to reject it (as I am obviously placing the object underground. Way WAY underground o_O).

I'll go and test this ASAP... but something's telling me that's the culprit. Many thanks!!!
If it's not that, and you're not creating AI objects, there might a sanity check that if the position is more than e.g. 100 or 1000 nm away, delete it. 0 latitude/longitude would put it near Africa. Maybe only create it when you know the initial position?
I do remember having issues with 0/0/0 position. Maybe change it before spawning the object...

Also make sure you don't have GSX running, that has a tendency to delete simconnect placed objects.