jamestamayo Posted January 31, 2018 Share Posted January 31, 2018 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 Quote Link to comment Share on other sites More sharing options...
SLW210 Posted February 1, 2018 Share Posted February 1, 2018 I moved your thread to the AutoLISP, Visual LISP & DCL Forum, please ask questions in the most appropriate forum. Quote Link to comment Share on other sites More sharing options...
Aftertouch Posted February 1, 2018 Share Posted February 1, 2018 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. (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. Quote Link to comment Share on other sites More sharing options...
Grrr Posted February 1, 2018 Share Posted February 1, 2018 Hi, (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) ) Quote Link to comment Share on other sites More sharing options...
jamestamayo Posted February 1, 2018 Author Share Posted February 1, 2018 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... Quote Link to comment Share on other sites More sharing options...
ronjonp Posted February 1, 2018 Share Posted February 1, 2018 "MTEXT,TEXT" .. You might run into issues with mtext formatting though. Quote Link to comment Share on other sites More sharing options...
jamestamayo Posted February 1, 2018 Author Share Posted February 1, 2018 thanks ronjonp... it helps a lot... Quote Link to comment Share on other sites More sharing options...
Clint Posted April 24 Share Posted April 24 For some reason, the generous code submission has not effect on the TEXT or MTEXT in a file with the MIRRTEXT setting both as 1 or 0 (zero). I renamed Test to Fliptxt.lsp that appears to be run successfully. Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.