+ Reply to Thread
Page 1 of 3 1 2 3 LastLast
Results 1 to 10 of 23
  1. #1
    Junior Member
    Using
    AutoCAD 2007
    Join Date
    Feb 2008
    Posts
    11

    Question Getting rid of text formatting of mtext

    Registered forum members do not see this ad.

    I want to iterate through the mtexts of a given drawing and export them to Excel.suppose that there is an mtext in the drawing named mtextobj in which "sample" is written in the first line and "note" is written in the 2nd.this would be read as "sample note". i use textstring property:
    .
    .
    Dim mtextobj As AcadMText
    MsgBox mtextobj .TextString
    .
    .
    and autocad returns "sample\Pnote". this is appropriate for me.
    the problem is when text formatting of this mtext is changed.for example if i double click on the mtext and in the Text Formatting box change the color to red,autocad returns
    {\C1;sample\Pnote}

    or if i change the font to verdana it gives
    {\fVerdana|b0|i0|c0|p34;sample\fVerdana|b0|i0|c178 |p34;\P\fVerdana|b0|i0|c0|p34;note}

    How can i access to the real content inside the mtext? and exclude text formatting data which is merged with the string.
    any help is highly appreciated..
    Last edited by arman88; 2nd Mar 2008 at 02:51 pm.

  2. #2
    Senior Member mahahaavaaha's Avatar
    Using
    AutoCAD 2009
    Join Date
    Jul 2007
    Location
    Finland
    Posts
    340

    Default

    Hi,

    I don't think you have any other method than ging through the textstrings and individually stripping the controlcharacters. Take a look at the ExpressTools Uppercase Text-tool-lisp, you'll see that's the way Autodesk does it as well.
    File tcaseSup.lsp, this is the part where they strip the formatting:
    Code:
    (defun acet-mtext-format-extract ( str / lst raw len pos frmt flst a n j lst2 )
     
     (setq lst (list "{"    "}"    "\\P"    "\\~"
                     "\\{"    "\\}"    "\\O"    "\\L"
                     "\\S"    "\\A1"    "\\A2"    "\\A3"
                     "\\f"    "\\C"    "\\H"    "\\T"
                     "\\Q"    "\\W" "\\p"
               );list
           raw ""
           len (strlen str)
           pos 0
     );setq
     
     (while (> (strlen str) 0)
      
      (setq lst2 (mapcar '(lambda (x) (acet-str-find x str)) lst)
            lst2 (mapcar '(lambda (x) (if x (list x) x)) lst2)
            lst2 (apply 'append lst2)
               j (apply 'min lst2)
      );setq 
      (if (/= j 0)
          (progn
            (setq  raw (strcat raw 
                               (substr str 1 (- j 1))
                       )
                   str (substr str j)
                     a (acet-mtext-format-bite str) ;; (list format str offset)
                  frmt (car a)
                   str (cadr a)
                     n (+ pos j)
                   pos (+ pos 
                          j 
                          (caddr a)
                          (- (strlen frmt) 1)
                       )
                  frmt (list frmt n)
                  flst (cons frmt flst)
            );setq
            (setq n (+ (length lst) 10));get out of inner loop
          );progn
          (setq raw (strcat raw str)
                str ""
          );setq then get out
      );if    
     
     );while
     
     (list raw (reverse flst))
    );defun acet-mtext-format-extract
    /Petri
    Life is what happens to you while you're busy making other plans.
    John Lennon (1940 - 1980)

  3. #3
    Forum Newbie
    Using
    AutoCAD 2007
    Join Date
    Dec 2006
    Posts
    9

    Default

    I usually just explode the mtext. Use match properties to the format I want then recombine the text entities.

  4. #4
    Junior Member
    Using
    AutoCAD 2007
    Join Date
    Feb 2008
    Posts
    11

    Default

    Hi Petri(mahahaavaaha)
    Do those codes strip the textformatting? would you please let me know how can i use it. I am not that familiar with lisps.
    I copied them into a blank notepad and saved it as tcaseSup.lsp. then in acad
    Tools>AutoLISP>Load Application i loaded tcaseSup.lsp. then i wrote tcaseSup in the prompt and pressed Enter. but acad returned and error: "Unknown command "TCASESUP". Press F1 for help."
    Was it the correct way?
    Last edited by arman88; 3rd Mar 2008 at 01:04 pm.

  5. #5
    Super Member Hedgehog's Avatar
    Computer Details
    Hedgehog's Computer Details
    Operating System:
    XP sp 3
    Motherboard:
    Asus NCL-DE/1U E7520
    CPU:
    2 x Intel Xeon 7150N
    RAM:
    8 x Kingston KHX6400D2K2/4G 4 GB PC2-6400
    Graphics:
    NVidia Quadro FX 5500 1 GB Pci-X 16
    Primary Storage:
    2 x Seagte Barracuda 7200.10 320 GB HDD
    Monitor:
    ViewSonic VP2290b-2Black 22” LCD
    Using
    MEP 2009
    Join Date
    Aug 2007
    Location
    Any Pub, Derbyshire, UK
    Posts
    896

    Default

    I use one called stripmtext.lsp but I suspect it does essentially the same thing...
    Attached Files
    Only the lonely only ... PhotoGallery / Music

  6. #6
    Junior Member
    Using
    AutoCAD 2007
    Join Date
    Feb 2008
    Posts
    11

    Default

    Quote Originally Posted by Hedgehog View Post
    I use one called stripmtext.lsp but I suspect it does essentially the same thing...
    I tested that in the same way. autocad gave me an error:
    "cannot load DCL file stripmtext[3].dcl"

    In the file it is said that for AutoCAD 2000 thru 2004.mine is 2007.
    thanks anyway

    I am trying to find a VBA code for that

  7. #7
    Super Member Hedgehog's Avatar
    Computer Details
    Hedgehog's Computer Details
    Operating System:
    XP sp 3
    Motherboard:
    Asus NCL-DE/1U E7520
    CPU:
    2 x Intel Xeon 7150N
    RAM:
    8 x Kingston KHX6400D2K2/4G 4 GB PC2-6400
    Graphics:
    NVidia Quadro FX 5500 1 GB Pci-X 16
    Primary Storage:
    2 x Seagte Barracuda 7200.10 320 GB HDD
    Monitor:
    ViewSonic VP2290b-2Black 22” LCD
    Using
    MEP 2009
    Join Date
    Aug 2007
    Location
    Any Pub, Derbyshire, UK
    Posts
    896

    Default

    Apologies... won't let me upload a DCL... erm, try this zip of it... I've run it on 2006/7/8
    Attached Files
    Only the lonely only ... PhotoGallery / Music

  8. #8
    Junior Member
    Using
    AutoCAD 2007
    Join Date
    Feb 2008
    Posts
    11

    Default

    Quote Originally Posted by Hedgehog View Post
    Apologies... won't let me upload a DCL... erm, try this zip of it... I've run it on 2006/7/8
    how should i run it? it still returns the same error. should i copy the DCL file to a special path? or load it manually in acad?

  9. #9
    Super Member CAB's Avatar
    Using
    AutoCAD 2000
    Join Date
    May 2004
    Location
    Tampa, Florida
    Posts
    801

    Default

    There is a newer version.
    Code:
    ;|
    
    StripMtext 4 BETA
    Main function that performs the format removal written by John Uhden
    All other supporting code and user interface written by Steve Doman
    
    -------------------------------------------------------------------
    
    Notes for Beta 4A 7/18/2005:
    
    1) New file names are: StripMtext[4a].lsp & StripMtext[4].dcl
    2) Added support for Acad Tables.
    3) Fields inside Mtext objects seem to process ok, but need more testing.
    4) Currently working on Tab removal.  DCL shows Tabs, but it doesn't work yet.
    5) The report which prints a count of objects processed is temporarily disabled.
    6) Please email bug reports, comments, or annoyances to: sdoman@qwest.net
    7) Should I add support for the new fangled ArcLength Dimensions?
    
    |;

  10. #10
    Super Member Hedgehog's Avatar
    Computer Details
    Hedgehog's Computer Details
    Operating System:
    XP sp 3
    Motherboard:
    Asus NCL-DE/1U E7520
    CPU:
    2 x Intel Xeon 7150N
    RAM:
    8 x Kingston KHX6400D2K2/4G 4 GB PC2-6400
    Graphics:
    NVidia Quadro FX 5500 1 GB Pci-X 16
    Primary Storage:
    2 x Seagte Barracuda 7200.10 320 GB HDD
    Monitor:
    ViewSonic VP2290b-2Black 22” LCD
    Using
    MEP 2009
    Join Date
    Aug 2007
    Location
    Any Pub, Derbyshire, UK
    Posts
    896

    Default

    Registered forum members do not see this ad.

    Quote Originally Posted by arman88 View Post
    how should i run it? it still returns the same error. should i copy the DCL file to a special path? or load it manually in acad?
    Bung 'em both in your support directory then appload the .lsp in Autocad... use stripmtext to run
    Only the lonely only ... PhotoGallery / Music

Similar Threads

  1. Text Formatting Problem?
    By lost0822 in forum AutoCAD Drawing Management & Output
    Replies: 16
    Last Post: 27th Oct 2010, 06:59 pm
  2. text formatting issue
    By studiorat in forum AutoCAD General
    Replies: 9
    Last Post: 10th Jan 2008, 09:15 pm
  3. Text appears to be faded in Text Formatting
    By edwin in forum AutoCAD Beginners' Area
    Replies: 3
    Last Post: 1st Aug 2007, 07:07 pm
  4. Formatting in MTEXT
    By Aries7 in forum AutoCAD Drawing Management & Output
    Replies: 12
    Last Post: 27th Dec 2006, 08:55 pm
  5. Text formatting
    By capita tech in forum AutoCAD Beginners' Area
    Replies: 1
    Last Post: 5th Oct 2005, 03:19 pm

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts