明经CAD社区

 找回密码
 注册

QQ登录

只需一步,快速开始

搜索
查看: 2060|回复: 7

[提问] 修改程序:修改文字内容,带记忆多选

  [复制链接]
发表于 2015-9-7 17:19 | 显示全部楼层 |阅读模式
本帖最后由 yunfengning 于 2015-9-8 10:33 编辑

(defun C:qm ()
(while (and
   (setq ent (entsel "\n请选择源文字:"))
   (setq ent (entget (car ent)))
   (wcmatch (cdr(assoc 0 ent)) "*TEXT")
   (setq newtxt (getstring "\n输入新的文字内容\n"))
   (setq newtxt (strcat "(" newtxt ")")) ;;;给改文字的内容加上括号
   )
  (entmod (subst (cons 1 newtxt) (assoc 1 ent) ent))
)
(princ)
)

请大侠帮忙修改以上LSP,实现以下功能
1、先输入要修改成的内容,再选择要修改的文字。
2、能多选。
3、能记忆上次输入的修改内容。
4、文字修改后,首尾要加上括号。
上次提的要求表达不清,深表歉意。
发表于 2015-9-7 20:28 | 显示全部楼层
1:没明白你说的什么意思,不觉明厉!
2、3:
  1. (defun c:qm()
  2.   (while (setq ss (ssget '((0 . "*TEXT"))))
  3.     (setq i 0)
  4.     (if (and newtxt_1 (/= newtext_1 ""))
  5.       (progn
  6.         (setq newtxt (getstring (strcat "\n输入新的文字内容" "<" newtxt_1 ">" ":")))
  7.   (if (= newtxt "")
  8.           (setq newtxt newtxt_1)
  9.   )
  10.       )
  11.       (setq newtxt (getstring "\n输入新的文字内容:"))
  12.     )
  13.     (repeat (sslength ss)
  14.       (setq ent (entget (ssname ss i)))
  15.       (entmod (subst (cons 1 newtxt) (assoc 1 ent) ent))
  16.       (setq i (1+ i))
  17.     )
  18.     (setq newtxt_1 newtxt)
  19.   )
  20. )
发表于 2015-9-8 08:29 | 显示全部楼层
  1. (defun c:qm ()
  2.   (setq str (USTR 1 "新文字内容" str NIL)
  3.         tx  (strcat "(" str ")")
  4.   )
  5.   (while (setq ss (ssget '((0 . "*text"))))
  6.     (xyp-SubUpd ss 1 tx)
  7.   )
  8.   (princ)
  9. )
发表于 2015-9-8 09:02 | 显示全部楼层
xyp1964 发表于 2015-9-8 08:29

ustr是个什么鬼?

点评

Kye
院长研究的真认真 http://bbs.mjtd.com/forum.php?mod=viewthread&tid=93190  发表于 2015-9-9 13:04
还有udist ,ukword, uangel 等等  发表于 2015-9-8 20:54
网站内就有此函数  发表于 2015-9-8 18:27
发表于 2015-9-8 20:50 | 显示全部楼层
  1. (defun c:qm( / ent i newtext_1 newtxt newtxt_1 ss)
  2.   (while T
  3.     (if (and newtxt_1 (/= newtext_1 ""))
  4.       (progn
  5.         (setq newtxt (getstring (strcat "\n输入新的文字内容" "<" newtxt_1 ">" ":")))
  6.         (if (= newtxt "")
  7.           (setq newtxt newtxt_1)
  8.         )
  9.       )
  10.       (setq newtxt (getstring "\n输入新的文字内容:"))
  11.     )
  12.     (setq ss (ssget '((0 . "*TEXT"))))
  13.     (setq i 0)
  14.     (repeat (sslength ss)
  15.       (setq ent (entget (ssname ss i)))
  16.       (entmod (subst (cons 1 (strcat "(" newtxt ")")) (assoc 1 ent) ent))
  17.       (setq i (1+ i))
  18.     )
  19.     (setq newtxt_1 newtxt)
  20.   )
  21. )
 楼主| 发表于 2015-9-9 12:49 | 显示全部楼层
谢谢哥们儿。
发表于 2022-5-29 08:35 | 显示全部楼层

你好,大佬。你这个能帮忙改下吗?保留现有的文字,增加的在后面 A 变成A(2x)
发表于 2023-9-8 23:00 | 显示全部楼层
不明觉厉~~支持一下
您需要登录后才可以回帖 登录 | 注册

本版积分规则

小黑屋|手机版|CAD论坛|CAD教程|CAD下载|联系我们|关于明经|明经通道 ( 粤ICP备05003914号 )  
©2000-2023 明经通道 版权所有 本站代码,在未取得本站及作者授权的情况下,不得用于商业用途

GMT+8, 2024-5-5 00:49 , Processed in 0.427409 second(s), 35 queries , Gzip On.

Powered by Discuz! X3.4

Copyright © 2001-2021, Tencent Cloud.

快速回复 返回顶部 返回列表