本帖最后由 dcl1214 于 2024-1-1 15:40 编辑
- (defun $ssget-vla$ (pt1 pt2 filter lst / ss-n ss tmp ents e)
- ;vla选择集
- ;示例 :($ssget-vla$ (getpoint)(getpoint)(list(cons 0 "*LINE*"))nil)
- (setq ss-n "SSGET")
- (if filter
- (progn
- (vl-Catch-All-Apply
- 'vla-delete
- (LIST
- (vl-Catch-All-Apply
- 'vla-item
- (list (vla-get-SelectionSets
- (vla-get-ActiveDocument (vlax-get-acad-object))
- )
- ss-n
- )
- )
- )
- )
- (setq
- ss (vl-Catch-All-Apply
- 'vla-add
- (list (vla-get-selectionsets
- (vla-get-activedocument (vlax-get-acad-object))
- )
- ss-n
- )
- )
- )
- (setq
- tmp (mapcar
- (function
- (lambda (x y)
- (vl-catch-all-apply
- 'vlax-make-variant
- (list (vl-catch-all-apply
- 'vlax-safearray-fill
- (list (vl-Catch-All-Apply
- 'vlax-make-safearray
- (list y (cons 0 (1- (length x))))
- )
- x
- )
- )
- )
- )
- )
- )
- (list (mapcar 'car filter) (mapcar 'cdr filter))
- (list vlax-vbInteger vlax-vbVariant)
- )
- )
- (if (and pt1 pt2)
- (progn
- (setq pt1 (list (car pt1) (cadr pt1) 0))
- (setq pt2 (list (car pt2) (cadr pt2) 0))
- (vl-catch-all-apply
- 'vla-select
- (list
- ss
- acSelectionSetCrossing
- (vlax-3d-point pt1)
- (vlax-3d-point pt2)
- (car TMP)
- (cadr TMP)
- )
- )
- )
- (vl-catch-all-apply
- 'vla-select
- (list
- ss
- acSelectionSetAll
- nil
- nil
- (car TMP)
- (cadr TMP)
- )
- )
- )
- )
- )
- (setq ents nil)
- (if ss
- (VLAX-FOR obj ss
- (setq e (vlax-vla-object->ename obj))
- (setq ents (cons e ents))
- )
- )
- (setq ss nil)
- ENTS
- )
|