明经CAD社区

 找回密码
 注册

QQ登录

只需一步,快速开始

搜索
查看: 515|回复: 2

[提问] 代码回删去现有的文字,求保留

[复制链接]
发表于 2022-5-29 08:45 | 显示全部楼层 |阅读模式
修改程序:修改文字内容,带记忆多选
http://bbs.mjtd.com/forum.php?mo ... amp;fromuid=7330080
(出处: 明经CAD社区)


感谢,重慶崽兒
  • (defun c:qm( / ent i newtext_1 newtxt newtxt_1 ss)
  •   (while T
  •     (if (and newtxt_1 (/= newtext_1 ""))
  •       (progn
  •         (setq newtxt (getstring (strcat "\n输入新的文字内容" "<" newtxt_1 ">" ":")))
  •         (if (= newtxt "")
  •           (setq newtxt newtxt_1)
  •         )
  •       )
  •       (setq newtxt (getstring "\n输入新的文字内容:"))
  •     )
  •     (setq ss (ssget '((0 . "*TEXT"))))
  •     (setq i 0)
  •     (repeat (sslength ss)
  •       (setq ent (entget (ssname ss i)))
  •       (entmod (subst (cons 1 (strcat "(" newtxt ")")) (assoc 1 ent) ent))
  •       (setq i (1+ i))
  •     )
  •     (setq newtxt_1 newtxt)
  •   )
  • )






发表于 2022-5-29 14:16 | 显示全部楼层
本帖最后由 xxc9595 于 2022-5-29 14:27 编辑


(defun c:qm( / ent i newtext_1 newtxt newtxt_1 ss)
  (while T
    (if (and newtxt_1 (/= newtext_1 ""))
      (progn
        (setq newtxt (getstring (strcat "\n输入新的文字内容" "<" newtxt_1 ">" ":")))
        (if (= newtxt "")
          (setq newtxt newtxt_1)
        )
      )
      (setq newtxt (getstring "\n输入新的文字内容:"))
    )
    (setq ss (ssget '((0 . "*TEXT"))))
    (command "copy" ss ""  '(0 0 0) '(0 0 0))
    (setq i 0)
    (repeat (sslength ss)
      (setq ent (entget (ssname ss i)))
      (entmod (subst (cons 1 (strcat "(" newtxt ")")) (assoc 1 ent) ent))
      (setq i (1+ i))
    )
    (setq newtxt_1 newtxt)
  )
)
 楼主| 发表于 2022-5-31 22:31 | 显示全部楼层
xxc9595 发表于 2022-5-29 14:16
(defun c:qm( / ent i newtext_1 newtxt newtxt_1 ss)
  (while T
    (if (and newtxt_1 (/= newtext_ ...

大佬可能您误解我的意思了。例如原来是A,现在我想用这个代码变成A(2x)。增加后缀。
您需要登录后才可以回帖 登录 | 注册

本版积分规则

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

GMT+8, 2024-4-25 06:22 , Processed in 0.387805 second(s), 28 queries , Gzip On.

Powered by Discuz! X3.4

Copyright © 2001-2021, Tencent Cloud.

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