SelectOnScreen Method

Back to Methods Reference

Prompts the user to pick an object from the screen.

Signature

VBA : object.SelectOnScreen [FilterType][, FilterData]

VL : (vla-SelectOnScreen object FilterType FilterData)

(vla-selectOnScreen newsset filter_code filter_value)

  • Object : SelectionSet
    The object or objects this method applies to.
  • FilterType Integer; input-only; optional
    A DXF group code specifying the type of filter to use.
  • FilterData Variant; input-only; optional
    The value to filter on.


Remarks

This method supports the filtering mechanism.
AutoCAD's default prompt for picking an object will be used automatically.
For more selection mode options, see the Select, SelectByPolygon, and SelectAtPoint methods.

Refer to Visual Lisp - Selection Objects for more details.

Example :


(defun al-selectonscreen 
( / ssets acadDocument newsset ctr item 
    filter_code filter_value)

;load the visual lisp extensions
(vl-load-com)

;retrieve a reference to the documents object
(setq acadDocument (vla-get-activedocument
     (vlax-get-acad-object)))

;retrieve a reference to the selection sets object
(setq ssets 
(vla-get-selectionsets acadDocument))

;add a new selection set
(setq newsset (vla-add ssets "SS1"))

;create a single element array for the DXF Code
(setq filter_code 
(vlax-make-safearray vlax-vbinteger '(0 . 0)))

;create a single element array for the value
(setq filter_value 
(vlax-make-safearray vlax-vbvariant '(0 . 0)))

;DXF Code for layers
(vlax-safearray-fill filter_code '(8))

;the filter value
(vlax-safearray-fill filter_value '("7"))

;Use Select on Screen to select objects on Layer 7
(vla-selectOnScreen newsset filter_code filter_value)

;set the counter to zero
(setq ctr 0)

 ;count the number of objects and loop
 (repeat (vla-get-count newsset)

   ;retrieve each object
   (setq item (vla-item newsset ctr))

   ;check if the entity has a color property
   ;and it can be updated
  (setq check (vlax-property-available-p 
                    item "Color" T))

   ;if it can
   (if check
       
   ;change it's color
   (vlax-put-property item 'Color 5)

   );if

   ;increment the counter
   (setq ctr (1+ ctr))

 );repeat

  ;delete the selection set
  (vla-delete (vla-item ssets "SS1"))

  (princ)

);defun

(princ)
      

 
The AutoLisp/Visual Lisp/VBA Resource Website
Google
Search the WWW Search AfraLisp

Copyright 1999-Perpetuity by AfraLisp

All rights reserved.
Information in this document is subject to change without notice.
Site created and maintained by Kenny Ramage

The AutoLisp/Visual Lisp/VBA Resource Website