- UID
- 298726
- 积分
- 147
- 精华
- 贡献
-
- 威望
-
- 活跃度
-
- D豆
-
- 在线时间
- 小时
- 注册时间
- 2005-7-25
- 最后登录
- 1970-1-1
|
发表于 2008-9-11 20:37:54
|
显示全部楼层
这是你1.lsp中的内容,首先你不应该把这么小的一个程序用附件的形式上传,直接粘贴上就可以了,一般人没有时间去下你这东西的.我大概看了一下程序写的看上去比较复杂,但是就你的问题来说,你只是没有判断选择的对象是不是文本而已,你只需在构造选择集中构造出一个文本选择集去使用就可以了,如果你是程序的作者你应该能明白,如果还需详细的帮助,请给我发信.
;格式内容刷,可以刷各种实体中的文字; text/mtext/attribute
;;; ReplaceText.lsp by J.J.Damstra - Copyright ?2005.
;;; Replaces any selected string for another
;;; 21-06-05 first release
;;; 09-07-05 tableindicator
(defun c:tv1 (/ bz_start bz_end bz_error old_cmd olderr ch_txt entity entitylist txt_str object pickpnt e-type n ti ostr)
(defun ch_txt (txt_str entity / entitylist ent)
(setq ent (car entity)
entitylist (entget ent)
entitylist (subst (cons 1 txt_str) (assoc 1 entitylist) entitylist)
)
(entmod entitylist)
(entupd ent)
)
(defun bz_start ( / )
(setq old_cmd (getvar "cmdecho"))
(setvar "cmdecho" 0)
(setvar "blipmode" 0) ;消除影点变量
(eval "(command \"_.undo\" \"_group\)")
(setq olderr *error* *error* bz_error)
)
(defun bz_end ( / )
(setq *error* olderr)
(command "_.undo" "end")
(setvar "cmdecho" old_cmd)
(princ)
)
(defun bz_error (s)
(if (not (member s '("console break" "Function cancelled" "quit / exit abort")))
(princ (strcat "\nError: " s))
)
(bz_end)
)
(bz_start)
(setq txt_str
(if (setq entity (nentsel "\n选择源文字: "))
(cdr (assoc 1 (entget (car entity))))
(getstring "\n 请输入文字:")
)
)
(if (= txt_str "")
(setq txt_str nil)
(princ (strcat "\n 复制文字内容为: " txt_str "."))
)
(while (and txt_str
(setq entity (nentsel "\n选择要改变的文字: "))
)
(setq ostr (cdr (assoc 1 (entget (car entity)))))
(if (< (length entity) 4)
(ch_txt txt_str entity)
(progn (setq object (car (last entity))
entitylist (entget object)
pickpnt (cadr entity)
e-type (cdr (assoc 0 entitylist))
)
(cond ((= e-type "INSERT")
(ch_txt txt_str entity)
)
((wcmatch e-type "*DIMENSION")
(command "_.dim1" "newtext" txt_str object "")
(entupd object)
)
((= e-type "ACAD_TABLE")
(command "_.tabledit" pickpnt "@#@")
(setq entitylist (entget object))
(foreach n entitylist
(if (eq (car n) 1)
(if (eq (substr (cdr n) 1 3) "@#@")
(entmod (subst (cons 1 txt_str) n entitylist))
)
)
)
(entupd object)
)
)
)
)
(princ (strcat "\n 原文字为:" ostr ". 已被替换为 " txt_str " ."))
)
(bz_end)
) |
|