Message 1 of 5
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report
So I found this routine in some black hole in the interwebs (don't know where or when) but wanted to modify it to fit our purposes. The problem I'm having is that the the ARG is not working propperly. I have replaced ARG in line 47 with the strings produced from GETKWORD and it works correctly. What am I missing?
(defun C:JOINTXT (/ *error* END ENT LST OBJ WD STR ARG) (defun *error* (errmsg) (if (not (wcmatch errmsg "Function cancelled,quit / exit abort,console break")) (princ (strcat "\nError: " errmsg))) (command "_.regen" "_.undo" "_end") (setvar 'cmdecho cmde) (princ) ) (setq cmde (getvar 'cmdecho)) (setvar 'cmdecho 0) (command "_.undo" "_begin") (initget "1 2 3 4 5") (setq KW (getkword "\nSelect a spacing type: [1 - None |/ 2 - Single Space |/ 3 - Single Return |/ 4 - Double Return |/ 5 - Custom] (1): ")) (IF (= KW 2) (setq ARG " ") (IF (= KW 3) (setq ARG "\\P") (IF (= KW 4) (setq ARG "\\P\\P") (IF (= KW 5) (setq ARG (GETSTRING T "\nEnter custom spacing text: ")) (setq ARG "") ) ) ) ) (while (not END) (setvar 'errno 0) (setq ENT (car (entsel "\nSelect Text/Mtext to join: "))) (if (and (= (getvar 'errno) 0); picked something (wcmatch (cdr (assoc 0 (entget ENT))) "TEXT,MTEXT")) (progn (if (not (member (vlax-ename->vla-object ENT) LST)) (setq LST (cons (vlax-ename->vla-object ENT) LST))) (redraw ENT 3)) (if (= (getvar 'errno) 52) (setq END T) (prompt "\nNothing selected --") ) ) ) (setq OBJ (last LST)) (if (= (substr (vla-get-ObjectName OBJ) 5) "Text") (progn (setq WD (apply 'max (mapcar 'vla-get-Width (vl-remove-if '(lambda (x) (= (vla-get-ObjectName x) "AcDbText")) LST) ) ) ) (command "_.txt2mtxt" (vlax-vla-object->ename OBJ) "") (setq OBJ (vlax-ename->vla-object (entlast))) (if (> WD 0) (vla-put-Width OBJ WD)) ) ) (setq STR (vla-get-TextString OBJ)) (foreach x (cdr (reverse LST)) (setq STR (strcat STR ARG (vla-get-TextString x))) (vla-delete x)) (vla-put-TextString OBJ STR) (command "_.undo" "_end") (setvar 'cmdecho cmde) (princ) )
Andrew Ingram
Civil 3D x64 2019
Win 10 x64 Pro
Intel Xeon E5-1620
32 GB Ram
Civil 3D x64 2019
Win 10 x64 Pro
Intel Xeon E5-1620
32 GB Ram
Solved! Go to Solution.