How to set AUTOPILOT VERITICAL HOLD

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”

thanks

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!

NOW I just need to be able to set a DIRECT TO Waypoint and I’ll be near completion of my application.

C# I’m using the MSFS stock A320 and the C172 G1000.

I am able to read the list of waypoints, destination airport and destination runway, but when I do a goaround (and other time) I need to set a waypoint and DIRECT TO function. Can I do this with a EVENT?

I have GPS IS DIRECTTO FLIGHTPLAN set but need to set the waypoint for it

NOTE:
I HAVE FOUND this in the docs but It is for an AI aircraft

can I use this? but what is my current AIAircraftID ??

to send data in an array, copy the array to a polymorphic object array. For example, to apply a waypoint list to an AI aircraft, go through the following steps using C#:

simconnect.AddToDataDefinition(DEFINITIONS.1,"AI WAYPOINT LIST", "number", SIMCONNECT_DATATYPE.WAYPOINT, 0.0f, SimConnect.SIMCONNECT_UNUSED);

o send data in an array, copy the array to a polymorphic object array. For example, to apply a waypoint list to an AI aircraft, go through the following steps using C#:

simconnect.AddToDataDefinition(DEFINITIONS.1,"AI WAYPOINT LIST", "number", SIMCONNECT_DATATYPE.WAYPOINT, 0.0f, SimConnect.SIMCONNECT_UNUSED);

Object[] objv = new Object[waypoints.Length]; waypoints.CopyTo(objv, 0

simconnect.SetDataOnSimObject(DEFINITIONS.WaypointDef, AIAircraftID, SIMCONNECT_DATA_SET_FLAG.DEFAULT, objv);