TheSwamp
Code Red => AutoLISP (Vanilla / Visual) => Topic started by: butzers09silverado on July 19, 2011, 01:50:36 PM
-
So I had this code partially fixed... but it won't change the case to a "title case", it only changes it to upper or lower. I'd REALLY like to have tcase work on mleaders so you can pick... here's what i've got:
(defun c:demo (/ ent mleader sset)
(vl-load-com)
(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
(strcase (vla-get-textstring mleader)))); or (strcase T (vla-get-textstring mleader))
(princ)
)
gracias
-
Perhaps this will help:
http://www.theswamp.org/index.php?topic=29049.msg346098#msg346098
-
I posted in that topic, we could close this one then i guess? thank you, want to verify it works with multi-leaders.
-
Another example:
(defun c:demo ( / *error* ss obj )
(defun *error* ( msg )
(setvar 'NOMUTT 0)
(or (wcmatch (strcase msg) "*BREAK,*CANCEL*,*EXIT*")
(princ (strcat "\n** Error: " msg " **")))
(princ)
)
(setvar 'ERRNO 0)
(setvar 'NOMUTT 1)
(princ "\nSelect Multileader: ")
(while
(not
(or
(setq ss (ssget "_+.:S:E:L" '((0 . "MULTILEADER"))))
(= 52 (getvar 'ERRNO))
)
)
)
(if
(and ss
(eq acmtextcontent
(vla-get-contenttype (setq obj (vlax-ename->vla-object (ssname ss 0))))
)
)
(vla-put-textstring obj (LM:TitleCase (vla-get-textstring obj)))
)
(setvar 'NOMUTT 0)
(princ)
)
(defun LM:TitleCase ( s / n )
(vl-list->string
(mapcar
(function
(lambda ( x )
(setq n (if (and (or (not n) (= 32 n)) (< 96 x 123)) (boole 2 x 32) x))
)
)
(vl-string->list (strcase s t))
)
)
)
It uses the titlecase function I posted here (http://www.theswamp.org/index.php?topic=35221.msg404519#msg404519), (ignore all the other crap that is unfortunately included with that thread).
-
(ignore all the other crap that is unfortunately included with that thread).
Damn, that's pretty conceded.
-
(ignore all the other crap that is unfortunately included with that thread).
Damn, that's pretty conceded.
conceded?
conceded past participle, past tense of con·cede (Verb)
1. Admit that something is true or valid after first denying or resisting it.
-
(ignore all the other crap that is unfortunately included with that thread).
Damn, that's pretty conceded.
conceded?
conceded past participle, past tense of con·cede (Verb)
1. Admit that something is true or valid after first denying or resisting it.
oops: *conceited*
-
oops: *conceited*
I wasn't referring to the code that was posted. :wink:
-
oops: *conceited*
I wasn't referring to the code that was posted. :wink:
suuuure :wink:
-
haters gonna hate... lol :lmao:
We'll give-it-a-go today, I'll let ya know thanks again this could be huge.
-
tested
it works, AWESOME
just wondering what it would take to get the options in a command line to pick what case we want or some quick direction on how to modify that so i have separate lisp files for:
title
sentence
upper
lower
thoughts? thanks
-
Copyright won't allow me to post, but with little effort I was able to hack a mod into the Express Tool: TCASE to work with MLeaders.
-
This was fun to write:
(defun c:tcase2 ( / acsel func name ) ;; © Lee Mac 2011
(if
(ssget "_:L"
'(
(-4 . "<OR")
(0 . "ARCALIGNEDTEXT,ATTDEF,*TEXT")
(-4 . "<AND")
(0 . "INSERT")
(66 . 1)
(-4 . "AND>")
(-4 . "<AND")
(0 . "*DIMENSION")
(1 . "*?*")
(-4 . "AND>")
(-4 . "<AND")
(0 . "MULTILEADER")
(304 . "~LEADER_LINE{")
(-4 . "AND>")
(-4 . "OR>")
)
)
(progn
(initget "Sentence Lower Upper Title toGgle")
(setq func
(eval
(cdr
(assoc
(setq case
(cond
(
(getkword
(strcat "\nSpecify Case [Sentence/Lower/Upper/Title/toGgle] <"
(setq case (cond ( case ) ( "Upper" ))) ">: "
)
)
)
( case )
)
)
'(
("Upper" . strcase)
("Lower" . (lambda ( x ) (strcase x t)))
("Title" . EE:TitleCase)
("Sentence" . LM:SentenceCase)
("toGgle" . LM:ToggleCase)
)
)
)
)
)
(vlax-for obj
(setq acsel
(vla-get-activeselectionset
(vla-get-activedocument (vlax-get-acad-object))
)
)
(cond
( (wcmatch (setq name (vla-get-objectname obj)) "AcDb*Dimension")
(vla-put-textoverride obj (func (vla-get-textoverride obj)))
)
( (or (eq "RText" name)(eq "AcDbArcAlignedText" name))
(vlax-put-property obj 'contents (func (vlax-get-property obj 'contents)))
)
( (eq "AcDbMLeader" name)
(if (eq acmtextcontent (vla-get-contenttype obj))
(vla-put-textstring obj (func (vla-get-textstring obj)))
)
)
( (eq "AcDbBlockReference" name)
(foreach att (vlax-invoke obj 'getattributes)
(vla-put-textstring att (func (vla-get-textstring att)))
)
)
( t
(vla-put-textstring obj (func (vla-get-textstring obj)))
)
)
)
(vla-delete acsel)
)
)
(princ)
)
(defun EE:TitleCase ( s ) ;; ElpanovEvgeniy
(vl-list->string
(mapcar
(function
(lambda ( a b c ) (if (= 32 a) b c))
)
(cons 32 (vl-string->list s))
(vl-string->list (strcase s))
(vl-string->list (strcase s t))
)
)
)
(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))
)
)
)
(defun LM:ToggleCase ( s )
(vl-list->string
(mapcar
(function
(lambda ( a b c ) (if (< 96 a 123) b c))
)
(vl-string->list s)
(vl-string->list (strcase s))
(vl-string->list (strcase s t))
)
)
)
(vl-load-com) (princ)
Note that it won't work with formatted MText however.
-
by fun do you mean "fun" sarcastically or was it really fun? lisping is not fun for me because I can't write it... it's fun to try and figure out though.. 8-)
-
This was fun to write:
At the risk of inflating your ego anymore :wink: very nice work.
Note that it won't work with formatted MText however.
TCase doesn't handle all the new formatting very well.
-
by fun do you mean "fun" sarcastically or was it really fun? lisping is not fun for me because I can't write it... it's fun to try and figure out though.. 8-)
No sarcasm intended, it was indeed enjoyable to construct the program and satisfying to write the subfunctions to change the case of the string.
This was fun to write:
At the risk of inflating your ego anymore :wink: very nice work.
Thanks Alan, but I certainly hope I don't appear egocentric :-(
-
... I certainly hope I don't appear egocentric :-(
Never have appeared that way to me; do keep up the awesome work.
-
... I certainly hope I don't appear egocentric :-(
Never have appeared that way to me; do keep up the awesome work.
Thanks for the reassurance Michael :-)
-
awesome, just saying... :kewl:
-
Thanks for the reassurance Michael :-)
you're most welcome Lee :)
-
by fun do you mean "fun" sarcastically or was it really fun? lisping is not fun for me because I can't write it... it's fun to try and figure out though.. 8-)
No sarcasm intended, it was indeed enjoyable to construct the program and satisfying to write the subfunctions to change the case of the string.
This was fun to write:
At the risk of inflating your ego anymore :wink: very nice work.
Thanks Alan, but I certainly hope I don't appear egocentric :-(
nah, i was just giving you a hard time from your earlier comment.