乐筑天下

搜索
欢迎各位开发者和用户入驻本平台 尊重版权,从我做起,拒绝盗版,拒绝倒卖 签到、发布资源、邀请好友注册,可以获得银币 请注意保管好自己的密码,避免账户资金被盗
查看: 64|回复: 3

[编程交流] Find & Replace in current layo

[复制链接]

9

主题

21

帖子

12

银币

初来乍到

Rank: 1

铜币
45
发表于 2022-7-6 07:17:34 | 显示全部楼层 |阅读模式
I have 2 things I'm trying to accomplish here. I need to find the the exact text to replace and only in the current layout. For example. Let's say I need to find "Date" but on the same layout I have "date", "Date" and "Date:". So it needs to be case sensitive also. I was using this but it's not case sensitive and also replaces "date" and "Date:" in all layouts. I just need "Date" in the current layout.
 
  1. ;Find And Replace(defun C:FAR ()(setq OldTxt (getstring T "\nEnter the old text: ")          NewTxt (getstring T "\nEnter the new text: "))(setq ss (ssget "x" '((0 . "TEXT,MTEXT"))))        (setq i (sslength ss))(while (not (minusp (setq i (1- i))))        (setq oText (vlax-ename->vla-object (ssname ss i)))        (setq Txt (vlax-get-property oText 'TextString))                (if (vl-string-search OldTxt txt)                (progn                        (setq newChg (vl-string-subst NewTxt OldTxt txt))                        (vlax-put-property oText 'TextString newchg)                        (vlax-invoke-method oText 'Update)                )        ))(princ))
回复

使用道具 举报

63

主题

6297

帖子

6283

银币

后起之秀

Rank: 20Rank: 20Rank: 20Rank: 20

铜币
358
发表于 2022-7-6 07:45:19 | 显示全部楼层
Hope that your texts are not Annotative ..
 
  1. (defun c:test (/ oldTxt NewTxt ss in en) (if   (and (not          (eq (setq OldTxt (getstring T "\nEnter the old text: ")) "")        )        (not          (eq (setq NewTxt (getstring T "\nEnter the new text: ")) "")        )   )    (if (setq ss (ssget "x"                        (list '(0 . "TEXT,MTEXT")                              (cons 1 OldTxt)                              (cons 410 (getvar 'ctab))                        )                 )        )      (repeat (setq in (sslength ss))        (setq en (entget (ssname ss (setq in (1- in)))))        (entmod (subst (cons 1 Newtxt) (assoc 1 en) en))      )    ) ) (princ))
回复

使用道具 举报

9

主题

21

帖子

12

银币

初来乍到

Rank: 1

铜币
45
发表于 2022-7-6 08:00:26 | 显示全部楼层
You Rock!! Thanks!!!
回复

使用道具 举报

63

主题

6297

帖子

6283

银币

后起之秀

Rank: 20Rank: 20Rank: 20Rank: 20

铜币
358
发表于 2022-7-6 08:19:08 | 显示全部楼层
 
You're welcome .
回复

使用道具 举报

发表回复

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

本版积分规则

  • 微信公众平台

  • 扫描访问手机版

  • 点击图片下载手机App

QQ|关于我们|小黑屋|乐筑天下 繁体中文

GMT+8, 2025-3-10 10:06 , Processed in 0.379002 second(s), 60 queries .

© 2020-2025 乐筑天下

联系客服 关注微信 帮助中心 下载APP 返回顶部 返回列表