leonucadomi Posted September 12 Posted September 12 hello all: Can someone help me modify this routine? This routine adds a line about texts and mtexs and it is very helpful to me but sometimes instead of texts or mtext I have dimensions I would like the routine when selecting and detecting dimensions to also add a line above its value. I hope someone knows. here the code (defun c:ltx (/ o s) (if (setq s (ssget ":L" '((0 . "*TEXT")))) (foreach e (vl-remove-if 'listp (mapcar 'cadr (ssnamex s))) (setq o (vlax-ename->vla-object e)) (if (= "TEXT" (cdr (assoc 0 (entget e)))) (vla-put-textstring o (strcat "%%O" (vl-string-left-trim "%%O" (vla-get-textstring o)))) (vla-put-textstring o (strcat "\\O" (vl-string-left-trim "\\O" (vla-get-textstring o)))) ) ) ) (princ) ) thanks Quote
pkenewell Posted September 12 Posted September 12 (edited) @leonucadomi Try This: ;; original code by RonJonP, edited by P. Kenewell (defun c:ltx (/ o s) (command "._undo" "_be") (if (setq s (ssget ":L" '((0 . "*TEXT,DIMENSION")))) (foreach e (vl-remove-if 'listp (mapcar 'cadr (ssnamex s))) (setq o (vlax-ename->vla-object e)) (cond ((= "TEXT" (cdr (assoc 0 (entget e)))) (vla-put-textstring o (strcat "%%U%%O" (vl-string-left-trim "%%U%%O" (vla-get-textstring o)))) ) ((= "MTEXT" (cdr (assoc 0 (entget e)))) (vla-put-textstring o (strcat "\\L\\O" (vl-string-left-trim "\\L\\O" (vla-get-textstring o)))) ) ((= "DIMENSION" (cdr (assoc 0 (entget e)))) (if (= (vla-get-textoverride o) "") (vla-put-textoverride o "\\L\\O<>") (vla-put-textoverride o (strcat "\\L\\O" (vl-string-left-trim "\\L\\O" (vla-get-textoverride o)))) ) ) ) ) ) (command "._undo" "_end") (princ) ) Edited September 12 by pkenewell Added Undo marks 1 Quote
pkenewell Posted September 12 Posted September 12 (edited) @leonucadomi Actually - I think this version will work better i it will prevent it from stripping other formatting for the reason Lee Mac noted here: ; Original by RonJonP, edited by P. Kenewell (defun c:ltx (/ o s) (setvar "cmdecho" 0) (command "._undo" "_be") (if (setq s (ssget ":L" '((0 . "*TEXT,DIMENSION")))) (foreach e (vl-remove-if 'listp (mapcar 'cadr (ssnamex s))) (setq o (vlax-ename->vla-object e)) (cond ((= "TEXT" (cdr (assoc 0 (entget e)))) (vla-put-textstring o (strcat "%%U%%O" (vl-string-subst "" "%%U" (vl-string-subst "" "%%O" (vla-get-textstring o)) ) ) ) ) ((= "MTEXT" (cdr (assoc 0 (entget e)))) (vla-put-textstring o (strcat "\\L\\O" (vl-string-subst "" "\\L" (vl-string-subst "" "\\O" (vla-get-textstring o)) ) ) ) ) ((= "DIMENSION" (cdr (assoc 0 (entget e)))) (if (= (vla-get-textoverride o) "") (vla-put-textoverride o "\\L\\O<>") (vla-put-textoverride o (strcat "\\L\\O" (vl-string-subst "" "\\L" (vl-string-subst "" "\\O" (vla-get-textoverride o)) ) ) ) ) ) ) ) ) (command "._undo" "_end") (setvar "cmdecho" 1) (princ) ) Edited September 12 by pkenewell 1 1 Quote
leonucadomi Posted September 12 Author Posted September 12 THANK YOU THIS IS PRECISELY WHAT I NEEDED 1 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.