• Which the release of FS2020 we see an explosition of activity on the forun and of course we are very happy to see this. But having all questions about FS2020 in one forum becomes a bit messy. So therefore we would like to ask you all to use the following guidelines when posting your questions:

    • Tag FS2020 specific questions with the MSFS2020 tag.
    • Questions about making 3D assets can be posted in the 3D asset design forum. Either post them in the subforum of the modelling tool you use or in the general forum if they are general.
    • Questions about aircraft design can be posted in the Aircraft design forum
    • Questions about airport design can be posted in the FS2020 airport design forum. Once airport development tools have been updated for FS2020 you can post tool speciifc questions in the subforums of those tools as well of course.
    • Questions about terrain design can be posted in the FS2020 terrain design forum.
    • Questions about SimConnect can be posted in the SimConnect forum.

    Any other question that is not specific to an aspect of development or tool can be posted in the General chat forum.

    By following these guidelines we make sure that the forums remain easy to read for everybody and also that the right people can find your post to answer it.

P3D v4 RequestDataOnSimObject [Solved]

DragonflightDesign

Resource contributor
Messages
1,368
Country
northernireland
Gotta 'nother problem (sigh). It's vb.Net again and I can say two things before proceeding: the C++ equivalent works perfectly and if I use RequestDataOnSimObjectByType triggered from an event timer then it also works perfectly. This, however, never triggers except when the P3D connection is doing its startup checks.

Code:
p3d_simconnect.RequestDataOnSimObject(P3Data.REQUEST_FUEL, P3Data.DEFINE_FUEL_TANKS, LockheedMartin.Prepar3D.SimConnect.SIMCONNECT_SIMOBJECT_TYPE.USER, SIMCONNECT_PERIOD.SECOND, 0, 0, 0, 0)
Code:
    Friend Sub p3d_simconnect_OnRecvSimobjectData(ByVal sender As SimConnect, ByVal data As SIMCONNECT_RECV_SIMOBJECT_DATA)
        Select Case data.dwDefineID      {or Select Case data.dwRequestID}
            Case P3Data.REQUEST_FUEL
                Dim fuel As Fuel_Data = CType(data.dwData(0), Fuel_Data)
        End Select
Why am I using vb.Net? because I'm far more comfortable creating GUIs in vb.Net or C# than I am in C++.
 
Yah, well, it had to be something stupid. Missed a field out:
Code:
p3d_simconnect.RequestDataOnSimObject(P3Data.REQUEST_FUEL, P3Data.DEFINE_FUEL_TANKS, SIMCONNECT_SIMOBJECT_TYPE.USER, SIMCONNECT_PERIOD.SECOND, SIMCONNECT_DATA_REQUEST_FLAG.DEFAULT, 0, 0, 0)
Even though you have a timing flag (SIMCONNECT_PERIOD) you still have to add the REQUEST _FLAG and no, you won't find it in the SDK.
 
It gets better Bill. If you check the description for the VBManagedDataRequest it states that it illustrates the use of RequestDataOnSimObject. Err....

I spent an hour on websearching and found a few very well written questions on different fora (including here) asking about the method. Not one single one of those questions had attracted an answer. The answer finally came up as an irrelevance in a code illustration for an unrelated question.

I really, really hate to admit this; I bought a book today on creating GUIs using MFC just so I could avoid these problems.
 
Last edited:
Have you by any chance checked the P3Dv4.xxx SDK to see if this omission has carried through? If it has I'll try to remember to mention it to the L-M team so they can correct it. :pushpin:
 
Still in the latest 4.5 release...

Simconnect API | Samples | Samples | scroll down to Managed Code Samples | scroll down to VB Data Request | right hand column.

Should be SIMCONNECT_RECV_SIMOBJECT_DATA_BYTYPE only.
 
Back
Top