VLA选择集
本帖最后由 dcl1214 于 2024-5-22 13:00 编辑(progn
(setq ss-n "SSGET")
(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 filtType
(vl-Catch-All-Apply
'vlax-make-variant
(LIST
(vl-Catch-All-Apply
'vlax-safearray-fill
(LIST
(vl-Catch-All-Apply 'vlax-make-safearray(LIST vlax-vbInteger '(0 . 4)))
;①这里需要修改(下面②、③总数减一即可);一维数组
(list 0 -4 0 -4 1001)
;②这里需要修改;过滤扩展数据的时候是1001
)
)
(logior vlax-vbarray vlax-vbInteger)
)
)
)
(setq filtData
(vlax-make-variant
(vl-Catch-All-Apply
'vlax-safearray-fill
(list
(vl-Catch-All-Apply 'vlax-make-safearray(LIST vlax-vbVariant '(0 . 4)))
;①这里需要修改(下面②、③总数减一即可);一维数组
(list "*LINE*" "<NOT" "INSERT" "NOT>" "JDCD")
;③这里需要修改(和上面的②一一对应);过滤条件
)
)
(vl-Catch-All-Apply
'logior
(list vlax-vbarray vlax-vbVariant)
)
)
)
(vl-catch-all-apply
'vla-select
(list ss acSelectionSetAll nil nil filtType filtData)
)
)
(defun $vla-ssget$ (pt1 pt2 lst / obj selectionsets xzj-n ss)
(setq selectionSets
(vla-get-selectionsets
(vla-get-activedocument (vlax-get-acad-object))
)
)
(setq xzj-n "ssget")
(setq obj (vl-catch-all-apply
'vla-item
(list selectionSets xzj-n)
)
)
(if (vl-catch-all-error-p obj)
()
(vla-delete obj)
)
(setq obj nil
ssnil
)
(setq ss
(vl-catch-all-apply 'vla-add (list selectionSets xzj-n))
)
(if (not (vl-catch-all-error-p obj))
(progn
(vl-catch-all-apply
(function
(lambda (/ filterType)
(setq filterType
(vlax-make-safearray vlax-vbinteger '(0 . 3))
)
;①②③④共计四个数字减去一个即可
(vlax-safearray-put-element filterType 0 -4) ;①
(vlax-safearray-put-element filterType 1 0) ;②
(vlax-safearray-put-element filterType 2 62) ;③
(vlax-safearray-put-element filterType 3 -4) ;④
(setq filterData
(vlax-make-safearray vlax-vbvariant '(0 . 3))
)
;①②③④共计四个数字减去一个即可
(vlax-safearray-put-element filterData 0 "<AND")
;与上面①对应
(vlax-safearray-put-element filterData 1 "Circle")
;与上面②对应
(vlax-safearray-put-element filterData 2 6) ;与上面③对应
(vlax-safearray-put-element filterData 3 "AND>")
;与上面④对应
(if (and pt1 pt2)
(progn
(setq pt1 (list (car pt1) (cadr pt1) 0))
(setq pt2 (list (car pt2) (cadr pt2) 0))
(vla-ZoomWindow
(vlax-get-acad-object)
(vlax-3d-point pt1)
(vlax-3d-point pt2)
)
(vl-catch-all-apply
'vla-select
(list
ss
acSelectionSetCrossing
(vlax-3d-point pt1)
(vlax-3d-point pt2)
filterType
filterData
)
)
(vla-zoomprevious (vlax-get-acad-object))
;逐个返回的,视口缩放返回上一个
)
(vl-catch-all-apply
'vla-select
(list
ss acSelectionSetAll
nil nil filterType
filterData
)
)
)
(vl-catch-all-apply 'vla-Highlight (list ss :vlax-true))
)
)
)
)
)
ss
)
鼓掌鼓掌鼓掌鼓掌鼓掌鼓掌吧 我测试没选出来 你们测试通过了吗? 感谢大佬分享 试出来了,运行后为nil,查结果ss里面有图元。 本帖最后由 guosheyang 于 2024-4-26 13:07 编辑
null. 发表于 2024-4-25 20:59
试出来了,运行后为nil,查结果ss里面有图元。
帮吗测试下 这个文件的扩展数据,看看代码要如何改?谢谢! (-3 ("注册名称" (1000 . "扩展数据")))
C:MIAN
命令: MIAN
命令: 1 注册名称
"AcDbCircle"
2 注册名称
"AcDbCircle"
3 注册名称
"AcDbCircle"
命令: 1 JZDST
"AcDbCircle"
2 JZDST
"AcDbCircle"
3 JZDST
"AcDbCircle"
4 JZDST
"AcDbCircle"
5 JZDST
"AcDbCircle"
6 JZDST
"AcDbCircle"
7 JZDST
"AcDbCircle" null. 发表于 2024-4-26 14:57
C:MIAN
命令: MIAN
命令: 1 注册名称
(sssetfirst nil (setq ss(SSGET "X" (list (list -3 (list "JZDST")))))) 能否实现这个代码对应的功能? guosheyang 发表于 2024-4-28 00:04
(sssetfirst nil (setq ss(SSGET "X" (list (list -3 (list "JZDST")))))) 能否实现这个代码对应的功 ...
不要觉得选择集过滤器什么都能过滤,
要知道过滤器是怎么制作的才明白它什么过滤不了...
如果你想知道可以接着问我 你有种再说一遍 发表于 2024-4-28 01:20
不要觉得选择集过滤器什么都能过滤,
要知道过滤器是怎么制作的才明白它什么过滤不了...
如果你想知道可 ...
好的感谢 !清楚了 ,群里面也讨论过了,不是所有的都能选择的,有的只有遍历选择
页:
[1]
2