ade_qryexecute

Land Desktop Development ARX CPP SDK

Up a level
ade_qryexecute
 
 

Executes the current query.

ads_real

ade_qryexecute();

Returns the number of queried objects. If none, it returns 0.0.

Executing a query makes a new selection set of the queried objects if the "MkSelSetWithQryObj" option is turned on, as in the following:

struct resbuf* pSetPrefValRb = acutBuildList(RTT, 0);
ade_prefsetval("MkSelSetWithQryObj", pSetPrefValRb);
acutRelRb(pSetPrefValRb);

The "P" argument identifies the "previous" selection set (the objects currently or most recently selected).

Note  Whenever you create a selection set, you replace the previous selection set. Make sure you know which objects you are getting. The will query run slower in this case because of the extra work involved.

The following sample sets the MkSelSetWithQryObj option which will place the resulting queried objects in a selection set of your specification. Ade_qryexecute() is called and the number of objects placed into the selection set is displayed. The Resbuf is released as required and the selection set is freed.

ads_name ssQueriedObjects;
char* pszOptionVar = "MkSelSetWithQryObj";
struct resbuf* pSetPrefValRb = acutBuildList(RTT, 0);
int nResultCode = ade_prefsetval(pszOptionVar, pSetPrefValRb);
if (RTNORM == nResultCode) {
    ads_real queriedObjects = ade_qryexecute();
    if (ADE_NULLID != queriedObjects) {
        acedSSGet("P", NULL, NULL, NULL, ssQueriedObjects);
        long ssQueriedObjectsLength;
        acedSSLength(ssQueriedObjects, &ssQueriedObjectsLength;);
        acutPrintf(
        "\n%d objects have been placed in the \"QueriedObjects\" selection set."
        , ssQueriedObjectsLength);
    }
    else {
        acutPrintf(
            "\nNo objects were queried.");
    }
}
else {
    acutPrintf(
        "\nThe specified options variable has not been modified.");
}
acutRelRb(pSetPrefValRb);
int resultCode = acedSSFree(ssQueriedObjects);