Query.Save method

AutoCAD Map 3D ActiveX

Query.Save method

Saves the current query to the query library or an external file.

Save( External As Boolean, _
 kSaveOptions As ESaveQueryOptions, _
 Category As String, _
 Name As String, _
 Description As String, _
 Filename as String _
 ) As Boolean

Returns True on success.

External

True saves the query to the external file named Filename. False saves the query to the Query Library.

kSaveOptions

Specifies information to save externally.

Set the External property to True before using kSaveOptions.

You combine kSaveOptions with the + operator. For example, to save the coordinates of the query and the alter properties, enter kQrySaveCoordinates + kQrySaveAlteration.

Category

The name of the category to which the query is added.

Name

A unique name for the query.

Description

The query description.

Filename

The full path of the external file for saving the query.

To save a query to an external file, set External to True and specify the file name. Use a second backslash to delimit each backslash in the path.

The following example first saves a query with a description and a category name in an external file and then also saves it in the query library. You pass an empty string, as shown in the second call to Query.Save, instead of a file name to save the query in the library.

Dim amap As AcadMap

Dim prj As Project

Dim qry As Query

Dim mainqrybr As QueryBranch

Dim qrylf As QueryLeaf

Dim boolVal As Boolean

 

Set amap = ThisDrawing.Application. _

GetInterfaceObject("AutoCADMap.Application") 

Set prj = amap.Projects(ThisDrawing)

Set qry = prj.CurrQuery

qry.Clear

Set mainqrybr = qry.QueryBranch

Set qrylf = mainqrybr.Add(kLocationCondition, kOperatorAnd)

boolVal = qrylf.SetLocationCond(kLocationInside, _

prj.MapUtil.NewLocationAll) 

qry.Mode = kQueryDraw

boolVal = qry.Define(mainqrybr)

'Only if C:\\query.qry does not exist continue -- code not shown

boolVal = qry.Save( _

True, 0, "DrawingCategory", "myExternalquery", _ 

"Qry on disk", "C:\\query.qry") 

boolVal = qry.Save( _

False, 0, "DrawingCategory", "myInternalquery", _ 

"Qry in library", "")