harilalmn Posted December 13, 2011 Share Posted December 13, 2011 Hi All, I wrote this routine to change the text string of all MLeaders in the drawing to Caps. I dont know hat is wrong, however, it doesn't happen... (defun c:caps( / ss Count n LeaderObj dxf txtstr newtxt newdxf) (setq ss (ssget "_X" '((0 . "MULTILEADER")))) (setq Count (sslength ss)) (setq n 0) (repeat Count (setq LeaderObj (ssname ss n)) (setq dxf (entget LeaderObj)) (setq txtstr (cdr (assoc 304 dxf))) (setq newtxt (strcase txtstr)) (setq newdxf (subst (cons 304 newtxt) (assoc 304 dxf) dxf)) (prompt (strcat "\nOld Text : " txtstr)) (prompt (strcat "\nNew Text : " newtxt)) (prompt "\n=============") (entmod newdxf) (setq n (1+ n)) ) (prompt (strcat "\nUpdated " (itoa Count) " Multileaders...")) ) Quote Link to comment Share on other sites More sharing options...
Tharwat Posted December 13, 2011 Share Posted December 13, 2011 Things like this .... ? (defun c:TesT (/ selectionset) (vl-load-com) ;;; Tharwat 13. Dec. 2011 ;;; (if (ssget "_x" '((0 . "MULTILEADER"))) (vlax-for mleader (setq selectionset (vla-get-activeselectionset (vla-get-activedocument (vlax-get-acad-object)))) (vla-put-textstring mleader (strcase (vla-get-textstring mleader))) ) (princ) ) (vla-delete selectionset) (princ) ) Quote Link to comment Share on other sites More sharing options...
harilalmn Posted December 13, 2011 Author Share Posted December 13, 2011 Wow...!!! That worked...!!! Thanks a lot...!!! Quote Link to comment Share on other sites More sharing options...
Tharwat Posted December 13, 2011 Share Posted December 13, 2011 Wow...!!! That worked...!!! Thanks a lot...!!! You're welcome . Quote Link to comment Share on other sites More sharing options...
Lee Mac Posted December 13, 2011 Share Posted December 13, 2011 (defun c:TesT (/ selectionset) (vl-load-com) ;;; Tharwat 13. Dec. 2011 ;;; (if (ssget "_x" '((0 . "MULTILEADER"))) (vlax-for mleader (setq selectionset (vla-get-activeselectionset (vla-get-activedocument (vlax-get-acad-object)))) (vla-put-textstring mleader (strcase (vla-get-textstring mleader))) ) (princ) ) (vla-delete selectionset) (princ) ) What if there are no MLeaders in the drawing... ? Quote Link to comment Share on other sites More sharing options...
Tharwat Posted December 13, 2011 Share Posted December 13, 2011 What if there are no MLeaders in the drawing... ? It means that we should add progn function to obtain vla-delete function within Thanks Quote Link to comment Share on other sites More sharing options...
Lee Mac Posted December 13, 2011 Share Posted December 13, 2011 To answer the OP's original question: I wrote this routine to change the text string of all MLeaders in the drawing to Caps. I dont know hat is wrong, however, it doesn't happen... Apart from the check for a valid SelectionSet, I don't see too much wrong with your code harilalmn, indeed, it works as expected for me I might rewrite the code in the following way: (defun c:caps ( / en i ss tx ) (if (setq ss (ssget "_X" '((0 . "MULTILEADER")))) (repeat (setq i (sslength ss)) (setq en (entget (ssname ss (setq i (1- i)))) tx (assoc 304 en) ) (entmod (subst (cons 304 (strcase (cdr tx))) tx en)) ) ) (princ) ) Quote Link to comment Share on other sites More sharing options...
3dwannab Posted June 2, 2014 Share Posted June 2, 2014 Hi all, I was wondering if its possible to get Sentence case if possible for multi-leaders. Lee I've seen your code for changing text strings to that but I'm at a lost end in trying to implementing it. Thanks. Quote Link to comment Share on other sites More sharing options...
Lee Mac Posted June 2, 2014 Share Posted June 2, 2014 I was wondering if its possible to get Sentence case if possible for multi-leaders. Lee I've seen your code for changing text strings to that but I'm at a lost end in trying to implementing it. Use my Text Case functions, and simply substitute a call to LM:SentenceCase for strcase in the above code: (defun c:caps ( / en i ss tx ) (if (setq ss (ssget "_X" '((0 . "MULTILEADER")))) (repeat (setq i (sslength ss)) (setq en (entget (ssname ss (setq i (1- i)))) tx (assoc 304 en) ) (entmod (subst (cons 304 ([color=red]LM:SentenceCase[/color] (cdr tx))) tx en)) ) ) (princ) ) Quote Link to comment Share on other sites More sharing options...
3dwannab Posted June 3, 2014 Share Posted June 3, 2014 Use my Text Case functions, and simply substitute a call to LM:SentenceCase for strcase in the above code: (defun c:caps ( / en i ss tx ) (if (setq ss (ssget "_X" '((0 . "MULTILEADER")))) (repeat (setq i (sslength ss)) (setq en (entget (ssname ss (setq i (1- i)))) tx (assoc 304 en) ) (entmod (subst (cons 304 ([color=red]LM:SentenceCase[/color] (cdr tx))) tx en)) ) ) (princ) ) Terrific Lee, Thank you AGAIN. Code for anyone who has trouble or lazy (defun c:tcase_leader_Sentence ( / en i ss tx ) ;; Sentence Case - Lee Mac ;; Returns the supplied string converted to Sentence Case (defun LM:SentenceCase ( s / f ) (vl-list->string (mapcar (function (lambda ( a b c ) (if (or f (= 46 a)) (progn (setq f (= 32 b)) b) c) ) ) (cons 46 (vl-string->list s)) (vl-string->list (strcase s)) (vl-string->list (strcase s t)) ) ) ) ;; Orignal Code (if (setq ss (ssget "_X" '((0 . "MULTILEADER")))) (repeat (setq i (sslength ss)) (setq en (entget (ssname ss (setq i (1- i)))) tx (assoc 304 en) ) (entmod (subst (cons 304 (LM:SentenceCase (cdr tx))) tx en)) ) ) (princ) ) Quote Link to comment Share on other sites More sharing options...
Lee Mac Posted June 3, 2014 Share Posted June 3, 2014 Terrific Lee, Thank you AGAIN. You're welcome 3dwannab! Quote Link to comment Share on other sites More sharing options...
3dwannab Posted June 5, 2014 Share Posted June 5, 2014 You're welcome 3dwannab! Hi Lee, you may be interested to know I posted on the original location of the LISP and a user replied with the code to use the built in TcaseSup.lsp (defun c:demo (/ ent mleader sset txt) (vl-load-com) (load "TcaseSup.lsp") (setvar "errno" 0) (while (and (not sset) (/= (getvar "errno") 52) ) (prompt "\n >> Select multileader >> ") (setq sset (ssget "+.:S:N" '((0 . "MULTILEADER")))) ) (if (and sset (setq mleader (vlax-ename->vla-object (setq ent (ssname sset 0)))) (eq acmtextContent (vla-get-contenttype mleader))) (vla-put-textstring mleader (acet-tcase-change-string (vla-get-textstring mleader) "Title"))) (princ) ) (acet-tcase-change-string (vla-get-textstring mleader) "Title"))) can be changed to: (acet-tcase-change-string (vla-get-textstring mleader) "upper"))) etc, etc. For the life of me I cannot find that thread now :/ Quote Link to comment Share on other sites More sharing options...
Lee Mac Posted June 5, 2014 Share Posted June 5, 2014 FWIW _$ (setq str "this is a test. ") "this is a test. " _$ (repeat 4 (setq str (strcat str str))) "this is a test. this is a test. this is a test. this is a test. this is a test. this is a test. this is a test. this is a test. this is a test. this is a test. this is a test. this is a test. this is a test. this is a test. this is a test. this is a test. " _$ (strlen str) 256 _$ (eq (acet-tcase-change-string str "Sentence") (LM:sentencecase str)) T _$ (benchmark '((acet-tcase-change-string str "Sentence") (LM:sentencecase str))) Benchmarking ...............Elapsed milliseconds / relative speed for 4096 iteration(s): (LM:SENTENCECASE STR)........................1295 / 5.49 <fastest> (ACET-TCASE-CHANGE-STRING STR "Sente...).....7114 / 1.00 <slowest> Quote Link to comment Share on other sites More sharing options...
3dwannab Posted June 5, 2014 Share Posted June 5, 2014 Your code was never in doubt. How come people like you are not snapped up by autodesk is beyond me! 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.