ade_qryhandent

AutoCAD Map 3D AutoLISP

Up a level
ade_qryhandent
 
 

Gets the entity name for the specified handle .

(ade_qryhandent dwg_id handle)

Returns the entity name for the specified drawing ID and handle or nil.

dwg_id ID of the drawing in which the object resides (real)
handle Original handle of the object in the specified drawing.

This function provides access to the entity name of an object in a source database.

You must use the retrieved entity name immediately before you call any other function (except ade_expreval) or return control to AutoCAD.

Once you have the entity name of an object, you can use it with other functions. For example, you could use entget (or ads_entget) to retrieve the entity and its definition data.

To get the original handle of the object in the source drawing, use the ade_qrygetentlist function.

To obtain a drawing ID, use ade_dslist.

To get the ID of a drawing given a drawing file path, use ade_dwggetid.

The following code sample shows how you can combine ade_qrygetentlist and ade_qryhandent to count the number of objects in the source drawing that are of type line.

; clear out old query... 
(ade_qryclear) 
; define a new query
(ade_qrydefine '("" "" "" "Location" ("All") ""))

; initialize the count...
(setq total_count 0) 

; for each drawing in the drawing set...
(foreach dwg_id (ade_dslist)

   ; if the drawing is active
   (if (ade_dwgisactive dwg_id)
       (progn

          ; get the objects which satisfy the query...
          (setq handle_list (ade_qrygetentlist dwg_id))
          (foreach handle handle_list
             (setq ename (ade_qryhandent dwg_id handle))

             ; if it's a line, increment the counter
             (if (= (cdr (assoc 0 (entget ename))) "LINE")
                 (setq total_count (1+ total_count))
             )
          )
       )  ; progn
   )  ; if
)  ; foreach

ADSRX equivalent

int

ade_qryhandent(

ade_id dwg_id,

char* handle,

ads_name result);

Returns RTNORM or an error code.

result Output the entity name for the specified drawing ID and handle.