TheSwamp

Code Red => AutoLISP (Vanilla / Visual) => Topic started by: mhcadman on May 02, 2008, 05:54:25 PM

Title: Will PAY $$ fpr lsp - MODIFY TEXT
Post by: mhcadman on May 02, 2008, 05:54:25 PM

 :)

PLEASE HELP!!!!

MODIFYING EXISTING TEXT

1st- the text can be mtext, mostly the text will be plain text.

2nd - the command will be placed in a toolbar button, for example: (load "chgtxt");chtxt

3rd - yes I know how to perform theses tasks one at a time.. it gets old after hours and hours of repetitious attribute editing.

4th - please respond only if you can write the program..  criticism isn't going to solve anything...  this is the program I want, period.  Maybe  in return, I can help you with something in Microstation.

humble cad man,,,,, mike....

-------------------------------------------------------------------------------
I've tried searching the web and using ACAD help but I can't make this lsp happen.

I need a lsp program that will change existing text.......

Existing test is:   PLAN EL.180'-0"

I want to select existing text to change.
 
Once selected, I want the selected text to be "UNDERLINED (adding %%u to the beginning- %%uEL.180'-0" )", the "STYLE" to change to "STD35E", the
"HEIGHT" to change to 3", the "LAYER" to change to "CY1".

An additional "help" (but not required) would be to have the lsp read a "data file" to import the "STYLE, HEIGHT, and LAYER". (Underlining will always be required.)
Different "data files" for multiple requirements.

Sincerely,
Mike
Title: Re: Will PAY $$ fpr lsp - MODIFY TEXT
Post by: JohnK on May 02, 2008, 06:08:15 PM
That doesn't sound like it isnt that hard of a procedure/request.
Title: Re: Will PAY $$ fpr lsp - MODIFY TEXT
Post by: mkweaver on May 02, 2008, 06:20:35 PM
Here's something to get you up and running.  Note that the layer and the text style must already exist or the routine will fail.
Zero error checking here (and zero testing)


Code: [Select]
(defun chgtxt( / obj oldstring newstring)
  (setq
    obj (vlax-ename->vla-object (car (entsel)))
    OldString (vla-get-textstring obj)
    NewString (vla-put-textstring obj (strcat "%%U" oldstring))
    )
  (vla-put-stylename obj "STD35E")
  (vla-put-height obj 3)
  (vla-put-layer obj "CY1")
  )code]
Title: Re: Will PAY $$ fpr lsp - MODIFY TEXT
Post by: JohnK on May 02, 2008, 06:31:59 PM
%%U doesnt work on mtext.
Title: Re: Will PAY $$ fpr lsp - MODIFY TEXT
Post by: T.Willey on May 02, 2008, 07:09:37 PM
If you really want to pay for this, make a donation to theSwamp.

[ http://www.theswamp.org/donate.html ]

Code: [Select]
(defun c:MyTest (/ ActDoc)
   
    (setq ActDoc (vla-get-ActiveDocument (vlax-get-Acad-Object)))
    (vla-EndUndoMark ActDoc)
    (vla-StartUndoMark ActDoc)
    (vla-Add (vla-get-Layers ActDoc) "CY1")
    (vla-Add (vla-get-TextStyles ActDoc) "STD35E")
    (if (ssget'((0 . "*TEXT")))
        (vlax-for obj (vla-get-ActiveSelectionSet ActDoc)
            (if (= (vla-get-ObjectName obj) "AcDbText")
                (vla-put-TextString obj (strcat "%%U" (vla-get-TextString obj)))
                (vla-put-TextString obj (strcat "{\\L" (vla-get-TextString obj) "}"))
            )
            (vla-put-StyleName obj "STD35E")
            (vla-put-Layer obj "CY1")
            (vla-put-Height obj 3)
        )
    )
    (vla-EndUndoMark ActDoc)
    (princ)
)
Title: Re: Will PAY $$ fpr lsp - MODIFY TEXT
Post by: JohnK on May 02, 2008, 07:25:24 PM
*blink-blink*
Title: Re: Will PAY $$ fpr lsp - MODIFY TEXT
Post by: M-dub on May 02, 2008, 07:31:20 PM
Nice thought, Tim.  :)
Title: Re: Will PAY $$ fpr lsp - MODIFY TEXT
Post by: T.Willey on May 02, 2008, 07:33:24 PM
*blink-blink*
Hope I didn't step on your toes, or anyone else's.  Or did I not do what the OP wanted?

Nice thought, Tim.  :)
Thanks.
Title: Re: Will PAY $$ fpr lsp - MODIFY TEXT
Post by: JohnK on May 02, 2008, 07:37:04 PM
Hope I didn't step on your toes, or anyone else's.  Or did I not do what the OP wanted?

I'm broke!! ...But, I guess $20 wouldn't have gotten me very much so no harm i guess. 
Title: Re: Will PAY $$ fpr lsp - MODIFY TEXT
Post by: T.Willey on May 02, 2008, 07:38:41 PM
Hope I didn't step on your toes, or anyone else's.  Or did I not do what the OP wanted?

I'm broke!! ...But, I guess $20 wouldn't have gotten me very much so no harm i guess. 
I don't think the OP saw it yet, so I can take it away.   :evil:

Just for you.   :-)
Title: Re: Will PAY $$ fpr lsp - MODIFY TEXT
Post by: Kerry on May 02, 2008, 07:42:55 PM
Quote from: OP Title
Will PAY $$ fpr lsp


...But, I guess $20 wouldn't have gotten me very much .........


 :|  I thought the offer was 2$ ( $$ )    :laugh:


Title: Re: Will PAY $$ fpr lsp - MODIFY TEXT
Post by: T.Willey on May 02, 2008, 07:44:52 PM
Quote from: OP Title
Will PAY $$ fpr lsp


...But, I guess $20 wouldn't have gotten me very much .........


 :|  I thought the offer was 2$ ( $$ )    :laugh:



If he's broke, 2$ is at least something to get him started.   :lmao:
Title: Re: Will PAY $$ fpr lsp - MODIFY TEXT
Post by: JohnK on May 02, 2008, 08:28:14 PM
Ok, im going to do some slight modifications to my version and you two are going to test it. But i need to know what bank you guys use and your favorite 4 digits first. 
Title: Re: Will PAY $$ fpr lsp - MODIFY TEXT
Post by: CAB on May 02, 2008, 09:29:13 PM
You should add (vl-load-com) to the beginning of both of those lisp routines.
Just in case it wasn't loaded already.
Title: Re: Will PAY $$ fpr lsp - MODIFY TEXT
Post by: M-dub on May 03, 2008, 12:23:02 AM
See, look at this...  This is typical of members of theSwamp.

Keep smilin' everyone.  :)
Title: Re: Will PAY $$ fpr lsp - MODIFY TEXT
Post by: JohnK on May 03, 2008, 02:14:55 AM
What is typical? Someone cheating someone else out of something? or Two bullies picking on a helpless, innocent, good person who only wanted to spread joy to others?
Title: Re: Will PAY $$ fpr lsp - MODIFY TEXT
Post by: Keith™ on May 03, 2008, 02:22:48 AM
What is typical?

You missed it on both accounts ...

Typical is how you misunderstood M-dub's comments.

Seriously though ... it is typical in the way that the members of theswamp have pitched in to help someone in need .. of course I could be wrong, because I didn't see the sarcasm tags on your post ;)
Title: Re: Will PAY $$ fpr lsp - MODIFY TEXT
Post by: Kerry on May 03, 2008, 02:37:46 AM

I think we all missed John's acceptance post for the contract.    :lmao:
Title: Re: Will PAY $$ fpr lsp - MODIFY TEXT
Post by: JohnK on May 03, 2008, 02:55:28 AM
Oh sure, just keep picking on the fat kid.

Keith, when have i ever added `sarcasm tags' to any of my posts?
Title: Re: Will PAY $$ fpr lsp - MODIFY TEXT
Post by: M-dub on May 03, 2008, 09:59:10 AM
Oh sure, just keep picking on the fat kid.

It's alright John... I'm used to it by now and just let it roll right off my back.  :)
Title: Re: Will PAY $$ fpr lsp - MODIFY TEXT
Post by: Keith™ on May 03, 2008, 10:02:02 AM
Oh sure, just keep picking on the fat kid.

Keith, when have i ever added `sarcasm tags' to any of my posts?
Well there ya go
Title: Re: Will PAY $$ fpr lsp - MODIFY TEXT
Post by: ELOQUINTET on May 05, 2008, 03:48:57 PM
Uh am I the only one who found this funny? I love defensive people. I didn't even have to look at his post count, I could tell he was new here as most people will bend over backwards to help you and for the most part only give constructive criticism or are joking around. Did he not come back and say thank you either, BAN HIM!!!

4th - please respond only if you can write the program..  criticism isn't going to solve anything...  this is the program I want, period.
Title: Re: Will PAY $$ fpr lsp - MODIFY TEXT
Post by: Maverick® on May 05, 2008, 03:59:40 PM
Interesting.  "Last active" on his profile is 30 seconds BEFORE the original post.  How does that work?  If someone signs in but doesn't do anything (yes, I'm aware of how I am setting myself up with that  :-D).... does it show as "active"?
Title: Re: Will PAY $$ fpr lsp - MODIFY TEXT
Post by: ELOQUINTET on May 05, 2008, 05:33:53 PM
Ban me, No wait don't Ban me BAN HIM
Title: Re: Will PAY $$ fpr lsp - MODIFY TEXT
Post by: jonesy on May 06, 2008, 02:59:35 AM
Uh am I the only one who found this funny? I love defensive people. I didn't even have to look at his post count, I could tell he was new here as most people will bend over backwards to help you and for the most part only give constructive criticism or are joking around. Did he not come back and say thank you either, BAN HIM!!!

4th - please respond only if you can write the program..  criticism isn't going to solve anything...  this is the program I want, period.
You may be joking about your comments, however, a new member may not feel that you are. :-)
Most members here have benefited from the abilities of others here, some more than others, I know...I have probably had more than my fair share of help  :-)... thats the great thing about this place, theres always someone willing to help.
Yes, its nice to get a thanks when you help someone, but it doesn't always happen... people too busy with rushed deadlines, too much work, not enough time etc...
Sorry... I'll stop now  :-(
Title: Re: Will PAY $$ fpr lsp - MODIFY TEXT
Post by: Guest on May 06, 2008, 08:45:14 AM
It ain't the prettiest thing, but it works.  Keep in mind there is no error checking and that the program assumes the layer/text style already exist in the drawing.

Code: [Select]
(defun C:ChTxt ( / objEnt objDat)
   (while (setq objEnt (entsel "\nSelect TEXT to modify: "))
      (if objEnt
         (progn
            (setq objDat (entget (car objEnt)))
            (setq objDat (subst (cons 7 "STD35E") (assoc 7 objDat) objDat))
            (setq objDat (subst (cons 8 "CY1") (assoc 8 objDat) objDat))
            (setq objDat (subst (cons 40 3.0)  (assoc 40 objDat) objDat))
            (setq objDat (subst (cons 1 (strcat "%%U" (cdr (assoc '1 objDat)))) (assoc 1 objDat) objDat))
            (entmod objDat)
         )
      )
   )
   (princ)
)

(princ)
Title: Re: Will PAY $$ fpr lsp - MODIFY TEXT
Post by: ELOQUINTET on May 06, 2008, 09:15:29 AM
Jonesy you sound like you need a hug so here's a virtual hug. I know what you mean that was my attempt to inform that user that we are pretty easy going around here. I wasn't implying that we are offended when we don't receive a thank you everytime. I do not agree with the statement that criticism isn't going to solve anything. Constructive criticism can be very helpful.
Title: Re: Will PAY $$ fpr lsp - MODIFY TEXT
Post by: jonesy on May 06, 2008, 09:31:08 AM
Thanks for the virtual hug :) First day back after a long weekend.
I agree that the vast majority of the time we are a pretty easy going bunch, sometimes its difficult to tell the "mood" of a post, so a newer member will not necessarily know that we are easy going,  so a well placed smiley could help.
Just a thought :)
Title: Re: Will PAY $$ fpr lsp - MODIFY TEXT
Post by: Guest on May 06, 2008, 09:35:04 AM
...a well placed smiley could help.

:-) :-) :-) :-D :-) :-) :-) :-D :-) :-) :-) :-D :-) :-) :-) :-D :-) :-) :-) :-D :-) :-) :-) :-D :-) :-) :-)

And a little something extra (http://www.hampsterdance.com/classinteractive.html).
Title: Re: Will PAY $$ fpr lsp - MODIFY TEXT
Post by: jonesy on May 06, 2008, 09:40:16 AM
LOL Thanks Matt..Better wait till I get home before I go for the "little something extra" Its bound to be blocked here!
Title: Re: Will PAY $$ fpr lsp - MODIFY TEXT
Post by: Guest on May 06, 2008, 09:49:38 AM
LOL Thanks Matt..Better wait till I get home before I go for the "little something extra" Its bound to be blocked here!

It's just the hampster dance web site!!   :-)
Title: Re: Will PAY $$ fpr lsp - MODIFY TEXT
Post by: jonesy on May 06, 2008, 09:53:51 AM
I cant get to many sites here at work :( Many of them work related too, so I stand no chance in getting to a non-work site...
But thanks for making me laugh :)
Title: Re: Will PAY $$ fpr lsp - MODIFY TEXT
Post by: ELOQUINTET on May 06, 2008, 02:53:33 PM
 :-) Feel Better
Title: Re: Will PAY $$ fpr lsp - MODIFY TEXT
Post by: jonesy on May 06, 2008, 03:12:44 PM
Yeah... I'm home now...
BTW thats a great smile :)
Title: Re: Will PAY $$ fpr lsp - MODIFY TEXT
Post by: JohnK on May 06, 2008, 03:37:26 PM
Sell flowers in `Lagniappe' this forum (`Code Red') is for hard core, down and dirty hacking/programing. We are a rough and tumble bunch. We are a motley crew of disbanded, hardened, evil dispensing, hackers set out to force AutoCAD to conform to our wills.

...here, allow me to demonstrate:
Kerry, you really hurt my feelings when you overlooked my code.
*waits*
See nothing?! Now watch this:
Kerry, that procedure you wrote for parsing a user entered string really sux; i mean my little brother could have done a better job with that char array.
*sits back to watch the flames*


Yipee!
Title: Re: Will PAY $$ fpr lsp - MODIFY TEXT
Post by: jonesy on May 06, 2008, 03:55:54 PM
That it may be, but it still needs to cater for new to programming people, new to the forum people who may not know you(or us) or your/our ways.
Heck theres time when I'd wanted to show my itty-bit of code, but didnt just because it doesnt stack up to the great and the good here... And I'm a long time member who knows people here.

Right, I'm going back to the Lagniappe forum now to continue to sell my flowers :)
Title: Re: Will PAY $$ fpr lsp - MODIFY TEXT
Post by: Bob Wahr on May 06, 2008, 04:07:51 PM
Sell flowers in `Lagniappe' this forum (`Code Red') is for hard core, down and dirty hacking/programing. We are a rough and tumble bunch. We are a motley crew of disbanded, hardened, evil dispensing, hackers set out to force AutoCAD to conform to our wills.

...here, allow me to demonstrate:
Kerry, you really hurt my feelings when you overlooked my code.
*waits*
See nothing?! Now watch this:
Kerry, that procedure you wrote for parsing a user entered string really sux; i mean my little brother could have done a better job with that char array.
*sits back to watch the posts disappear*


Yipee!
Fixed it for you.
Title: Re: Will PAY $$ fpr lsp - MODIFY TEXT
Post by: CAB on May 06, 2008, 04:42:26 PM
Looks like mhcadman got what he wanted and too much of what he didn't need.
This thread isn't going anywhere useful so I'll end it here.


Title: Re: Will PAY $$ fpr lsp - MODIFY TEXT
Post by: Kerry on February 02, 2010, 11:23:25 PM
Sell flowers in `Lagniappe'
this forum (`Code Red') is for hard core, down and dirty hacking/programing. We are a rough and tumble bunch. We are a motley crew of disbanded, hardened, evil dispensing, hackers set out to force AutoCAD to conform to our wills.
< .. >
See nothing?! Now watch this:
< .. >
*sits back to watch the flames*


Yipee!

Is there a Statute of limitations on flames   :wink: