The Hurricane Forum
The Hurricane Forum
Home | Profile | Register | Active Topics | Members | Search | FAQ
Username:
Password:
Save Password
Forgot your Password?

 All Forums
 AutoCAD
 Lisp & Other Handy Files
 Problem with find and replace MTEXT
 New Topic  Reply to Topic
 Printer Friendly
Author Previous Topic Topic Next Topic  

anthenson
New Member

United Kingdom
11 Posts

Posted - December 27 2006 :  11:02:58 AM  Show Profile  Visit anthenson's Homepage  Reply with Quote
I have a strange problem when I run a script to find and replace parts of reference numbers in MTEXT objects.

The scripts fail to find most of the items I am searching for and the problem turned out to be the following.

Where on screen it shows the text string:

b=BA/DB2B/12R

if I actually list the MTEXT object is shows the content as:

b{\Fromans.shx|c1;=}BA{\Fromans.shx|c1;/DB}2B{\Fromans.shx|c1;/}
12R

So it has lots of extra info embedded in the text string for formatting and font style etc, meaning my find and replace script cant see the wood for the trees. eg if I search for the last bit, /12R, it doesnt find it due to the } in between. (and before you suggest it the items in between vary and I already have 200 permutations of text to find and replace without creating new ones).

This problem goes away if I simply double click on the MTEXT to open the editor window, and then click OK without changing anything. It automatically clears all the extraneous info from between the text characters.

Unfortuantely I have up to 2000 MTEXT entities to change per drawing so I cant do this individually.

SO basically I need a way of running a script to open each MTEXT object in the editing window and then close it without changing anything, so that it clears all the unwanted info and then I can run my find and replace scripts and they work.

I hope you follow this as its quite hard to explain.

Can anyone help please?

Admin
Administrator



652 Posts

Posted - December 27 2006 :  8:49:22 PM  Show Profile  Visit Admin's Homepage  Reply with Quote
Hi anthenson,

I found this lisp (plus DCL )
http://www.users.qwest.net/~sdoman/

Download Attachment: StripMtext[307].zip
5.78 KB (in case the website doesn't work)

With a bit of modification, it could be run to just strip everything out of every MTEXT object without having the dialog box appear. I bet it is a 5 minute job for a lisp expert to mod this to run in Hurricane. If you are really stuck, I can take a look, but it might take me a little while.

Please let me know if this helps any.

Regards,
Bill

Hurricane for AutoCAD
http://www.74mph.com
FAQ at
http://www.74mph.com/faq/faq.html
Tutorials at
http://www.74mph.com/tutorials.html
Go to Top of Page

anthenson
New Member

United Kingdom
11 Posts

Posted - December 28 2006 :  05:28:17 AM  Show Profile  Visit anthenson's Homepage  Reply with Quote
Thats done the trick. I dont really need it to be in a script as it doesnt take long to run it once on all 10 drawings before I run the find and replace scripts.

It strips off everything except the curly brackets {}, which I can get rid of using the normal find and replace scripts (replacing them with a blank) before I run the rest of the find and replace scripts.

Thanks for your help
Go to Top of Page

Admin
Administrator



652 Posts

Posted - December 30 2006 :  08:12:46 AM  Show Profile  Visit Admin's Homepage  Reply with Quote
Here is a fantastic response from one of the authors of StripMtext, Steve Doman. If you find this lisp useful, please send Steve (and his accomplice, John a "thanks!" (their contact info is also located in the lisp file)).
Steve Domans website: http://www.users.qwest.net/~sdoman/
John Uhdens website: http://www.cadlantic.com/

quote:
Attached is the latest version of StripMtext which can be run from a script. I wrote this version several months ago for someone that requested a script version. This user said it worked good for him, but I haven't really tested it much. Let me know if you experience any problems. The DCL file hasn't changed but is included for your convenience.

I have not received any reports of StripMtext destroying or degrading drawings. But to be prudent, please tell your users to back up their drawings.

The script needs to load StripMtext and execute the StripMtext function with the appropriate arguments. Below is the lisp code to do that:

Download Attachment: stripmtext308.zip
5.93 KB

Syntax:

(StripMtext ss formats)

Where:

SS = a selection set of objects. Non Mtext objects may be included but will be ignored.
Formats = a string of characters which represent each type of formatting codes to strip

Example 1:
You wish to remove all formatting from all mtext without prompting or dialog:

(load "Stripmtext[308]")
(stripmtext (ssget "x") "*")


Example 2:
You wish to prompt the user to select objects and automatically remove the color, font, & height formatting without showing the dialog.

(load "Stripmtext[308]")
(stripmtext (ssget) "CFHQ")

Here is a legend for the formatting characters:

A = Alignment
C = Color
F = Font
H = Height
L = Underscore
O = Overscore
P = Linefeed (Paragraph)
Q = Obliquing
S = Spacing (Stacking)
T = Tracking
W = Width
~ = Non-breaking Space
* = Wildcard strips all formats including curly braces.

Hopefully this information is clear. But if it isn't, just let me know and I'll try to clarify further.

Regards,
Steve Doman




Hurricane for AutoCAD
http://www.74mph.com
FAQ at
http://www.74mph.com/faq/faq.html
Tutorials at
http://www.74mph.com/tutorials.html
Go to Top of Page
  Previous Topic Topic Next Topic  
 New Topic  Reply to Topic
 Printer Friendly
Jump To:
The Hurricane Forum © 2009 - 2021 Go To Top Of Page
This page was generated in 0.35 seconds. Snitz Forums 2000