The SimConnect_RequestDataOnSimObjectType function is used to retrieve information about simulation objects of a given type that are within a specified radius of the user’s aircraft.

 

Syntax
HRESULT SimConnect_RequestDataOnSimObjectType(
    HANDLE  hSimConnect,
    SIMCONNECT_DATA_REQUEST_ID  RequestID,
    SIMCONNECT_DATA_DEFINITION_ID  DefineID,
    DWORD  dwRadiusMeters,
    SIMCONNECT_SIMOBJECT_TYPE  type
    );

 

Parameters
ParameterDescriptionType
hSimConnectHandle to a SimConnect object.Integer
RequestIDSpecifies the ID of the client defined group.Integer
DefineIDSpecifies the ID of the client defined data definition.Integer
dwRadiusMetersDouble word containing the radius in meters. If this is set to zero only information on the user aircraft will be returned, although this value is ignored if type is set to SIMCONNECT_SIMOBJECT_TYPE_USER. The error SIMCONNECT_EXCEPTION_OUT_OF_BOUNDS will be returned if a radius is given and it exceeds the maximum allowed (200,000 meters, or 200 Km).
typeSpecifies the type of object to receive information on. One member of the SIMCONNECT_SIMOBJECT_TYPE enumeration type

 

Return Values

The function returns an HRESULT. Possible values include, but are not limited to, those in the following table.

Return valueDescription
S_OKThe function succeeded.
E_FAILThe function failed.

 

Example
void CALLBACK dispatchEvents(SIMCONNECT_RECV*  pData, DWORD  cbData, void *  pContext)
{
HRESULT hr;
switch (pData->dwID)
    {
    case SIMCONNECT_RECV_ID_EVENT:
        {
        SIMCONNECT_RECV_EVENT *evt = (SIMCONNECT_RECV_EVENT*)pData;
        switch (evt->uEventID)
            {
            case STARTUP:
                stats.lastDeleted = 0;
                stats.nrOfDeletions = 0;
                stats.nrOfRequests = 0;
                // Now the sim is running, request information on the user aircraft
                hr = SimConnect_RequestDataOnSimObjectType(hSimConnect, R1, AIPARKDATA, conf.radius, SIMCONNECT_SIMOBJECT_TYPE_AIRCRAFT);
                ++stats.nrOfRequests;
                break;
            case R2:
                fsecCnt++;
                if (fsecCnt >= (conf.requestEveryXSec/4))
                    {
                    fsecCnt = 0;
                    if (SUCCEEDED(SimConnect_RequestDataOnSimObjectType(hSimConnect, R1, AIPARKDATA, conf.radius, SIMCONNECT_SIMOBJECT_TYPE_AIRCRAFT)))
                        {
                        ++stats.nrOfRequests;
                        }
                    }
                break;
            }
        break;
    // further cases here
    default:
        printf("\nReceived:%d", pData->dwID);
        break;
    }
}