明经CAD社区

 找回密码
 注册

QQ登录

只需一步,快速开始

搜索
查看: 305|回复: 2

[讨论] 文字替换代码,多行字替换不了,高手请帮忙看看

[复制链接]
发表于 3 天前 | 显示全部楼层 |阅读模式

文字替换代码,多行字替换不了,高手请帮忙看看
CopyTextAToB 这个命令换成方便的命令就不行,比如换成AS

(defun c:CopyTextAToB (/ entA textA entB dataB done)
  (if (setq entA (car (entsel "\n选择源文字A(将被复制的文字): "))))
    (if (wcmatch (cdr (assoc 0 (entget entA))) "*TEXT")
      (progn
        (setq textA (cdr (assoc 1 (entget entA)))
        (princ "\n选择目标文字B(将被替换的文字,右键结束): ")
        (while (not done)
          (if (setq entB (car (entsel)))
            (if (wcmatch (cdr (assoc 0 (entget entB))) "*TEXT")
              (progn
                (setq dataB (entget entB))
                (entmod (subst (cons 1 textA) (assoc 1 dataB) dataB))
                (entupd entB)
                (princ (strcat "\n已将文字B内容替换为: " textA))
              )
              (princ "\n选择的对象不是文字,请重新选择或右键结束。")
            )
            (setq done T) ; 用户按ESC或右键结束
          )
        )
      )
      (princ "\n选择的对象不是文字。")
    )
    (princ "\n未选择源文字。")
  )
  (princ)
)

点评

AI码?  发表于 3 天前
回复

使用道具 举报

发表于 3 天前 | 显示全部楼层
  1. (defun c:tt ()
  2.   (if (and (setq s1 (car (entsel "\n选择源文字A(将被复制的文字): ")))
  3.            (wcmatch (cdr (assoc 0 (entget s1))) "*TEXT")
  4.            (setq tx (cdr (assoc 1 (entget s1))))
  5.       )
  6.     (while (and (setq s2 (car (entsel "\n选择目标文字B(将被替换的文字,右键结束): ")))
  7.                 (wcmatch (cdr (assoc 0 (entget s2))) "*TEXT")
  8.            )
  9.       (setq ent (entget s2))
  10.       (entmod (subst (cons 1 tx) (assoc 1 ent) ent))
  11.       (entupd s2)
  12.     )
  13.   )
  14.   (princ)
  15. )
回复 支持 反对

使用道具 举报

您需要登录后才可以回帖 登录 | 注册

本版积分规则

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

GMT+8, 2025-4-25 10:04 , Processed in 0.206670 second(s), 26 queries , Gzip On.

Powered by Discuz! X3.4

Copyright © 2001-2021, Tencent Cloud.

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