- 我做的LISP程序
- ;;命令:JZD 查找形如“J004”重复注记
- (defun c:jzd(/ j_lay ss a j_d j_n n entname j_s j_z j_dd j_h pt)
- (setvar "cmdecho" 0)
- (command "undo" "be")
- (setq j_lay(getstring "\n界址点所在层:"));;输入层名
- (setq ss(ssget "x" (list (cons 0 "TEXT")(cons 8 j_lay))));;选取图幅内所有j_lay层的文字集合
- (setq a 0 j_d '())
- (repeat (sslength ss);;循环处理选择集ss每一图元
- (setq entname(ssname ss a));;选择ss一图元名
- (setq j_n(cdr (assoc 1 (entget entname))));;获取文字内容字符串
- (setq n(strlen j_n)) ;;获取该文字字符串个数
- (setq j_s(substr j_n 2));;获取该文字字符串子串编号(去J)
- (setq j_z(atoi j_s)) ;;字符串转变为整数
- (setq j_dd(cons j_z j_n));;构造一个点对
- (setq j_h(assoc j_z j_d));;从关联表中搜索j_z(点号)元素
- (if j_h
- (progn ;;若j_h不为空,说明已有该编号
- (setq pt(cdr (assoc 10 (entget entname))));;获取该文字所在位置坐标
- (command "PLINE" PT '(0 0) "");;画一条从原点到该文字位置的线
- );;end progn
- (setq j_d(cons j_dd j_d));;若为空把该点对加入表
- );; end if
- (setq a(1+ a));;循环加一
- );;end repeat
- (command "undo" "e")
- (setvar "cmdecho" 1)
- )
- ;;命令:CHZ 查找字符串所在位置
- (defun c:chz(/ tr s num pt1 nm rq ct)
- (setvar "CMDECHO" 0)
- (setq tr(getstring "\n输入字符串"))
- (setq s(ssget "x" (list (cons 0 "text") (cons 1 tr))))
- (if s
- (progn
- (setq num 0)
- (repeat (sslength s)
- (setq pt1(cdr(assoc '10 (entget (ssname s num)))))
- (command "pline" pt1 '(0 0) "")
- ;;(command "zoom" "1.5x")
- (if (> (sslength s) 1)(progn
- (initget 2 "n y")
- (setq nm (getstring "下一个? N(不)/Y(是)/:<Y>"))
- (if (eq nm "") (setq nm "y"))
- (if (or (eq nm "n") (eq nm "N")) (exit))
- (if (or (eq nm "y") (eq nm "Y")) (setq num (1+ num)))
- ))
- )
- )(alert "本图没有该文字或文字大小写错误"))
- (setvar "CMDECHO" 1)
- )
|