SelectByPolygon Method

Back to Methods Reference

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

Signature

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
    acSelectionSetFence
    acSelectionSetWindowPolygon
    acSelectionSetCrossingPolygon

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

Remarks

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 ()

(vl-load-com)

(setq thisdrawing (vla-get-activedocument
     (vlax-get-acad-object)))

(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"))
  
     (progn
       
    	(vla-delete (vla-item ssets "$Set"))
       
  	(setq newSet (vla-add ssets "$Set"))
       
     );progn

);if

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

  (setq ptlist (cons pt ptlist))

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

    (setq ptlist (cons pt ptlist))

  );while

  (setq ptlist (apply 'append ptlist))

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

    (progn

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

(vlax-safearray-fill tmp ptlist)

(vla-SelectByPolygon newSet acSelectionSetFence tmp)

);progn

);if

(princ)

);defun

 
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