乐筑天下

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

[编程交流] Flip text - lisp

[复制链接]

1

主题

3

帖子

2

银币

初来乍到

Rank: 1

铜币
5
发表于 2022-7-5 15:37:23 | 显示全部楼层 |阅读模式
Hi, today is my first day in this group.
I would like to thank the admin of this group for accepting my registration.
 
I join here to learn things, techniques, etc. and sometimes I encountered problems that I can't find solution by browsing on the internet. I'm sure you can help & teach me.
 
First thing I need your help is about flipping/mirroring the text content. I usually use this in wiring connection. The format is SOURCE/DESTINATION. So, for example, my wire label on one end is TB1.1/TB9.8. I need to label the other end with T9.8/TB1.1. As you can see, it mirrors or flips the value after the / symbol.
 
I'm using Lee Mac's CopySwapTextV1-7.lsp that copy or swap the texts but I don't know how to modify it so I can use it for my purpose.
 
I really appreciate your help.
Thanks
回复

使用道具 举报

4

主题

2143

帖子

2197

银币

限制会员

铜币
-24
发表于 2022-7-5 15:49:36 | 显示全部楼层
I moved your thread to the AutoLISP, Visual LISP & DCL Forum, please ask questions in the most appropriate forum.
回复

使用道具 举报

76

主题

312

帖子

254

银币

后起之秀

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

铜币
390
发表于 2022-7-5 16:04:32 | 显示全部楼层
Welcome to this forum!
Im sure you can learn alot around here!
 
About your question, here is a very simple code:
I dont have time for a full code, but this may get someone started.
  1. (setq test "Hello/Goodbye")(setq result (strcat (substr test (+ 2 (vl-string-position (ascii "/") test))) "/" (substr test 1 (vl-string-position (ascii "/") test))))"Goodbye/Hello"
 
Where the format is flipped.
回复

使用道具 举报

66

主题

1552

帖子

1514

银币

后起之秀

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

铜币
325
发表于 2022-7-5 16:16:25 | 显示全部楼层
Hi,
  1. (defun C:test ( / f )  (setq f   '( ( c s / L cL )     (cond        ( (not (eq 'STR (type s))) nil)       (         (if (member c (setq cL (vl-string->list s)))           (apply 'strcat              (apply 'append               (mapcar                  ''( (x / tmp)                   (cond                     ( (not x) (if L (list (vl-list->string L))) )                     ( (= c x) (setq tmp L) (setq L nil) (list (vl-list->string (append tmp (list c)))) )                     ( (setq L (cons x L)) nil )                   )                 )                 (reverse (cons nil cL))               )             )           )           s         )       )     )   ) )  (princ "\nSelect texts to inverse: ") (foreach x   ('((/ SS) (if (setq SS (ssget "_:L-I" '((0 . "TEXT")))) (vl-remove-if-not ''((x) (eq 'ENAME (type x))) (apply 'append (ssnamex SS))))))   ('(( enx / g ) (setq g (assoc 1 enx)) (entmod (subst (cons 1 (f 47 (cdr g))) g enx))) (entget x)) ) (princ))
 
回复

使用道具 举报

1

主题

3

帖子

2

银币

初来乍到

Rank: 1

铜币
5
发表于 2022-7-5 16:26:03 | 显示全部楼层
thank you very much Aftertouch & Grrr... it works perfectly.
 
I replace "TEXT" with "MTEXT" so it will work with MTEXT too but it doesn't work with TEXT.
How to make it work for both TEXT and MTEXT?
 
thanks a lot...
回复

使用道具 举报

58

主题

3353

帖子

33

银币

顶梁支柱

Rank: 50Rank: 50

铜币
1761
发表于 2022-7-5 16:35:52 | 显示全部楼层
"MTEXT,TEXT" .. You might run into issues with mtext formatting though.
回复

使用道具 举报

1

主题

3

帖子

2

银币

初来乍到

Rank: 1

铜币
5
发表于 2022-7-5 16:39:36 | 显示全部楼层
thanks ronjonp... it helps a lot...
回复

使用道具 举报

发表回复

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

本版积分规则

  • 微信公众平台

  • 扫描访问手机版

  • 点击图片下载手机App

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

GMT+8, 2025-7-12 12:51 , Processed in 0.883709 second(s), 66 queries .

© 2020-2025 乐筑天下

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