SelectByPolygon Method

Back to Methods Reference

Selects entities within a fence and adds them to the selection set.


VBA : object.SelectByPolygon Mode, PointsList, FilterType, FilterData

VL : (vla-SelectByPolygon object Mode PointsList FilterType FilterData)

(vla-SelectByPolygon newSet acSelectionSetFence tmp)

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

  • Mode : AcSelect enum; input-only

  • PointsList : Variant (array of doubles); input-only
    An array of 3D WCS coordinates specifying the selection fence.

  • 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.


The following selection modes are available:

  • Fence : Selects all entities crossing a selection fence. The fence is defined by coordinates in Point1.

  • WindowPolygon : Selects objects within a polygon defined by Point1.

  • CrossingPolygon : Selects objects within and crossing an area defined by a polygon. Use Point1 to define the coordinates of the polygon. AutoCAD will close the last vector of the polygon. A polygon definition cannot cross itself.

This method supports the filtering mechanism.

For more selection mode options, see the Select, SelectAtPoint, and SelectOnScreen methods.

Example :

(defun c:al-selectbypolygon ()


(setq thisdrawing (vla-get-activedocument

(setq ssets (vla-get-selectionsets thisdrawing))

(if (vl-catch-all-error-p 
    (vl-catch-all-apply 'vla-item (list ssets "$Set")))

  (setq newSet (vla-add ssets "$Set"))
    	(vla-delete (vla-item ssets "$Set"))
  	(setq newSet (vla-add ssets "$Set"))


  (setq pt (getpoint "\nSpecify start point: "))

  (setq ptlist (cons pt ptlist))

  (while (setq pt (getpoint "\nSpecify next point: " pt))

    (setq ptlist (cons pt ptlist))


  (setq ptlist (apply 'append ptlist))

  (if (= (rem (length ptlist) 3) 0)


        tmp (vlax-make-safearray 
               (cons 0 (- (length ptlist) 1))

(vlax-safearray-fill tmp ptlist)

(vla-SelectByPolygon newSet acSelectionSetFence tmp)





The AutoLisp/Visual Lisp/VBA Resource Website
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