TheSwamp
Code Red => AutoLISP (Vanilla / Visual) => Topic started by: Andrew H on June 02, 2004, 12:08:04 PM
-
Does anyone have a lisp to add a box around mtext that will readjust if the mtext size or width changes?
I am currently using the "Enclose Text with Object" command from the express tools, but it takes too much time to get what you want plus if the text changes or needs to be adjusted later on down the road, you have to redo the box. Any help or direction will be greatly appreciated.
Thanks,
Andrew
-
lookup reactors in C:\<acad install>\Help\acad_dev.chm that is the only way I can see doing it.
-
What are reactors?
FYI... I know nothing about writing lisps, just using them.
-
well reactors are beyond my programming abilities also, so don't feel bad. :D
-
I understand. :P
Thank for trying anyway.
-
Not sure how or if this one works...just downloaded it from CADalyst.com
;;Tip1847 LOUD.LSP BOX FOR MTEXT (c) 2003 Chris
Picklesimer
(defun C:loud (/ tlf wid hig brg TLFO MTLAY BRGO CURLAY MTH FNM ENT)
;defun statement
(prompt "PICK MTEXT TO MAKE LOUD... ")
;prompt for user friendlyness
(setq ent (ssget)) ;sets selected mtext as variable "ent"
(setq fnm (ssname ent 0)) ;sets name of selected mtext as variable "fnm"
(setq tlf (cdr (assoc 10 (entget fnm))))
;sets top left corner variable "tlf"
(setq wid (cdr (assoc 42 (entget fnm))))
;sets variable "wid" as width of mtext
object
(setq hig (cdr (assoc 43 (entget fnm))))
;sets variable "hig" as height of mtext
object
(setq mth (cdr (assoc 40 (entget fnm))))
;sets variable "mth" to text height
(setq mtlay (cdr (assoc 8 (entget fnm))))
;sets variable "mtlay" to mtext layer
(setq brg (list (+ (car tlf) wid) (- (cadr tlf) hig)))
;formulates bottom right corner and
sets as "brg"
(setq tlfo (list (- (car tlf) mth) (+ (cadr tlf) mth)))
;formulates rectangle top left corner,
"tlfo"
(setq brgo (list (+ (car brg) mth) (- (cadr brg) mth)))
;formulates rectangle bot right cor,
"brgo"
(setq curlay (getvar "clayer")) ;saves the current layer name as "curlay"
(setvar "clayer" mtlay) ;changes current layer to mtext layer
(command "rectang" tlfo brgo) ;draws rectangle using formulated
coordinates
(setvar "clayer" curlay) ;changes current layer back to "curlay"
(command "pedit" "last" "w" (* 0.125 mth) "")
;edits pline width from 0 to 1/8*"mth"
(princ) ;prints nothing to eliminate nil
)
Good Luck...Hope it helps!
-
It works the same as the other lisps I have. Just draws a box around the existing text, but if the text size or width changes the box doesn't modify accordingly.
But thanks for the efforts.
-
Here's my solution:
+--------------------------------+
| ADJUSTABLE TEXT FRAME TEMPLATE |
+--------------------------------+
Sorry couldnt resist. But serioulsy, you could use reactors to do this but that would be one huge program. I dont have the time/practice/etc. to build anything like this andymore. I just dont know what to say besides "thats a tought one".
I wish i could help.
-
OBTW, That code failed on the first attempt. ...that prety much sums up my feelings about it too. (Holly script batman?!)
-
M-dub's lisp works great, but still can't adjust the text and have the box automatically adjust too. Thanks M-dub for trying.
Is there anyone out there up for the challenge?
-
Andrew i wasnt knocking M-dub. (He didnt write that code.)
What i was trying to say is that your request is a bigone. unless someone already has this application they can give out, your prolly not going to get someone to develop this for free. (this is a tall order and would require at least a couple of days worth of coding to get a solid working model. And that would be only a beta version. Next is debugging; that could take weeks.) Im not trying to squash your idea or anything --i think its a good one-- but ...well i think you understand what im trying to say now.
-
I know what Se7en's sayin' here...and agree. It does sound like it might take a lot of testing to get the bugs out. And he's right...I didn't write it...just found it.
...just downloaded it from CADalyst.com
In the meantime, might I suggest adding that lisp to your startup suite and creating a button for it so it's easy / quick to access the routine after editing mtext? Actually, create a new button and put the following macro in it...see if that'll do for now...
^C^Cerase;\;ddedit;\;loud;p;;
-
*NOTE*
YOu have to have that LOUD.LSP loaded already...
This is also assuming that you have an existing box around your text. (if you don't, you should make another macro without the erase command in it) That's what the erase command is for...so you can erase the current one. Then, you edit the text and right after, LOUD draws the new box around the text you just edited. Make sense? It's not as reliable as a properly tested, full blown lisp routine, but it's the best I can provide with my complete lack of lisp writing skills.
-
I actually like the text box command from the Express Tools, but I was just wondering if there was an exiting lisp out there that would stick to the text size adjustments.
Here is my version of what M-dub posted, but using the existing ACAD Express Tools "Enclose Text with Object" command.
^C^Cerase;\;ddedit;\;tcircle;\;;r;c;b;pedit;m;\;w;.5;;
This one will let you erase an existing box, edit the text, created a new box and give the new box a thinkness. This button includes my personal setting for all the command options, but you may need to adjust them the suite your needs.
-
^C^Cerase;\;ddedit;\;spell;\;tcircle;\;;r;c;b;pedit;m;\;w;.5;;
Here is another version with spell check included for anyone, like myself, whom can't spell worth a darn.