本帖最后由 marting 于 2020-5-11 21:18 编辑
给你个例子
 - (vl-load-com)
- (defun c:Example_Select()
- ;; This example adds members to a selection set, first by crossing and
- ;; then by filtering for circles.
- (setq acadObj (vlax-get-acad-object))
- (setq doc (vla-get-ActiveDocument acadObj))
- ;; Create the selection set
- (setq ssetObj (vla-Add (vla-get-SelectionSets doc) "SSET"))
-
- ;; Add all object to the selection set that lie within a crossing of (28,17,0) and
- ;; (-3.3, -3.6,0)
- (setq mode acSelectionSetCrossing
- corner1 (vlax-3d-point 28 17 0)
- corner2 (vlax-3d-point -3.3 -3.6 0))
- (vla-Select ssetObj mode corner1 corner2)
- (alert (strcat "Objects selected: " (itoa (vla-get-Count ssetObj))))
- (vla-Clear ssetObj)
-
- ;; Add all the Circles to the selection set that lie within the crossing of (28,17,0) and
- ;; (-3.3, -3.6,0) by filtering from the current drawing
- (setq gpCode (vlax-make-safearray vlax-vbInteger '(0 . 0)))
- (vlax-safearray-put-element gpCode 0 0)
- (setq dataValue (vlax-make-safearray vlax-vbVariant '(0 . 0)))
- (vlax-safearray-put-element dataValue 0 "Circle")
-
- (vla-Select ssetObj mode corner1 corner2 gpCode dataValue)
- (alert (strcat "Objects selected: " (itoa (vla-get-Count ssetObj))))
- (vla-Delete ssetObj)
- )
select方法
VBA:
object.Select Mode [, Point1] [, Point2] [, FilterType, FilterData]
object Type: SelectionSet
The object this method applies to.
Mode Access: Input-only
Type: AcSelect enum
- acSelectionSetWindow
- acSelectionSetCrossing
- acSelectionSetPrevious
- acSelectionSetLast
- acSelectionSetAll
Point1 Access: Input-only; optional
Type: Variant (three-element array of doubles)
The 3D WCS coordinates, or array of coordinates, specifying Point1. See the mode definitions for the proper use of Point1.
Point2 Access: Input-only; optional
Type: Variant (three-element array of doubles)
The 3D WCS coordinates specifying Point2. See the mode definitions for the proper use of Point2.
FilterType Access: Input-only; optional
Type: Variant
A DXF group code specifying the type of filter to use.
FilterData Access: Input-only; optional
Type: Variant
The value to filter on.
|