• 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.

Simconnect_data_initposition

Messages
1
This is what I have envisioned and I'm apparently not correct because the SIMCONNECT_DATA_INITPOSITION is private and cannot be set in this fashion. What am I missing here..?

Dim init_truck As SIMCONNECT_DATA_INITPOSITION

With init_truck
init_truck.altitude = 8
init_truck.latitude = 35.77
init_truck.longitude = -84.76
init_truck.pitch = -0.0
init_truck.bank = -1.0
init_truck.heading = 180.0
init_truck.onground = 1
init_truck.airspeed = 0
End With

fsx_simconnect.AICreateSimulatedObject("VEH_jetTruck", init_truck, DATA_REQUESTS.TRUCK)

I'm not so sure this isn't a lesson about VB.NET or SimConnect. This is simple, or should be. I'm just trying to create a simple truck. A similar C-based example is as follows (only for aircraft).

{
SIMCONNECT_DATA_INITPOSITION Init;
HRESULT hr;

// Add a parked museum aircraft, just west of the runway

Init.Altitude = 433.0; // Altitude of Sea-tac is 433 feet
Init.Latitude = 47 + (25.97/60); // Convert from 47 25.97 N
Init.Longitude = -122 - (18.51/60); // Convert from 122 18.51 W
Init.Pitch = 0.0;
Init.Bank = 0.0;
Init.Heading = 90.0;
Init.OnGround = 1;
Init.Airspeed = 0;
hr = SimConnect_AICreateSimulatedObject(hSimConnect, "Douglas DC-3", Init, REQUEST_DOUGLAS);

See how they can set the SIMCONNECT_DATA_INITPOSITION so easily? Why does VB.NET turn this into a nightmare..? I must be missing something so basic (in Visual Basic) that, well, it can't be good.

Any much needed light you could shed on this issue would be greatly appreciated.

Thanks Guys.
 
I'm not a .NET guy but what about...

Dim init_truck As new SIMCONNECT_DATA_INITPOSITION ( )

since this is a structure.

Can't get my head around this managed code stuff. Still locked in C++ MFC.
 
Last edited:
Rusty in VB.NET, but as RonH points out, it's probably because the object is not instantiated. A struct is very similar to a class in .NET.


Dim init_truck As SIMCONNECT_DATA_INITPOSITION = new SIMCONNECT_DATA_INITPOSITION()

In C#, you'd do

SIMCONNECT_DATA_INITPOSITION Init_Truck = new SIMCONNECT_DATA_INITPOSITION();

Init_Truck.Altitude = 0;
...

In C#, I'd expect a null object reference error, in VB.NET, I don't know.

Hope this helps,

Etienne
 
Another thing is you may have to qualify all class and structs with

Microsoft.FlightSimulator.SimConnect.

Dim init_truck As Microsoft.FlightSimulator.SimConnect.SIMCONNECT_DATA_INITPOSITION = new Microsoft.FlightSimulator.SimConnect.SIMCONNECT_DATA_INITPOSITION()
 
Yes full qualifying the structure name as Microsoft.Flightsimulator.SimConnect.SIMCONNECT_DATA_INITPOSITION does the trick. Must be full qualified even or better especially when there is an #imports "Microsoft.Flightsimulator.SimConnect" in the source. I guess there is also a private instance of this struct named the same in some module of SimConnect and that is found first by VS8 before the public declaration is found.

Creating an instance with New for structures is not necessary in VB since dim'ed structs are always values and not references.
 
Thanks,

Can you answer a question? How do we know that these are structs , enums or classes?

If I look at ILDasm I see things like

.class value public <- is this a struct or class

.class public < - is this a calss

.class enum public < - assume this is a enum

TIA

Also agree structs do not need new but am I correct that classes do since they require ref.
 
I just know it since the tool tip help in visual studio says what object type an item is.

It could actually be that the VB compiler compiles a structure as a class so that ILDasm wouldn't see any difference. Structures in VB can have properties and methods, even a New() method (with restrictions) so they are pretty similar to classes anyway.
 

Attachments

  • Structure.gif
    Structure.gif
    10.7 KB · Views: 551
Thank-you DocMoriarty,

I guess I should actually read the tool tips.
 
Back
Top