Jump to content

Mtext Width


giovanni64

Recommended Posts

Hi everybody,

 

I'm not sure if there is a Lisp routine which allows to change the width of

MTEXT. The only thing I've seen so far while searching in the internet is to explode the mtext to convert it into text and reconvert it back with

my routine shown in Thread

http://www.cadtutor.net/forum/showthread.php?61827-Text-hight-only-change

If you use my code replace the line (if (/= clr "")(ers 62 clr cla)) with

(if (> clr 0)(ers 62 clr cla)) or use Lee Mac's code.

I wonder if there is someone who knows to do that with a lisp routine.

 

Thanks in advance for any answer

 

giovanni64

Edited by giovanni64
Link to comment
Share on other sites

  • Replies 22
  • Created
  • Last Reply

Top Posters In This Topic

  • pBe

    7

  • giovanni64

    7

  • Lee Mac

    4

  • eldon

    3

Top Posters In This Topic

When you say width, do you mean the number of characters available before it goes to the next line? If so, and you only have a few to do, simply double click on the offending bit of text and drag the arrow at the top of the ruler over how ever far you want it.

Link to comment
Share on other sites

When you say width' date=' do you mean the number of characters available before it goes to the next line? If so, and you only have a few to do, simply double click on the offending bit of text and drag the arrow at the top of the ruler over how ever far you want it.[/quote']

 

Sorry, I don't mean the number of characters but the width of the individual characters itself i.e. 1.5, 1.8, 2.0 etc.

 

I've also checked Lee Mac's information but it won't work.

Link to comment
Share on other sites

for an unformatted Mtext entity its fairly easy

 

 
(defun c:test (/ wd ui str)
      (setq wd (getreal "\nEnter Width: "))
(Setq ui (vlax-ename->vla-object (car (entsel))))
      (setq str (vla-get-textstring ui))
      (if (setq pst (vl-string-search "[url="file://w/"]\\W[/url]" (vla-get-textstring ui)))
            (vla-put-textstring ui
         (vl-string-subst (strcat "[url="file://w/"]\\W[/url]" (rtos wd 2 2) ";")
                                     (substr str (1+ pst) (+ pst 6)) str))
               (vla-put-textstring ui (strcat "{\\W" (rtos wd 2 2) ";" str "}"))
           )
     )

Link to comment
Share on other sites

for an unformatted Mtext entity its fairly easy

 

 
(defun c:test (/ wd ui str)
(setq wd (getreal "\nEnter Width: "))
(Setq ui (vlax-ename->vla-object (car (entsel))))
(setq str (vla-get-textstring ui))
(if (setq pst (vl-string-search "[url="file://w/"]\\W[/url]" (vla-get-textstring ui)))
(vla-put-textstring ui
(vl-string-subst (strcat "[url="file://w/"]\\W[/url]" (rtos wd 2 2) ";")
(substr str (1+ pst) (+ pst 6)) str))
(vla-put-textstring ui (strcat "{\\W" (rtos wd 2 2) ";" str "}"))
)
)

 

I'm sorry but your code doesn't work. I've got the following message after selecting the MTEXT:

 

error: no function definition: VLAX-ENAME->VLA-OBJECT

Link to comment
Share on other sites

Add this

 

(defun c:test (/ wd ui str)

(vl-load-com)

.....

 

Thank you very much! It works perfect!

May I ask you if there is a way to change the oblique angel or is that to difficult?

Link to comment
Share on other sites

If all your Mtext had been in one Text Style, then you could change the width and oblique angle in the Style set-up. :D

 

But of course :) Globally that is not individually. hence lisp code

Link to comment
Share on other sites

Thank you very much! It works perfect!

May I ask you if there is a way to change the oblique angel or is that to difficult?

 

Not really that difficult giovanni64. you can tweak that snippet i posted to select multiple mtext entities and include a default value for the widht.

Whiel you're at it, take time to understand the code, its basicallty the same logic for oblique angle. try to figure it out for now.

 

Holelr if you need help.

Link to comment
Share on other sites

But of course :) Globally that is not individually. hence lisp code

 

If you are having to pick each Mtext, then having changed one manually, then use "Match Properties".

 

I am not against lisp, but some people seem to think that it is a universal panacea when there is often an inbuilt command, which they will never know about when presented with a lisp, so readily. :shock:

Link to comment
Share on other sites

...., but some people seem to think that it is a universal panacea when there is often an inbuilt command, which they will never know about when presented with a lisp, so readily. :shock:

 

True that :lol:

Link to comment
Share on other sites

The match properties would only affect the MText entity's global properties. What happens with pBe's code is it adds internal formatting to the text inside the MText ... that stuff doesn't repeat using matchprop.

 

There's not a lot of documentation to show how these internal MText format codes work, the simplest way of figuring out what each does is make a copy of the MText prior to doing an internal format. Then after modifying the text manually list and compare both - the differences should be what's required to make the text formatted according to your edits. Then from there you should be able to figure out how to add it to any other MText using something like pBe's code.

Link to comment
Share on other sites

There's not a lot of documentation to show how these internal MText format codes work, the simplest way of figuring out what each does is make a copy of the MText prior to doing an internal format. Then after modifying the text manually list and compare both - the differences should be what's required to make the text formatted according to your edits.

 

That is usually how I would go about figuring out which codes are used to achieve various effects, reverse engineering so to speak. However, for those looking for some kind of reference, Autodesk provides this short reference, and here is a small (incomplete) diagram that I created some time ago as a part reference.

 

Lee

Link to comment
Share on other sites

The match properties would only affect the MText entity's global properties.

 

I had envisaged that a new Text Style would have been set up with the Width and Oblique angle set as required. Then merely by choosing the required Mtexts the properties of the Text Style can be changed. (Match Properties will work)

 

In previous threads, the difficulties created by internal formatting in Mtext have been roundly condemned, and I was trying to circumvent future problems.

 

However the OP did ask for a lisp, so I hope you lispers will warn of the complications being stored up as well. There do not appear to be enough caveats, just easy button pushing being provided :shock:

Link to comment
Share on other sites

As I mentioned at the beginning of my thread in order not to get entangled the easyest way

will be to explode the Mtext to receive plain text than do the fomatting and use my

AETXT.LSP routine than reconvert to Mtext by typing TXT2MTXT at the command prompt.

I understand that it is not that easy and I don't want you guys getting a headache or even angry with me.

:unsure:

Link to comment
Share on other sites

I understand that it is not that easy and I don't want you guys getting a headache or even angry with me.

:unsure:

 

No worries giovanni64, No headaches nor anger here. :) have you figured out the code for oblique angle yet?

Link to comment
Share on other sites

That is usually how I would go about figuring out which codes are used to achieve various effects, reverse engineering so to speak.

 

Me too, 80% of the time. thank you for the reference Lee

Link to comment
Share on other sites

have you figured out the code for oblique angle yet?

 

Sorry, but I haven't figured it out yet. I think that it cannot be only done with AutoLisp but Visual Lisp and that I don't know anything.

I just downloaded the AutoCAD 2000 Visual Lisp Tutorial (I have AutoCAD 2011).

Is that good to learn from or is there a better one?

 

:unsure:

Link to comment
Share on other sites

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.

Guest
Unfortunately, your content contains terms that we do not allow. Please edit your content to remove the highlighted words below.
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.


×
×
  • Create New...