In the example Simvars.exe … I can set the value AUTOPILOT VERITICAL HOLD
(1 and 0 ) … how do I accomplisth this in C# ?

this event doesn’t seem to work

TransmitEvent(EventEnum.AUTOPILOT_VERITICAL_HOLD, evtText.ToString());

// evtText is “1” or “0”


Events are separate from variables. Simvars only changes simulation variables, and doesn’t touch events. You can also see the source code for Simvars (which is written in C#). If you can successfully activate vertical hold by setting AUTOPILOT VERTICAL HOLD to 1, then you should be able to do the exact same thing in your C# function, by calling the same SetDataOnSimObject command. The line where this happens on Simvars is line 601:

// C#
m_oSimConnect.SetDataOnSimObject(m_oSelectedSimvarRequest.eDef, SimConnect.SIMCONNECT_OBJECT_ID_USER, SIMCONNECT_DATA_SET_FLAG.DEFAULT, dValue);

my guess is you could just invoke something like this instead:

// C#
m_oSimConnect.SetDataOnSimObject(MyDataDefinition, SimConnect.SIMCONNECT_OBJECT_ID_USER, SIMCONNECT_DATA_SET_FLAG.DEFAULT, 1);

where MyDataDefinition is defined to explicitly have AUTOPILOT_VERTICAL_HOLD.

That being said, I’ve only engaged with the SDK using C++. In C++ it would be written as:

// C++
 hr = SimConnect_SetDataOnSimObject(hSimConnect, MyDataDefinition, SIMCONNECT_OBJECT_ID_USER, 0, 0, 0, 1);

where MyDataDefinition is defined to explicitly have AUTOPILOT_VERTICAL_HOLD.

Sorry for the long response, hopefully it was helpful. Let me know if you need me to clarify anything!

1 Like

thank you … very clear . I just did get the SetDataOnSimObject to work with position (latitude and longitude) ! very cool! (first time I’ve succeeded with that). So I’ll try the AP VERTICAL HOLD next… thanks again it really helped.

1 Like

Glad I could help! I also was very confused at first, but after looking at the source code for SimVars I began to realize the methodology for implementing something similar into my own program. It was also very confusing how the function calls are similar but not identical between C# and C++. If you have any issues with the VERTICAL HOLD stuff, let me know. Regardless, I’d be interested to hear if you were successful in your goals!