XPLMNavigation

To use:

import xp

The XPLMNavigation APIs give you some access to the navigation databases inside X-Plane. X-Plane stores all navigation information in RAM, so by using these APIs you can gain access to most information without having to go to disk or parse the files yourself.

You can also use this API to program the FMS. You must use the navigation APIs to find the navaids you want to program into the FMS, since the FMS is powered internally by X-Plane’s navigation database.

Flight Management Computer

Some aircraft have a Flight Management System which responds to these commands. Some do not. sigh. The Laminar G530 and G1000 work.

Note: the FMS works based on an array of entries. Indices into the array are zero-based. Each entry is a nav-aid plus an altitude. The FMS tracks the currently displayed entry and the entry that it is flying to.

The FMS must be programmed with contiguous entries, so clearing an entry at the end shortens the effective flight plan. There is a max of 100 waypoints in the flight plan.

countFMSEntries()

Returns the number of entries in the FMS.

>>> xp.countFMSEntries()
6

Official SDK XPLMCountFMSEntries

getDisplayedFMSEntry()

Return the index of the entry the pilot is viewing. (For XP 11.55, this appears to always return 0. This has been acknowledged by Laminar Research as bug XPD-11386. The X-Plane 10 737 works correctly, but the 737 which comes with X-Plane 11 does not.

Practically speaking, assume this does not work.

>>> xp.getDisplayedFMSEntry()
0

Official SDK XPLMGetDisplayedFMSEntry

getDestinationFMSEntry()

Return the index of the entry the FMS is flying to. (The “destination” refers to the active leg.) This is an index into the FMS, not into the navaid database.

>>> xp.getDestinationFMSEntry()
0

Official SDK XPLMGetDestinationFMSEntry

setDisplayedFMSEntry(index)

Change which entry the FMS is showing to the integer index specified. (For X-Plane 11.55, this does not appear to do anything. This has been acknowledged by Laminar Research as bug XPD-11386. Like getDisplayedFMSEntry(), this appears to work in X-Plane 11 only for older X-Plane 10 version of the 737 aircraft.)

>>> xp.setDestinationFMSEntry(3)

Official SDK XPLMSetDisplayedFMSEntry

setDestinationFMSEntry(index)

Change which entry the FMS is flying the aircraft toward.

>>> xp.getDestinationFMSEntry()
0
>>> xp.setDestinationFMSEntry(3)
>>> xp.getDestinationFMSEntry()
3

Official SDK XPLMSetDestinationFMSEntry

getFMSEntryInfo(index)

Returns information about the zero-based index entry in the FMS. Value returned is an object (see below).

A reference to a navaid can be returned allowing you to find additional information (such as a frequency, ILS heading, name, etc.). Some information is available immediately. For a lat/lon entry, the lat/lon is returned by this routine but the navaid cannot be looked up (and the reference will be XPLM_NAV_NOT_FOUND.

Note

X-Plane C SDK function takes many parameters, where the data is returned. The XPPython3 function takes a single parameter (Index) and returns all the values in an FMSEntryInfo object.

Object returned by getFMSEntryInfo() containing information about an entry. It has the following attributes:

type

XPLMNavType or XPLM_NAV_NOT_FOUND if this is a lat/lon entry

navAidID

str or None if this is a lat/lon entry

ref

XPLMNavRef or None

altitude

int (in feet)

lat

float latitude

lon

float longitude

Conveniently, it also has a str() representation

>>> info = xp.getFMSEntryInfo(0)
>>> info
<xppython3.FMSEntryInfo object at 0x7ff38c0a5040>
>>> info.navAidID
'LUCOS'
>>> info.ref
337064980
>>> print(info)
Fix: [337064980] LUCOS, (41.638, -70.768) @0'
>>> print(xp.getNavAidInfo(info.ref))
LUCOS (LUCOS) Fix (41.638, -70.768) ---

Official SDK XPLMGetFMSEntryInfo

setFMSEntryInfo(index, navRef, altitude=0)

This routine changes an entry at index in the FMS to have the destination navaid specified by navRef (as returned by findNavAid()) at altitude (in feet) specified. Use this only for airports, fixes, and radio-beacon navaids. Currently for radio beacons, the FMS can only support VORs and NDBs.

Use the setFMSEntryLatLon() fly to a lat/lon.

>>> navRef = xp.findNavAid(navType=xp.Nav_VOR)
>>> xp.setFMSEntryInfo(3, navRef, 1000)
>>> print(xp.getFMSEntryInfo(3))
VOR: [9469] ZDA, (44.095, 15.364) @1000'

Official SDK XPLMSetFMSEntryInfo

setFMSEntryLatLon(index, lat, lon, altitude=0)

This routine changes an entry at index in the FMS to have the destination specified by lat, lon at altitude (in feet) specified.

>>> xp.setFMSEntryLatLon(3, 34, -122.5, 1000)
>>> print(xp.getFMSEntryInfo(3))
LatLon: (34.000, -122.5) @1000'

Official SDK XPLMSetFMSEntryLatLon

clearFMSEntry(index)

Clears the given entry, potentially shortening the flight plan.

Official SDK clearFMSEntry

getGPSDestinationType()

Return the XPLMNavType of the current GPS destination.

>>> xp.getGPSDestinationType()
512

Official SDK XPLMGetGPSDestinationType

getGPSDestination()

Return the XPLMNavRef of current GPS destination.

>>> xp.getGPSDestination()
33706498
>>> print(xp.getNavAidInfo(xp.getGPSDestination()))
LUCOS (LUCOS) Fix (41.638, -70.768) ---

Official SDK XPLMGetGPSDestination

Constants

XPLMNavType

These enumerations define the different types of navaids. They are each defined with a separate bit so that they may be bit-wise added together to form sets of nav-aid types.

Nav_Unknown

=0

Nav_Airport

=1

Nav_NDB

=2

Nav_VOR

=4

Nav_ILS

=8

Nav_Localizer

=16

Nav_GlideSlope

=32

Nav_OuterMarker

=64

Nav_MiddleMarker

=128

Nav_InnerMarker

=256

Nav_Fix

=512

Nav_DME

=1024

Nav_LatLon

=2048

Note

Nav_LatLon is a specific lat-lon coordinate entered into the FMS. It will not exist in the database, and cannot be programmed into the FMS. Querying the FMS for navaids will return it. Use setFMSEntryLatLon() to set a lat/lon waypoint.

Official SDK XPLMNavType

XPLMNavRef

XPLMNavRef is an iterator into the navigation database. The navigation database is essentially an array, but it is not necessarily densely populated. The only assumption you can safely make is that like-typed nav-aids are grouped together.

Use XPLMNavRef to refer to a nav-aid.

XPLM_NAV_NOT_FOUND = -1

XPLM_NAV_NOT_FOUND is returned by functions that return an XPLMNavRef when the iterator must be invalid.

Official SDK XPLMNavRef