Queries Detail

AutoCAD Map 3D ObjectARX

 
Queries Detail
 
 
 

After a query has been defined, it can be saved externally and subsequently loaded into an application, where it can be executed or modified.

The building blocks for creating a query definition are query conditions and query branches.

Query Conditions

The criteria that the query uses to select objects are expressed in query conditions. There are four types of query conditions.

  Description
Location Conditions Based on the location of objects relative to a boundary. There are several boundary types. See Location Boundaries below.
Property Conditions Based on a particular AutoCAD property.
Data Conditions Based on object data?information about drawing objects that is stored with drawing objects themselves.
SQL Conditions Based on data about drawing objects that is stored in external database tables and is specified by the WHERE clause of a SQL query.

Location Boundaries

There are several types of location boundaries. They are all represented by descendents of the AcMapLocationBoundary class, as illustrated in the following diagram.

For more information about query condition types, refer to AutoCAD Map 3D Help. On the Contents tab, click Using AutoCAD Map 3D > Queries > Defining Queries.

Query Branches

Query branches are trees composed of query conditions, possibly subordinate query branches, and join operators, which connect the components.

The following diagram illustrates the structure of a simple query branch, in which a, b, and c are query conditions and AND and OR are join operators. It expresses the query, a AND b or c.

Both query branches and query conditions inherit from the same base class, as shown in the following diagram.

To build a query

  1. Create one or more query conditions (also called query units or operands).
  2. Create one or more query branches.
  3. Append or insert query conditions onto the branch(es).
  4. Create the query definition by passing the query branch to the AcMapQuery::Define function.
  5. Create the query as an object in the project using the AcMapProject::CreateQuery function. This makes the query available to the application.
  6. Save the query definition in an external file or query library.

To execute a query

  1. You may want to set the mode, enable or disable property alteration, or create a report template for the query.
  2. Call AcMapQuery::Run to execute the query.

For More Information

For more information about queries, see the UI documentation, AutoCAD Map 3D Help, and the Map Samples folder of ObjectARX installations.