Clear Method

Back to Methods Reference

Clears the specified selection set of all items.

Signature

VBA : object.Clear

VL : (vla-Clear object)

(vla-Clear newSset)

  • Object : SelectionSet
    The object or objects this method applies to.

Remarks

Items cleared from a selection set remain in the drawing; they are simply no longer associated to the selection set.

To clear a subset of the items in a selection set, use the RemoveItems method.

This method differs from the Delete method in that it does not remove objects from the drawing.

Example :


;Example:
;In the following sample code, a new selection set is created
;by name if it doesn't already exist. It is merely populated
;by picking objects on the screen and then emptied.
;After completion, the selection set still exists, but is empty.
;This is kind of a silly example, but it shows a way to use the method.

(defun c:al-Clear (/ acadobj doc ssetCollection a flag)
  (setq acadobj (vlax-get-acad-object)
        doc      (vla-get-activedocument acadobj)
        ;;get hold of the selectionSet Collection
        ssetCollection (vla-get-selectionsets doc)
        a       0
  )
  (repeat (setq w (vla-get-count ssetCollection))
    (if (= (vla-get-name (vla-item ssetCollection a)) "NEW_SET")
      (setq flag T)
    )
    (setq a (1+ a))
  )
  ;;check if the selectionSet already exists - otherwise, create it
  (if (null flag)
    (setq newSset (vla-add ssetCollection "NEW_SET"))
  )
  ;;let the user select objects on screen
  (vla-selectOnScreen newSset)
  ;;report the number of objects held in selectionSet
  (mapcar 'princ
    (list "\n"
          (vla-get-count newSset)
          " objects were added to the selection set"
    )
  )
  ;;clear the selectionSet
  (vla-Clear newSset)
  ;;report result
  (mapcar 'princ
    (list "\nAfter clearing, the selection set now holds "
          (vla-get-count newSset)
          " objects"
    )
  )
  (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