动态块如何选择用块名去选择块呢?
动态块回用一个类似`*U763的值替代块名,如何选择实际的块名呢?(setq ss (ssget "_X" '((0 . "INSERT")(2 . "*gps*"))))这种就没法把gps*的块加入变量。求大神解惑?(setq obj (vlax-ename->vla-object EntNam))
(setq b_name (vla-get-EffectiveName obj))
这个函数可以获取动态块的块名 xiaocainiao 发表于 2023-8-9 18:22
(setq obj (vlax-ename->vla-object EntNam))
(setq b_name (vla-get-EffectiveName obj))
这个函数可以 ...
谢谢,非常感谢,获取到块名怎么筛选呢,比如说我要筛选带块名带gps的块,该怎么写呢?小白求教
令: (fun:usage 'block:ssget)
*** 函数名:block:ssget
---------------
说明: 选择满足指定属性标记及对应值的块参数: blknames 块名,或块名列表参数: lst-attr 属性名与值的点对表
用法: (block:ssget blknames lst-attr)
参数: 1 blknames: 块名称;2 lst-attr: 列表;
返回值: 满足条件的选择集
示例: (block:ssget '("块1" "块2") '(("属性1" . "值1")("属性2" . "值2")))
命令: (fun:src 'block:ssget)
(defun block:ssget (blknames lst-attr / ss ss-res)
"选择满足指定属性标记及对应值的块\n参数: blknames 块名,或块名列表\n参数: lst-attr 属性名与值的点对表"
"满足条件的选择集"
"(block:ssget '(\"块1\"
\"块2\")
'((\"属性1\"
. \"值1\")(\"属性2\"
. \"值2\")))"
(if (= (quote str)
(type blknames))
(setq blknames (list blknames)))
(setq ss-res (ssadd))
(if (setq lst-ent (pickset:to-list (ssget "x"
(quote ((0 . "insert"))))))
(foreach ent% lst-ent (if (and (member (block:get-effectivename ent%)
blknames)
(apply (quote and)
(mapcar (quote (lambda (x)
(member x (block:get-attributes ent%))))
lst-attr)))
(ssadd ent% ss-res))))
(sssetfirst nil ss-res)
ss-res) 没办法 根据dxf码直接筛选,只能选取很多动态块后,在程序内部进行筛选 论坛有代码,提前预选过滤所有符合要求的*U,再作为DXF2来给SSGET过滤选择 (DEFUN $ssget-km$ (KMS LST / ents filter km obj ss ss-n tmp)
;高速搜索块名
(IF KMS
(PROGN
(setq ss-n "SSGET")
(SETQ filter (list (cons 0 "INSERT") (cons 66 1)))
(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)
)
)
(vl-catch-all-apply
'vla-select
(list
ss
acSelectionSetAll
nil
nil
(car TMP)
(cadr TMP)
)
)
(if ss
(vlax-for obj ss
(setq km nil)
(setq km (vl-catch-all-apply
'vla-get-effectivename
(list obj)
)
)
(AND (vl-catch-all-error-p KM)
(setq KM (vl-catch-all-apply 'vla-get-name (list obj)))
)
(and km (setq km (strcase km)))
(if (and km (member km KMS))
(SETQ ENTS (CONS (VLAX-VLA-OBJECT->ENAME OBJ) ENTS))
)
)
)
(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
)
)
)
)
)
)
ENTS
) 感谢各位大佬的回复,结合这篇文章大概弄出来了https://www.cnblogs.com/edata/p/6797362.html。感谢
http://bbs.mjtd.com/forum.php?mod=viewthread&tid=182700&highlight=%B6%AF%CC%AC%BF%E9
页:
[1]