Results 1 to 4 of 4

Thread: Tight Text Mask lisp, for anyone that wants it.

  1. #1
    Active Member
    Join Date
    2009-03
    Posts
    63
    Login to Give a bone
    0

    Default Tight Text Mask lisp, for anyone that wants it.

    Hey all, in my application inc Civil 3D I often run into a problem with large mtext notes, even with the reference rectangle set to 0's the text mask takes up too much page real estate, leaving chunks needlessly wiped out. I had been exploding the mtext, converting the individual lines of dtext to mtext, tweaking it back into place and turning on the text mask. I knew there had to be a better way, so I banged out this little routine yesterday. Seems to be working fine, though i have run into a slight left-to-right shift with some True Type fonts and a more noticeable shift with oblique text, also some special characters get messed up, but still much faster than previous for me.

    anyways here's the code, use it if you want, comment or critique it if you want, or ignore if you don't care. I just thought I'd share.

    Code:
    ; TightTextMask v1.0 CCalder May, 2013
    
    ; Permission to use, copy, modify, and distribute this software
    ; for any purpose and without fee is hereby granted
    
    ; Prompts user to select an mtext object. Explodes mtext and
    ; creates a new mtext object for each line of dtext with text
    ; mask turned on sometimes will shift text l or r if text is
    ; oblique, but usually text doesn't move
    
    
    (defun c:TTM (/) (c:TightTextMask)) ;shortcut
    
    (defun c:TightTextMask ( / en:mt en:dt en1 en2 en3 en4 cnt )
    
      (princ "\nSelect MText to Tight Mask: ")
      (setq en:mt (ssname (ssget "_:s" '((0 . "mtext"))) 0) )
    
      (command "explode" en:mt)
    
      (setq en:dt (ssget "_P"))
      (setq cnt 0)
    
      (repeat (sslength en:dt)
    
        (setq en1 (entget (ssname en:dt cnt)))
    
        (setq en2 (cdr (assoc 10 en1)))
    
        (setq en3 (cdr (assoc 40 en1)))
    
        (setq en4 (list (car en2) (+ (cadr en2) en3) (caddr en2)))
    
        (entmake
         (list
         (cons 0 "MTEXT")
         (cons 100 "AcDbEntity")
         (assoc 8 en1)
         (cons 100 "AcDbMText")
         (cons 10 en4)
         (assoc 40 en1)
         (cons 41 0.0)
         (cons 46 0.0)
         (cons 71 1)
         (cons 72 5)
         (assoc 1 en1)
         (assoc 7 en1)
         (assoc 50 en1)
         (cons 73 2)
         (cons 90 3)
         (cons 63 9)
         (cons 45 1.35))
        )
    
        (setq cnt (+ 1 cnt))
    
      )
    
      (command "erase" en:dt)
    
      (PRINC)
    
    )
    
    (princ "\n TightTextMask v1.0 \n CCalder, \nMay, 2013....loaded.")
    
    (terpri)
    
    (princ "Type \"TTM\" or \"TightTextMask\" to run")
    
    (print)
    Attached Files Attached Files

  2. #2
    AUGI Addict fixo's Avatar
    Join Date
    2005-05
    Location
    Pietari, Venäjä
    Posts
    1,269
    Login to Give a bone
    0

    Default Re: Tight Text Mask lisp, for anyone that wants it.

    Something goes wrong on my end,
    try on formatted mtext like this.
    {\fArial|b0|i0|c0|p0;\C1;RX-100 {\fTahoma|b1|i0|p0;\C121;Sniper} \C5;1.5708}

  3. #3
    Active Member
    Join Date
    2009-03
    Posts
    63
    Login to Give a bone
    0

    Default Re: Tight Text Mask lisp, for anyone that wants it.

    I could help more if I knew what "something" was that was going wrong. As far as I can reproduce, as said above, TrueType fonts (such as Arial and Tahoma) may shift slightly to the left or right (in my test it wasn't enough to throw it visibly out of line with the other text). Another thing that just hit me, it looks like your using font and color overrides within that mtext, if you were to just explode it (which my code does) it would revert any text back to its Style settings, whatever font that is, and it will explode the single line of mtext to 3 lines of dtext side by side, the Tahoma portion, being a bold TrueType font would be spaced a little wider than the Ariel portion and would leave a gap when it converts back to ariel normal (I'm just assuming thats what your base style is set to). The colors should carry through the routine. If that's whats going wrong, I'm afraid to modify it for your personal application, instead of exploding you'd have to parse the string and look for carriage returns and entmake new lines of mtext from that information, as well as trying to figure out how to space it vertically would be waaaay more complex then that simple rookie stuff I posted above. Sorry man.

  4. #4
    AUGI Addict fixo's Avatar
    Join Date
    2005-05
    Location
    Pietari, Venäjä
    Posts
    1,269
    Login to Give a bone
    0

    Default Re: Tight Text Mask lisp, for anyone that wants it.

    Okay, forget about this was just a dummy test,
    other than that is working good
    Happy coding

Similar Threads

  1. text mask deletes text
    By gingermick in forum AutoCAD Annotation
    Replies: 9
    Last Post: 2016-12-15, 05:59 PM
  2. 2011: Text Mask looses text
    By ccook79 in forum AutoCAD General
    Replies: 8
    Last Post: 2010-11-19, 08:39 PM
  3. Use LISP to turn off MTEXT background mask
    By jason.cyr13 in forum AutoLISP
    Replies: 2
    Last Post: 2007-08-03, 06:35 PM
  4. Replies: 8
    Last Post: 2007-07-03, 04:25 PM
  5. Updating Text Mask once Text has been edited
    By r_soula in forum AutoCAD General
    Replies: 8
    Last Post: 2007-06-05, 03:05 AM

Posting Permissions

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