ant7 Posted October 21, 2020 Author Posted October 21, 2020 (edited) 47 minutes ago, Tharwat said: No but I meant something like this: ooh! I see, I wouldn't know how to create the box, but to be honest, that way you did it is perfect, it works like a dream, so nice and quick Edited October 21, 2020 by ant7 Quote
Tharwat Posted October 21, 2020 Posted October 21, 2020 If you like this way then just let me know to write such a working routine for you for free. 3 Quote
BIGAL Posted October 21, 2020 Posted October 21, 2020 Here is another version it allows you to type the numbers required directly on the command line. It uses a reactor to look at the error that occurs as it is not a valid command and pulls the numbers apart. I have set up 2 and 3 as the 1st string you can add more 4 5 6 etc so 230 will return 2 & 30 2300 2 & 300 for the 2 edits required. A couple of buts if you have set a defun and used numbers it may cause a problem I have a few defuns that use a number like c:47 so would have to exclude in error check or just simply rename the defun. ; enter numbers on command line and split into multi text ; Enter the text as 2300 it will be split into the 1st character and then what is left ; eg 230 = 2 30 2300 = 2 300 ; original code and methology by Alan H ; OCT 2015 1st version ; Oct 2020 2txt ((lambda nil (vl-load-com) (foreach obj (cdar (vlr-reactors :vlr-command-reactor)) (if (= "text-reactor" (vlr-data obj)) (vlr-remove obj) ) ) (vlr-command-reactor "text-reactor" '((:vlr-unknowncommand . text-reactor-callback))) ) ) (defun ah:txtsplitnum (/) (setq txt1 (substr com 1 1)) (setq txt2 (substr com 2)) (vla-sendcommand text-reactor-acdoc "txt2txt ") (princ) ) (defun ah:txtsplit (/) (setq txt1 (substr com 2 1)) (setq txt2 (substr com 3)) (vla-sendcommand text-reactor-acdoc "txt2txt ") (princ) ) (defun text-reactor-callback (obj com) (setq com (strcase (car com))) (cond ((and (wcmatch com "~*[~2.0-9]*") ) (ah:txtsplitnum) ) ( (wcmatch com "~*[~3.0-9]*") (ah:txtsplitnum) ) ) ) (or text-reactor-acdoc (setq text-reactor-acdoc (vla-get-activedocument (vlax-get-acad-object))) ) ; two text entries by AlanH (defun c:txt2txt (/ ss ss2) (princ "\n Pick 1st text") (setq ss (ssget "_+.:E:S" (list (cons 0 "Text")))) (princ "\nPick 2nd text") (setq ss2 (ssget "_+.:E:S" (list (cons 0 "Text")))) (if (and (/= ss nil) (/= ss2 nil)) (progn (setq ent (entget (ssname ss 0))) (entmod (subst (cons 1 txt1) (assoc 1 ent) ent)) (setq ent (entget (ssname ss2 0))) (entmod (subst (cons 1 txt2) (assoc 1 ent) ent)) ) (alert "Object picked was not text") ) (princ) ) Quote
ant7 Posted October 22, 2020 Author Posted October 22, 2020 13 hours ago, BIGAL said: Here is another version it allows you to type the numbers required directly on the command line. It uses a reactor to look at the error that occurs as it is not a valid command and pulls the numbers apart. I have set up 2 and 3 as the 1st string you can add more 4 5 6 etc so 230 will return 2 & 30 2300 2 & 300 for the 2 edits required. A couple of buts if you have set a defun and used numbers it may cause a problem I have a few defuns that use a number like c:47 so would have to exclude in error check or just simply rename the defun. ; enter numbers on command line and split into multi text ; Enter the text as 2300 it will be split into the 1st character and then what is left ; eg 230 = 2 30 2300 = 2 300 ; original code and methology by Alan H ; OCT 2015 1st version ; Oct 2020 2txt ((lambda nil (vl-load-com) (foreach obj (cdar (vlr-reactors :vlr-command-reactor)) (if (= "text-reactor" (vlr-data obj)) (vlr-remove obj) ) ) (vlr-command-reactor "text-reactor" '((:vlr-unknowncommand . text-reactor-callback))) ) ) (defun ah:txtsplitnum (/) (setq txt1 (substr com 1 1)) (setq txt2 (substr com 2)) (vla-sendcommand text-reactor-acdoc "txt2txt ") (princ) ) (defun ah:txtsplit (/) (setq txt1 (substr com 2 1)) (setq txt2 (substr com 3)) (vla-sendcommand text-reactor-acdoc "txt2txt ") (princ) ) (defun text-reactor-callback (obj com) (setq com (strcase (car com))) (cond ((and (wcmatch com "~*[~2.0-9]*") ) (ah:txtsplitnum) ) ( (wcmatch com "~*[~3.0-9]*") (ah:txtsplitnum) ) ) ) (or text-reactor-acdoc (setq text-reactor-acdoc (vla-get-activedocument (vlax-get-acad-object))) ) ; two text entries by AlanH (defun c:txt2txt (/ ss ss2) (princ "\n Pick 1st text") (setq ss (ssget "_+.:E:S" (list (cons 0 "Text")))) (princ "\nPick 2nd text") (setq ss2 (ssget "_+.:E:S" (list (cons 0 "Text")))) (if (and (/= ss nil) (/= ss2 nil)) (progn (setq ent (entget (ssname ss 0))) (entmod (subst (cons 1 txt1) (assoc 1 ent) ent)) (setq ent (entget (ssname ss2 0))) (entmod (subst (cons 1 txt2) (assoc 1 ent) ent)) ) (alert "Object picked was not text") ) (princ) ) Thank you Sir, I kindly appreciate your auto lisp, the one from MR. Tharwat is simple and perfect Quote
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.