masterfal Posted yesterday at 03:00 AM Posted yesterday at 03:00 AM hi all, i have a lisp routine i've been trying to set up to quickly update the line space factors of selected text to 0.8. now i've got it working ok for multiline text but i want it to also include multileaders. after running its picking the multileaders and then telling me the change to 0.8 has been completed but in reality the multileaders havent been updated. they are still 1. any ideas how i can get them to update? (defun c:LSFsel ( / ss i ent obj acLineSpacingStyleAtLeast mtextObj newText) (vl-load-com) (setq acLineSpacingStyleAtLeast 1) (if (setq ss (ssget)) (progn (setq i 0) (while (< i (sslength ss)) (setq ent (vlax-ename->vla-object (ssname ss i))) (cond ;; MText: apply directly ((= (vla-get-objectname ent) "AcDbMText") (vla-put-LineSpacingStyle ent acLineSpacingStyleAtLeast) (vla-put-LineSpacingFactor ent 0.8) ) ;; MLeader: rebuild MText ((= (vla-get-objectname ent) "AcDbMLeader") (vl-catch-all-apply (function (lambda () (setq mtextObj (vlax-invoke ent 'GetMText)) (if mtextObj (progn (setq newText (vla-AddMText (vla-get-ModelSpace (vla-get-ActiveDocument (vlax-get-acad-object))) (vla-get-insertionpoint mtextObj) (vla-get-width mtextObj) (vla-get-TextString mtextObj) ) ) (vla-put-LineSpacingStyle newText acLineSpacingStyleAtLeast) (vla-put-LineSpacingFactor newText 0.8) (vlax-invoke ent 'SetMText newText) (vla-delete newText) ; cleanup temp MText ) ) ) ) ) ) ) (setq i (1+ i)) ) (princ "\n Line spacing factor set to 0.8 for selected items.") ) (princ "\n No objects selected.") ) (princ) ) Quote
Saxlle Posted 23 hours ago Posted 23 hours ago Hi @masterfal, I don't know what do you want to achieve with this: (vl-catch-all-apply (function (lambda () (setq mtextObj (vlax-invoke ent 'GetMText)) (if mtextObj (progn (setq newText (vla-AddMText (vla-get-ModelSpace (vla-get-ActiveDocument (vlax-get-acad-object))) (vla-get-insertionpoint mtextObj) (vla-get-width mtextObj) (vla-get-TextString mtextObj) ) ) but there is several issues in this code, like: 'GetMText doesn't exist as Method, you can't use "acLineSpacingStyleAtLeast" as variable to store the value, etc. You can try with this: (defun c:LSFsel ( / ss i ent obj acLineSpacingStyleAtLeast mtextObj newText) (vl-load-com) (if (setq ss (ssget)) (progn (setq i 0) (while (< i (sslength ss)) (setq ent (vlax-ename->vla-object (ssname ss i))) (cond ;; MText: apply directly ((= (vla-get-objectname ent) "AcDbMText") (vla-put-LineSpacingStyle ent 1) (vla-put-LineSpacingFactor ent 0.8) ) ;; MLeader: rebuild MText ((= (vla-get-objectname ent) "AcDbMLeader") (vla-put-TextLineSpacingStyle ent acLineSpacingStyleAtLeast) (vla-put-TextLineSpacingFactor ent 0.80) ) ) (setq i (1+ i)) ) (princ "\n? Line spacing factor set to 0.8 for selected items.") ) (princ "\n?? No objects selected.") ) (princ) ) Try it, and see if it's helpful. 1 Quote
GLAVCVS Posted 23 hours ago Posted 23 hours ago 23 minutes ago, Saxlle said: Hi @masterfal, I don't know what do you want to achieve with this: (vl-catch-all-apply (function (lambda () (setq mtextObj (vlax-invoke ent 'GetMText)) (if mtextObj (progn (setq newText (vla-AddMText (vla-get-ModelSpace (vla-get-ActiveDocument (vlax-get-acad-object))) (vla-get-insertionpoint mtextObj) (vla-get-width mtextObj) (vla-get-TextString mtextObj) ) ) but there is several issues in this code, like: 'GetMText doesn't exist as Method, you can't use "acLineSpacingStyleAtLeast" as variable to store the value, etc. You can try with this: (defun c:LSFsel ( / ss i ent obj acLineSpacingStyleAtLeast mtextObj newText) (vl-load-com) (if (setq ss (ssget)) (progn (setq i 0) (while (< i (sslength ss)) (setq ent (vlax-ename->vla-object (ssname ss i))) (cond ;; MText: apply directly ((= (vla-get-objectname ent) "AcDbMText") (vla-put-LineSpacingStyle ent 1) (vla-put-LineSpacingFactor ent 0.8) ) ;; MLeader: rebuild MText ((= (vla-get-objectname ent) "AcDbMLeader") (vla-put-TextLineSpacingStyle ent acLineSpacingStyleAtLeast) (vla-put-TextLineSpacingFactor ent 0.80) ) ) (setq i (1+ i)) ) (princ "\n? Line spacing factor set to 0.8 for selected items.") ) (princ "\n?? No objects selected.") ) (princ) ) Try it, and see if it's helpful. Just one detail: it might be necessary to replace 'acLineSpacingStyleAtLeast' with 1 for MLEADERs as well. 1 Quote
Saxlle Posted 23 hours ago Posted 23 hours ago @GLAVCVS, I tryed with "acLineSpacingStyleAtLeast", where the default value is 1 (acLineSpacingStyleAtLeast = 1). But, if you want different number than "1", definetly need to change "acLineSpacingStyleAtLeast" with desired value. As always, you're the man, thanks! 1 Quote
GLAVCVS Posted 22 hours ago Posted 22 hours ago (edited) No 'man': Ro'man' Edited 22 hours ago by GLAVCVS 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.