Code Red => AutoLISP (Vanilla / Visual) => Topic started by: notredave on September 22, 2020, 10:50:06 AM
Title: MTEXT width to match text lenth
Post by: notredave on September 22, 2020, 10:50:06 AM
Good morning all,
I'm having a time trying to fix mtext through out drawings. I have mtext all over the place that when I double click on it, the bar goes off the screen, length wise. See Example 1 on attach drawing. I would like it to end close to vertical white line at end of text. When I use MTW lisp (attached), mtext width goes to zero but when I drag out the bar, it gives me 1 line per text, see Example 2. What is wrong with this mtext? It's all over my drawings. is there a fix for this? Any help would be greatly appreciated. I've tried stripmtext also to no avail.
Thank you, David
Title: Re: MTEXT width to match text lenth
Post by: Tharwat on September 22, 2020, 11:07:28 AM
Hi, Replace the subst function with the following:
Title: Re: MTEXT width to match text lenth
Post by: notredave on September 22, 2020, 11:20:31 AM
Tharwat,
Thank you for the response. I tried that, it brings ruler to beginning but when I stretch out the ruler to end of longest text, it goes to 1 column, 1 piece of text per line.
Thank you, David
Title: Re: MTEXT width to match text lenth
Post by: Tharwat on September 22, 2020, 11:28:52 AM
Yes correct, and I just gave you the solution to your question to reach the end of that white line. Try to recreate the Mtext object itself then this should solve the issue though you don't need more codes to do so.
Title: Re: MTEXT width to match text lenth
Post by: notredave on September 22, 2020, 11:38:41 AM
Thank you Tharwat. I appreciate it.
Title: Re: MTEXT width to match text lenth
Post by: Tharwat on September 22, 2020, 11:44:23 AM
You're most welcome.
Title: Re: MTEXT width to match text lenth
Post by: Tharwat on September 22, 2020, 01:39:14 PM
Hi David, Please try the following routine to work around the width issue of the Mtext objects and let me know how you get on with it.
Title: Re: MTEXT width to match text lenth
Post by: notredave on September 22, 2020, 01:55:21 PM
Tharwat,
It works great to reverse it. The only problem I see and if you can try it on my example drawing is to run the lisp and after it executes, try and grab the ruler and extend it. It puts it back as one column with one line of text per each line. I'm just going to run it on infinity ruler mtext and be done with it, I'm not going to mess with stretching out ruler. Some idiot must have made mtext with column, that's my guess. Thanks again, I really appreciate it. But both of your routines work!
Thank you, David
Title: Re: MTEXT width to match text lenth
Post by: Tharwat on September 22, 2020, 02:04:13 PM
It works here without going on one line as before now. Please assure if this is was your goal as shown in the following demo.
Title: Re: MTEXT width to match text lenth
Post by: notredave on September 22, 2020, 02:17:16 PM
Tharwat,
I hope this gif works. This is what I'm talking about after lisp does it thing. I can't stretch ruler back out or else it messes up. I'm just showing you but by no means spend anymore time on this. I will leave it as is. It works great! Thank you very much.
David
Title: Re: MTEXT width to match text lenth
Post by: Tharwat on September 22, 2020, 03:06:50 PM
I would not be able to go to sleep tonight if I did not solve the problem. :laugh: Please give this a go and be sure you are running this latest routine.