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.

In the upcoming flighting, we've changed the behaviour of the content.xml file. If your addon uses this file, please read this article!

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


heliopsUK avatar image
heliopsUK asked heliopsUK answered

RequestDataOnSimObject returns exception


I'm trying to read the ObjectID following the creation of an object using AICreateSimulatedObject. This is an extract from the SimConnect Debug Log.

> 1458.77925 [342, 6]AICreateSimulatedObject:szContainerTitle="Ambulance03", InitPos=1119350480, RequestID=5
< 1458.78427 [342] AssignedObjectID: RequestID=5  ObjectID=438
> 1458.78480 [342, 7]RequestDataOnSimObjectType:RequestID=5, DefineID=1, dwRadiusMeters=100000, type=5
< 1458.78553 [342] >>>>>  EXCEPTION=3, SendID=7, Index=2  <<<<<

I should add that the object is created without any problem, it just keeps wandering off on it's own little journey down the hill! Basically, I'm trying to read the ObjectID to then send some waypoints.

I'm using the Python SimConnect library coupled with the Python MobiFlight WASM Module.

Any help greatly appreciated!

10 |10000

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

BenBaron85 avatar image
BenBaron85 answered BenBaron85 edited


I think you actually got the use-case of RequestDataOnSimObjectType() wrong.

What you'd normally do in your case is listening to SIMCONNECT_RECV_ID_ASSIGNED_OBJECT_ID in your SimConnect dispatch procedure after the SimConnect_AICreateSimulatedObject() call. Once that comes in, you cast the SIMCONNECT_RECV* into SIMCONNECT_RECV_ASSIGNED_OBJECT_ID*.

From that you can finally match your RequestId and get an ObjectId that you can then use in later to send a list of waypoints.

Greets, Ben

10 |10000

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

heliopsUK avatar image
heliopsUK answered

Hi Ben,

That's brilliant thanks! Completely misread that bit of the SDK docs! For those of you using Python SimConnect here is what I've done in a very hacky kinda way:

1. Add a new elif clause to the my_dispatch_proc function in

            pObjData = cast(
            objectId = pObjData.dwObjectID
            os.environ["OBJECT_ID"] = str(objectId)

2. Create a Sim Object using AICreateSimulatedObject:

def createSimulatedObject(self, name, lat, lon, rqst, hdg=0, gnd=1, alt=0, pitch=0, bank=0, speed=0):
        simInitPos.Altitude = alt
        simInitPos.Latitude = lat
        simInitPos.Longitude = lon
        simInitPos.Pitch = pitch
        simInitPos.Bank = bank
        simInitPos.Heading = hdg
        simInitPos.OnGround = gnd
        simInitPos.Airspeed = speed

3. Sleep for 1 second and then print the os.environ["OBJECT_ID"]

Definitely isn't the prettiest code but works for what I need!


10 |10000

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

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 19.1 MiB each and 23.8 MiB total.