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.
The criteria that
the query uses to select objects are expressed in query conditions.
There are four types of query conditions.
on the location of objects relative to a boundary. There are several
boundary types. See Location Boundaries below.
on a particular AutoCAD property.
on object data?information about drawing objects that is stored
with drawing objects themselves.
on data about drawing objects that is stored in external database
tables and is specified by the WHERE clause of a SQL query.
There are several
types of location boundaries. They are all represented by descendents
of the AcMapLocationBoundary class, as illustrated in the following
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 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.
build a query
- Create one or more query conditions (also
called query units or operands).
- Create one or more query branches.
- Append or insert query conditions onto the
- Create the query definition by passing the
query branch to the AcMapQuery::Define function.
- Create the query as an object in the project
using the AcMapProject::CreateQuery function. This makes the query
available to the application.
- Save the query definition in an external
file or query library.
execute a query
- You may want to set the mode, enable or disable
property alteration, or create a report template for the query.
- 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.