giovanni64 Posted September 2, 2011 Share Posted September 2, 2011 (edited) 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 September 3, 2011 by giovanni64 Quote Link to comment Share on other sites More sharing options...
Lee Mac Posted September 2, 2011 Share Posted September 2, 2011 http://www.theswamp.org/index.php?topic=38691.0 Quote Link to comment Share on other sites More sharing options...
Jack_O'neill Posted September 2, 2011 Share Posted September 2, 2011 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. Quote Link to comment Share on other sites More sharing options...
giovanni64 Posted September 2, 2011 Author Share Posted September 2, 2011 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. Quote Link to comment Share on other sites More sharing options...
pBe Posted September 3, 2011 Share Posted September 3, 2011 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 "}")) ) ) Quote Link to comment Share on other sites More sharing options...
giovanni64 Posted September 3, 2011 Author Share Posted September 3, 2011 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 Quote Link to comment Share on other sites More sharing options...
pBe Posted September 3, 2011 Share Posted September 3, 2011 Add this (defun c:test (/ wd ui str) (vl-load-com) ..... Quote Link to comment Share on other sites More sharing options...
giovanni64 Posted September 3, 2011 Author Share Posted September 3, 2011 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? Quote Link to comment Share on other sites More sharing options...
eldon Posted September 3, 2011 Share Posted September 3, 2011 If all your Mtext had been in one Text Style, then you could change the width and oblique angle in the Style set-up. Quote Link to comment Share on other sites More sharing options...
pBe Posted September 3, 2011 Share Posted September 3, 2011 If all your Mtext had been in one Text Style, then you could change the width and oblique angle in the Style set-up. But of course Globally that is not individually. hence lisp code Quote Link to comment Share on other sites More sharing options...
pBe Posted September 3, 2011 Share Posted September 3, 2011 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. Quote Link to comment Share on other sites More sharing options...
eldon Posted September 3, 2011 Share Posted September 3, 2011 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. Quote Link to comment Share on other sites More sharing options...
pBe Posted September 3, 2011 Share Posted September 3, 2011 ...., 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. True that Quote Link to comment Share on other sites More sharing options...
irneb Posted September 3, 2011 Share Posted September 3, 2011 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. Quote Link to comment Share on other sites More sharing options...
Lee Mac Posted September 3, 2011 Share Posted September 3, 2011 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 Quote Link to comment Share on other sites More sharing options...
eldon Posted September 3, 2011 Share Posted September 3, 2011 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 Quote Link to comment Share on other sites More sharing options...
giovanni64 Posted September 3, 2011 Author Share Posted September 3, 2011 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. Quote Link to comment Share on other sites More sharing options...
pBe Posted September 4, 2011 Share Posted September 4, 2011 I understand that it is not that easy and I don't want you guys getting a headache or even angry with me. No worries giovanni64, No headaches nor anger here. have you figured out the code for oblique angle yet? Quote Link to comment Share on other sites More sharing options...
pBe Posted September 4, 2011 Share Posted September 4, 2011 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 Quote Link to comment Share on other sites More sharing options...
giovanni64 Posted September 4, 2011 Author Share Posted September 4, 2011 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? Quote Link to comment Share on other sites More sharing options...
Recommended Posts
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.