乐筑天下

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

[编程交流] Find & Replace

[复制链接]

48

主题

1073

帖子

1043

银币

后起之秀

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

铜币
238
发表于 2022-7-6 10:54:15 | 显示全部楼层 |阅读模式
I'm sorry to be asking this as I should be able to do it myself and indeed have routines that ALMOST do what I need, but as usual I am in a hurry.
 
Has anybody got a routine that will replace the 2nd character in a (select by mouse) string with "Z"?
 
That is I need to select the text GS-1330/1A and have it updated to GZ-1330/1A
 
-------------------------------
 
I've now read what I need to do properly and I should be asking for the 2nd letter to become a Y
回复

使用道具 举报

10

主题

8258

帖子

8335

银币

初来乍到

Rank: 1

铜币
31
发表于 2022-7-6 11:15:42 | 显示全部楼层
Wouldn't you be able to do this using the normal FIND command and wildcards?
回复

使用道具 举报

48

主题

1073

帖子

1043

银币

后起之秀

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

铜币
238
发表于 2022-7-6 11:22:57 | 显示全部楼层
not easily as the first letter isn't fixed. I have done one sheet (out of many) with find A?- replace with AY- but I have a complete alphabet to go through.
 
Searching for ??- gives me ?Y-
回复

使用道具 举报

54

主题

3755

帖子

3583

银币

后起之秀

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

铜币
438
发表于 2022-7-6 11:33:47 | 显示全部楼层
  1. (defun c:test (/ ss) (if (setq ss (ssget "_:L" '((0 . "MTEXT,TEXT"))))   ((lambda (i / ent s)      (while (setq e (ssname ss (setq i (1+ i))))        (setq s (cdr (assoc 1 (setq ent (entget e)))))        (entmod (subst (cons 1 (strcat (substr s 1 1) "Y" (substr s 3))) (cons 1 s) ent))      )    )     -1   ) ) (princ))
回复

使用道具 举报

54

主题

3755

帖子

3583

银币

后起之秀

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

铜币
438
发表于 2022-7-6 11:50:42 | 显示全部楼层
  1. (defun c:test (/ ss replace) (if (and (setq ss (ssget "_:L" '((0 . "MTEXT,TEXT"))))          (/= "" (setq replace (getstring "\nSpecify replacement letter: ")))     )   ((lambda (i / ent s)      (while (setq e (ssname ss (setq i (1+ i))))        (setq s (cdr (assoc 1 (setq ent (entget e)))))        (entmod (subst (cons 1 (strcat (substr s 1 1) replace (substr s 3))) (cons 1 s) ent))      )    )     -1   ) ) (princ))
回复

使用道具 举报

48

主题

1073

帖子

1043

银币

后起之秀

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

铜币
238
发表于 2022-7-6 12:04:18 | 显示全部楼层
thanks Alan, I'll try it on Monday but the problem has gone away (from me). I went home early unwell yesterday and left the problem with somebody else   Should be done by Monday!
回复

使用道具 举报

发表回复

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

本版积分规则

  • 微信公众平台

  • 扫描访问手机版

  • 点击图片下载手机App

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

GMT+8, 2025-3-6 12:23 , Processed in 0.370267 second(s), 64 queries .

© 2020-2025 乐筑天下

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