C# using the SDK
I can load the default MSFS FlightPlan with this code …
-
HOW DO I SAVE IT TO A FILE? a complex object?
-
WHY is this not updated to match the real flight plan.
this flight plan is always weird and not one that I can use.
public FlightPlan23 LoadFlightPlan23(string filePath)
{
var doc = XDocument.Load(filePath);
var flightPlanElement = doc.Element(“SimBase.Document”).Element(“FlightPlan.FlightPlan”);
var flightPlan = new FlightPlan23
{
Title = GetElementValue(flightPlanElement, "Title"),
FPType = GetElementValue(flightPlanElement, "FPType"),
RouteType = GetElementValue(flightPlanElement, "RouteType"),
CruisingAlt = double.Parse(GetElementValue(flightPlanElement, "CruisingAlt")),
DepartureID = GetElementValue(flightPlanElement, "DepartureID"),
DepartureLLA = GetElementValue(flightPlanElement, "DepartureLLA"),
DestinationID = GetElementValue(flightPlanElement, "DestinationID"),
DestinationLLA = GetElementValue(flightPlanElement, "DestinationLLA"),
Descr = GetElementValue(flightPlanElement, "Descr"),
DeparturePosition = GetElementValue(flightPlanElement, "DeparturePosition"),
DepartureName = GetElementValue(flightPlanElement, "DepartureName"),
DestinationName = GetElementValue(flightPlanElement, "DestinationName"),
ATCWaypoints = flightPlanElement.Elements("ATCWaypoint").Select(e => new ATCWaypoint23
{
ID = e.Attribute("id").Value,
ATCWaypointType = GetElementValue(e, "ATCWaypointType"),
WorldPosition = GetElementValue(e, "WorldPosition"),
SpeedMaxFP = double.Parse(GetElementValue(e, "SpeedMaxFP")),
ICAOIdent = GetElementValue(e, "ICAO.ICAOIdent")
}).ToList()
};
return flightPlan;
}
the class is this
public class FlightPlan23
{
public string Title { get; set; }
public string FPType { get; set; }
public string RouteType { get; set; }
public double CruisingAlt { get; set; }
public string DepartureID { get; set; }
public string DepartureLLA { get; set; }
public string DestinationID { get; set; }
public string DestinationLLA { get; set; }
public string Descr { get; set; }
public string DeparturePosition { get; set; }
public string DepartureName { get; set; }
public string DestinationName { get; set; }
public List ATCWaypoints { get; set; }
public FlightPlan23()
{
}
}
something starting with (i suspect)
doc.Save
thanks