SavedQuery object

AutoCAD Map 3D ActiveX

SavedQuery object

A query saved in a query library.

Created by the QueryCategory.Add, QueryCategory.AddFromFile, or Query.Save method.

You can save internal queries or queries from an external file in the query library. The properties of the saved query name it and indicate whether it resides in an external file. If the query is external, another property represents its path.

The following example shows how to create, retrieve, and execute a saved query.

Dim atdr As AttachedDrawing

Dim amap As AcadMap

Dim prj As Project

Dim qry As Query

Dim mainqrybr As QueryBranch

Dim qrylf As QueryLeaf

Dim boolVal As Boolean

Dim i As Integer, cqryct As Integer

Dim j As Integer, cqry As Integer

Dim sqry As SavedQuery

 

Set amap = ThisDrawing.Application. _

GetInterfaceObject("AutoCADMap.Application") 

Set prj = amap.Projects(ThisDrawing)

prj.CurrQuery.Clear

Set atdr = prj.DrawingSet.Add("MAPTUT:\\citymap7.dwg")

Set qry = prj.CurrQuery

qry.Clear

Set mainqrybr = qry.QueryBranch

Set qrylf = mainqrybr.Add(kLocationCondition, kOperatorAnd)

qrylf.SetLocationCond kLocationInside, prj.MapUtil.NewLocationAll

qry.Mode = kQueryDraw

qry.Define mainqrybr

qry.Save False, 0, "DrawingCategory", "MyInternalquery", _

"Qry in library", "" 

For i = 0 To prj.QueryCategories.Count - 1

If prj.QueryCategories(i).Name = "DrawingCategory" Then 

cqryct = i 

End If 

Next i

For j = 0 To prj.QueryCategories.Item(cqryct).Count - 1

If prj.QueryCategories.Item(cqryct).Item(j).Name = "MyInternalquery" Then 

cqry = j 

End If 

Next j

Set sqry = prj.QueryCategories.Item(cqryct).Item(cqry)

prj.CurrQuery.Load (sqry)

prj.CurrQuery.Execute

ThisDrawing.Application.ZoomExtents