【源码】【过滤选择】快速选择同名块(块名带*号#号的都可以哦!【可框选,全选】
本帖最后由 1028695446 于 2023-6-29 16:35 编辑【过滤选择】快速选择同名块(块名带*号#号的都可以哦!【可框选,全选】
按提示操作,
先选样板,然后选择范围,默认框选,直接空格(不选)则全选
可同时过滤选择多个块名
下面是源码,附件和附件中的lsp一致,lsp文件需要收费
0.1明经币,意思下咯;P,觉得好就当礼物打赏下
注意!!!
本人阅读权限还没有20,好多帖子还不能看,所以,路过的帮忙顶下或者回贴
以后有更好源码再来分享
;; 用正则表达式替换字符 by 梁雄啸.2007.7
(defun XD::String:Replace (pat str nstr key / end)
(vl-load-com)
(if (not *xxvbsexp)
(setq *xxvbsexp (vlax-get-or-create-object "VBScript.RegExp"))
)
(vlax-put *xxvbsexp 'Pattern pat)
(if (not key)(setq key ""))
(setq key (strcase key))
(setq keys '(("I""IgnoreCase")("G""Global")("M""Multiline")))
(mapcar '(lambda(x)
(if (wcmatch key (strcat "*" (car x) "*"))
(vlax-put *xxvbsexp (read(cadr x)) 0)
(vlax-put *xxvbsexp (read(cadr x)) -1)
))
keys)
(vlax-invoke *xxvbsexp 'replace str nstr)
)
;[功能] 特殊字符处理(用于文字替换等)
;示例(ACET-STR-ESC-WILDCARDS1 "#a@b");"`#a`@b"
;注:没有安装ET时用,安装ET后用(ACET-STR-ESC-WILDCARDS "#a@b")
;;淘贴至自贡黄大师
(defun ACET-STR-ESC-WILDCARDS1 (A / X LST)
;(ACET-STR-REPLACE "B" "2" "ssABCsBs");"ssA2Cs2s"
(defun ACET-STR-REPLACE1 (o n s)
(XD::String:Replace (strcat "[" o "]") s n "I")
)
(SETQ LST '("#" "@" "." "*" "?" "~" "[" "]" ","))
(foreach X LST
(SETQ A (ACET-STR-REPLACE1 X (STRCAT "`" X) A))
)
A
)
;;-------------------------------------------------------------------------
;过滤选择,DXF组码,by:1028695446
;过滤选择,DXF组码,by:1028695446
(defun FILTER_by_DXF_code(ss DXF_code / ss i filter elist DXF_cons ssf n)
(if ss
(progn
(*sp_set)
(command "undo" "be")
(setq i 0)
(setq filter nil)
(repeat (sslength ss)
(setq elist(entget (ssname ss i)))
(if (assoc DXF_code elist)
(if (=(type(cdr(assoc DXF_code elist))) 'STR)
(setq DXF_cons(cons DXF_code (ACET-STR-ESC-WILDCARDS1 (cdr(assoc DXF_code elist)))))
(setq DXF_cons(assoc DXF_code elist))
);;此处有修正
(if(= DXF_code 62)
(setq DXF_cons (consDXF_code 256))
);;;只针对颜色为 bylayer 有用
);;end if
(setq filter (append filter (list DXF_cons)))
(setq i (1+ i))
);;end repeat
(setq filter (append '((-4 . "<or")) filter '((-4 . "or>"))));建立过滤表
(princ"\n请框选对象范围<按空格或右键全选>:")
(if (setq ssf (ssget filter))
(princ)
(setq ssf (ssget "x" filter))
)
(command "undo" "e")
(sssetfirst nil ssf)
(princ)
)
(princ"\n未选择,退出")
)
(princ)
);;end defun
(defun *sp_get (/ sstmp)
(if (setq sstmp (ssget "P"))
(progn
(setq *sp_xz* sstmp)
)
)
)
(defun *sp_set ()
(if *sp_xz* (command "SELECT" *sp_xz* ""))
)
;;0按类型过滤
(defun c:xee() (princ "\n过滤选择---类型")(*sp_get)(FILTER_by_DXF_code (ssget) 0 ))
;;8按图层过滤
(defun c:xer() (princ "\n过滤选择---图层")(*sp_get)(FILTER_by_DXF_code (ssget) 8 ))
;;62 按颜色过滤
(defun c:xcr() (princ "\n过滤选择---颜色")(*sp_get)(FILTER_by_DXF_code (ssget) 62))
;;先选块,然后按块名过滤
(defun c:xzk() (princ "\n过滤选择---块名")(*sp_get)(FILTER_by_DXF_code (ssget '((0 . "INSERT"))) 2))
;;先选填充,然后按填充样式过滤
(defun c:xzh() (princ "\n过滤选择---填充名")(*sp_get)(FILTER_by_DXF_code (ssget '((0 . "HATCH"))) 2))
;;先选尺寸标注,然后按标注样式过滤
(defun c:xzD() (princ "\n过滤选择---标注样式")(*sp_get)(FILTER_by_DXF_code (ssget '((0 . "*DIMENSION"))) 3))
;;先选文字,然后按文字内容过滤
(defun c:xztt()(princ "\n过滤选择---文字内容")(*sp_get)(FILTER_by_DXF_code (ssget '((0 . "MTEXT,TEXT"))) 1))
;;先选文字,然后按字体样式过滤
(defun c:xzSt()(princ "\n过滤选择---文字样式")(*sp_get)(FILTER_by_DXF_code (ssget '((0 . "MTEXT,TEXT"))) 7))
;;只选文字
(DEFUN C:x1() (sssetfirst nil (ssget '((0 . "MTEXT,TEXT")))) (prin1))
;;只选标注+箭头引线
(DEFUN C:x2() (sssetfirst nil (ssget '((0 . "*DIMENSION,LEADER")))) (prin1))
;选文字+标注+箭头引线
(DEFUN C:x3() (sssetfirst nil (ssget '((0 . "MTEXT,TEXT,*DIMENSION,LEADER")))) (prin1))
;选填充
(DEFUN C:x5() (sssetfirst nil (ssget '((0 . "hatch")))) (prin1))
1291500406 发表于 2019-4-6 13:23
(defun c:bb()(sssetfirst nil (SSGET "X"(LIST '(0 . "*")(assoc 2 (entget (car (entsel "按块全选
试了一下,动态块没法全选。 本帖最后由 1291500406 于 2019-4-6 13:31 编辑
(defun c:bb()(sssetfirst nil (SSGET "X"(LIST '(0 . "*")(assoc 2 (entget (car (entsel "按块全选"))))))))
arcers 发表于 2019-4-9 22:21
跟小菜选择易有什么区别?
肯定有区别,没小菜选择易强大,这是必然的,,,不喜欢操作对话框的,可以试试{:1_1:} 跟小菜选择易有什么区别? 谢谢大佬:lol 试了下操作,操作步骤提示不是很明确,还是读下代码理解下再说吧 谢谢大佬分享 Thanks for sharing ^^ 我就喜欢这样摸黑选,不喜欢对话框 有没有按文字角度和直线角度过滤的?
页:
[1]
2