;;===========================================================
;; UNFORMAT.LSP (c)2003, John F. Uhden, Cadlantic/CADvantage
;; v1.0 (04-01-03)
;; Removes MTEXT formatting with option to retain the "\\P" LineFeeds
;;
;; Arguments:
;; Mtext - either an Ename or VLA-Object
;; KeepLF - nil (discard LineFeeds) non-nil (retain LineFeeds)
;;
;; NOTES:
;; Only R15 or higher.
;; v1.0 is only the first attempt.
;; We can always embellish the code with additional options.
;; Yes, it can probably be sped up using integers, but this is legible.
;;
(defun UnFormat (Mtext KeepLF / Text Str)
(vl-load-com)
(cond
((= (type Mtext) 'VLA-Object))
((= (type Mtext) 'ENAME)
(setq Mtext (vlax-ename->vla-object Mtext))
)
(1 (setq Mtext nil))
)
(and
Mtext
(= (vlax-get Mtext 'ObjectName) "AcDbMText")
(setq Mtext (vlax-get Mtext 'TextString))
(setq Text "")
(while (/= Mtext "")
(cond
((wcmatch (strcase (setq Str (substr Mtext 1 2))) "\\[\\{}`~]")
(setq Mtext (substr Mtext 3)
Text (strcat Text Str)
)
)
((wcmatch (substr Mtext 1 1) "[{}]")
(setq Mtext (substr Mtext 2))
)
((and KeepLF (wcmatch (strcase (substr Mtext 1 2)) "\\P"))
(setq Mtext (substr Mtext 3)
Text (strcat Text "\\P")
)
)
((wcmatch (strcase (substr Mtext 1 2)) "\\[LOP]")
(setq Mtext (substr Mtext 3))
)
((wcmatch (strcase (substr Mtext 1 2)) "\\[ACFHQTW]")
(setq Mtext (substr Mtext (+ 2 (vl-string-search ";" Mtext))))
)
((wcmatch (strcase (substr Mtext 1 2)) "\\S")
(setq Str (substr Mtext 3 (- (vl-string-search ";" Mtext) 2))
Text (strcat Text (vl-string-translate "#^\\" " " Str))
Mtext (substr Mtext (+ 4 (strlen Str)))
)
(print Str)
)
(1
(setq Text (strcat Text (substr Mtext 1 1))
Mtext (substr Mtext 2)
)
)
)
)
)
Text
)
--
John Uhden, Cadlantic/formerly CADvantage
http://www.cadlantic.com
Sea Girt, NJ
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;;
;;
;; StripMtext v2.1 R15+ Copyright Steve Doman sdo...@yahoo.com 8/25/01
;;
;; Program removes inline formatting from Mtext objects.
;;
;; Call by command:
;; Stripmtext
;;
;; Or call from lisp or script:
;; (StripMtext ss) where ss is a selection set
;;
;; Example to process all mtext objects in drawing from lisp or script:
;; (StripMtext (ssget "x"))
I think I got it from this NG or CFiles?
seems to work pretty well.
cheers
Steve
"John Uhden" <juh...@cadlantic.com> wrote in message
news:6184267E79CB2AD9...@in.WebX.maYIadrTaRb...
--
John Uhden, Cadlantic/formerly CADvantage
http://www.cadlantic.com
Sea Girt, NJ
"Scribble" <Scri...@work.now> wrote in message
news:1DCBB384E5112D55...@in.WebX.maYIadrTaRb...
--
John Uhden, Cadlantic/formerly CADvantage
http://www.cadlantic.com
Sea Girt, NJ
"Scribble" <Scri...@work.now> wrote in message
news:1DCBB384E5112D55...@in.WebX.maYIadrTaRb...
From: "Steve Doman" <sdo...@yahoo.com>
Subject: Removing Mtext formatting StripMtext2.1
Date: Sunday, 26 August 2001 2:53 AM
For anyone that's interested,
Attached is the latest version of my StripMtext routine. Say for
example you have a drawing that contains Mtext objects where the text has
been formatted to override the current textsize, font, color, or whatever.
This program will strip the formatting overrides, allowing the Mtext objects
appearance to revert to its associated textstyle and layer properties.
This version is faster and strips more formatting codes then the previous
version which I posted on the Customization NG on 7/16/01.
"John Uhden" <juh...@cadlantic.com> wrote in message
news:4476866885BD5DB5...@in.WebX.maYIadrTaRb...
I'm not sure what's hard about stripping formatting
codes from MTEXT, but what I was referring to is
replacing formatted MTEXT.
FYI, I am currently working on StripMtext v3.0 The old version will attempt
to remove all formatting from selected mtext. The new version allows the
user to pick which formatting to remove via a dialog box. I am also adding
to v3.0 support for stripping formatting from dimensions mtext, which is
something I overlooked in prior versions (thanks to Joe Burke for
suggesting).
Regards,
Steve Doman
-----
"Scribble" <Scri...@work.now> wrote...
Regards,
Steve Doman
-----
"John Uhden" <juh...@cadlantic.com> wrote ...
> ;;========================================================
You'd better take another look at your methods, and check out what I just posted
in CF under the subject "StripMtext/Unformat"
--
John Uhden, Cadlantic/formerly CADvantage
http://www.cadlantic.com
Sea Girt, NJ
"Steve Doman" <sdo...@yahoo.com> wrote in message
news:8CC20A0A3F04E27E...@in.WebX.maYIadrTaRb...
I should have read your code more thoroughly, sorry. I was focusing on the
wcmatch argument and didn't see the strcase. I did try your the test you
posted on CF and see what you mean. My code failed to parse the path string
big time.
I guess that's why I'm a drafter and your a programmer. So what should I do
now? Do you want to finish my project? :)
Thanks for the heads up.
Regards,
Steve Doman
------
"John Uhden" <juh...@cadlantic.com> ...
Strip/Unformat Options
x Color x Tracking
x Width x Oblique
x Etc. <yuggh>
o All o Layers o Picklayers o Manually
| OK | | Cancel | | No Help Here |
--
John Uhden, Cadlantic/formerly CADvantage
http://www.cadlantic.com
Sea Girt, NJ
"Steve Doman" <sdo...@yahoo.com> wrote in message
news:94F6CEA9B9FF3BC4...@in.WebX.maYIadrTaRb...
If I try to rewrite my parsing routine to fix the problem that you pointed
out, then it would be difficult to come up with an orignial algorithm after
seeing your clever solution. So although I don't like writing DCL either,
sure I'll do it.
The goal for v3.0 is to allow the user to pick which formatting codes to
remove. That means we need to pass to your Unformat function a textstring
to be unformatted, and some additional arguments that can be used to control
what codes get removed from that textstring.
I suggest something like this:
(unformat
"textsting" ;string to be unformatted
"codes" ;simple codes to be removed
"codes;" ;complex codes with ";" delimiter
bit ;flag to remove hard returns, braces, etc.
)
Also in regards to removing curly braces "{}", that problem becomes much
more complex when not removing all formatting codes, since the codes that
are not to be stripped may be wrapped between braces.
I've handled the locked layer issue in v3.0 by wrapping 'vl-catch-all-apply
around 'vlax-put-property 'textstring. In v3.0, I've added ":L" to the
ssget arguments.
Thanks,
Steve Doman
-----
"John Uhden" <juh...@cadlantic.com> wrote...
e.g. (StripMtext String "ACHQS~")
The curly brackets are a problem if you want to be a purist; otherwise it's okay
to leave them in.
(vl-catch-all) is a good solution to locked layers and unknown anomalies.
--
John Uhden, Cadlantic/formerly CADvantage
http://www.cadlantic.com
Sea Girt, NJ
"Steve Doman" <sdo...@yahoo.com> wrote in message
news:08B7BA20E7CE1B25...@in.WebX.maYIadrTaRb...
An off-topic question: the following code uses "1" as the last test
expression in the cond function. I've seen this in some other code you've
posted. Does it operate the same as using "T" in its place, or is there some
subtle distinction?
Command: (cond ((= 1 1) (+ 1 1)) (1 (+ 2 3)))
2
Command: (cond ((= 1 2) (+ 1 1)) (1 (+ 2 3)))
5
Command: (cond ((= 1 2) (+ 1 1)) (T (+ 2 3)))
5
I'm looking forward to whatever you and Steve come up with.
Thanks to both of you...
Joe Burke
"John Uhden" <juh...@cadlantic.com> wrote in message
news:6184267E79CB2AD9...@in.WebX.maYIadrTaRb...
That's an old habit from the days when someone could (setq T nil) whereas
there's no way you could (setq 1 nil). In R15+ I believe that T is a protected
symbol.
I've got the UNFORMAT function working for variable unformatting codes
"ACFHLOPQSTW~" with an optional "*" for everything. Just waiting on Steve to
build a cutesy DCL.
--
John Uhden, Cadlantic/formerly CADvantage
http://www.cadlantic.com
Sea Girt, NJ
"Joe Burke" <job...@hawaii.rr.com> wrote in message
news:9A0DE174D17FB931...@in.WebX.maYIadrTaRb...
Thanks for the explanation. Looks like there's still reason to use 1 in lieu
of T under A2k2:
Command: (setq T nil)
nil
Command: (cond ((= 1 2) (+ 1 1)) (T (+ 2 3)))
nil
Command: (cond ((= 1 2) (+ 1 1)) (1 (+ 2 3)))
5
Joe Burke
"John Uhden" <juh...@cadlantic.com> wrote in message
news:F83CA64241705089...@in.WebX.maYIadrTaRb...
"Doug Broad" <dbr...@earthlink.net> wrote in message news:9F0EA47C55FF74C2...@in.WebX.maYIadrTaRb...
> There is no reason to use a test in the last condition if there is
> only one expression in the group...
<snip>
I'll stick to <some of> my old-fashioned methods.
--
John Uhden, Cadlantic/formerly CADvantage
http://www.cadlantic.com
Sea Girt, NJ
"Doug Broad" <dbr...@earthlink.net> wrote in message
news:9F0EA47C55FF74C2...@in.WebX.maYIadrTaRb...
> There is no reason to use a test in the last condition if there is
> only one expression in the group.
>
> I prefer T for readability and for clearly communicating the
> intent. (I would rather track down the misbehaving program
> and berate its author rather than change my program style.
> After all, if someone redefines T, a whole lot else will fail
> besides the last statement of a cond.
>
> What then would this mean with redefined T? (= 1 1)
> The return value would be T which would be nil.....
>
> Using 1 rather than T is quirky and raises more questions
> than it answers.
>
> Just my opinion.
> Regards,
> Doug
>
>
> "Joe Burke" <job...@hawaii.rr.com> wrote in message
news:F532F3508C2A5E39...@in.WebX.maYIadrTaRb...
> > John,
> >
> > Thanks for the explanation. Looks like there's still reason to use 1 in lieu
> > of T under A2k2:
>
> <snip>
>
>
Regards,
Doug
Just say (set 't 't)
"John Uhden" <juh...@cadlantic.com> wrote in message news:4F146A429AC68194...@in.WebX.maYIadrTaRb...
> I'll stick to <some of> my old-fashioned methods.
>
<snip>
I have found your v2.0 handy to remove embedded font types from mtext, which
has been my main need for it.
cheers
Steve
"Steve Doman" <sdo...@yahoo.com> wrote in message
news:E551EFD44C432EF6...@in.WebX.maYIadrTaRb...
I wrote a function to re-color the parts of a mtext, I lefted because the
command that I was going to use still I have some minor problems (this
command is for change the color of simple or nested objects, but I could not
finished yet is now abandon), if you want I can post the function maybe can
be useful.
luis.
Thanks,
Steve Doman
"John Uhden" <juh...@cadlantic.com> wrote in message
news:78A73271F20FFC6A...@in.WebX.maYIadrTaRb...
I'm not sure what the issue is with curly brackets. Just want to let you
know that's something I added to StripMtext. Sometimes after processing I'd
end up with this {text} in the Properties window. I added strip "\{" "\}"
I also added strip double spaces, convert to single space. I needed that
after adding strip hard returns.
One other thought, which I realize is beyond the intent... *maybe* an option
to let the user strip any character(s) desired? Example: in most cases I've
used StripMtext to fix text received from outside sources. The standard in
the architectural offices where I work is don't use periods in
abbreviations. I get a drawing which needs StripMtext and is full of
abbreviations with periods. It would be nice if I could strip the periods
while massaging the mtext, rather than search and replace as a separate
operation. Just a thought... and maybe not a good one.
Joe Burke
"Steve Doman" <sdo...@yahoo.com> wrote in message
news:5C96BB8BC3B415BB...@in.WebX.maYIadrTaRb...
--
John Uhden, Cadlantic/formerly CADvantage
http://www.cadlantic.com
Sea Girt, NJ
"sdoman" <sdo...@yahoo.com> wrote in message news:f1545...@WebX.maYIadrTaRb...
> Joe, It rather easy to remove the curly braces from the entire mtext string.
But much more difficult to strip them if we only want to remove some formatting.
These braces are used by AutoCAD to control the extent of a particular
formatting code. In other words, the braces group together charactes within the
textstring which are to have a specified formatting applied. Sometimes these
braces can be nested rather deep. So we can't just strip all the braces because
that would mess up the displayed formatting of that textstring. I haven't really
given it much thought yet, but perhaps there is a way to remove only the braces
the surround formatting codes that are being removed. If we choose to only
remove some formatting, then I don't see why it would matter to leave braces in,
since you wouldn't normally see them anyhow. If we choose to remove all
formatting, then we could and probably should remove the braces too. As for your
other concerns: I agree that if we are going to strip LineReturns, then we
should add a single space if one is not already there. Replacing other
characters such as "." can be done using AutoCAD's FIND command. So I don't see
that we need to duplicate that feature here. Also this is going to be open
code, so you can tweak it if you so desire. Regards,
> Steve Doman
Agreed. The "All" toggle is my primary concern, if that was in question.
Thanks for the info, Steve.
Joe
"John Uhden" <juh...@cadlantic.com> wrote in message
news:439119203C8CA958...@in.WebX.maYIadrTaRb...
Sorry I didn't notice your post untill today. If your function removes
Mtext formatting from a textsting, I'd be interested. Otherwise, John
Uhden's function handles the problem very well. Thank you for the offer.
Regards,
Steve Doman
----
"Luis Esquivel" <www.caddximation.com> wrote...
Ok, the DCL now has a "Saveall" & "Clearall" button. If all toggles are
checked, then the program will pass "*" as the search argument to John's
Unformat function. Is that what you were thinking John?
Also added a "Save Settings" toggle for saving the user's prefered default
setting to the Registry.
Anything else?
Steve Doman
"Joe Burke" <job...@hawaii.rr.com> wrote in message
news:3673322B1D89A974...@in.WebX.maYIadrTaRb...
Today you can find me at juh...@vannoteharvey.com
I don't have OE capabilities there.
--
John Uhden, Cadlantic/formerly CADvantage
http://www.cadlantic.com
Sea Girt, NJ
"Steve Doman" <sdo...@yahoo.com> wrote in message
news:887DFBB85DEB5852...@in.WebX.maYIadrTaRb...
Please send a copy of your function to sdo...@yahoo.com
I still need to merge the DCL into the wrapper, toss in the registry save
feature, and modify the prompt. I have all this tested and running in bits
and pieces of code here and there. Just have to put dump it all together
and give it a big stir.
Thanks,
Steve Doman
------
"John Uhden" <juh...@cadlantic.com> wrote in message
news:88E40A603C6836FB...@in.WebX.maYIadrTaRb...