;查找命令
;1、输入关键字
;2、选择被查找文本
;3、定位至查找到的文本
(defun c:fd()
(setq s nil)
(setq wd "")
(while (= wd "")
(setq wd(getstring "\n请输入关键字:"))
)
(setq wd(strcat "*" (strcase wd) "*")) ;加入通配符
(while (= s nil)
(princ "\n请选择被查找文本:")
(setq s (ssget (list (cons 0 "text"))));text为单行文本,mtext为多行文本
)
(princ "\n")
(setq sl (sslength s))
(setq st 0)
(setq i 0)
(setq lt(list))
(while (< st sl)
(setq e(ssname s st))
(setq st(1+ st))
(setq txt(cdr (assoc 1 (entget e)))) ;获取文本
(if (wcmatch (strcase txt) wd) ;比较
(progn
(setq pos(cdr (assoc 10 (entget e)))) ;获取三维坐标
(setq h (cdr (assoc 40 (entget e)))) ;获取字体高度
(setq lt (cons (list txt pos h) lt))
(setq i (1+ i))
(princ (strcat (itoa i) "、" txt "\n"))
)
)
)
(if (= lt nil)
(progn
(princ "\n未找到相关项\n")
(setq ret nil)
)
(progn
(setq lt (reverse lt)) ;反转列表
(setq msg (strcat "\n请选择项(1-" (itoa i) ")/退出(0): "))
(setq j (getint msg))
(while (> j 0)
(setq e1 (nth (- j 1) lt))
(myZoom (cadr e1) (caddr e1))
(setq j (getint msg))
)
)
)
)
;CAD窗口定位
;@p0:坐标
;@h: 文字高度
(defun myZoom(p0 h)
(setq m (* h 10))
(setq n (* h 15))
(setq x1 (- (car p0) m))
(setq y1 (- (cadr p0) m))
(setq x2 (+ (car p0) n))
(setq y2 (+ (cadr p0) n))
(setq z (caddr p0))
(setq p1 (list x1 y1 z)) ;左下标
(setq p2 (list x2 y2 z)) ;右上标
(command "zoom" "w" p1 p2 )
)
autolisp自制cad查找命令
发表评论
热门文章
-
OneNice简洁大方且开源免费的WordPress主题 17114 阅读
-
Bootstrap4显示和隐藏元素 5076 阅读
-
mysql批量去除重复记录 4165 阅读
-
OneNice Pro简洁且强大的WORDPRESS主题 4130 阅读
-
-
loadjs - javascript动态载入css和js文件 2092 阅读
-
BT宝塔中安装nodejs 2026 阅读
-
github无法加载或不显示图片问题 1910 阅读