mtext background mask default settings

Discussion in 'AutoCAD' started by Tom Hanley, Oct 11, 2004.

  1. Tom Hanley

    Tom Hanley Guest

    How can I set my mtext to always have a background mask with 1.25 offset
    using background color - by default....?
     
    Tom Hanley, Oct 11, 2004
    #1
  2. Tom Hanley

    C Witt Guest

    well it's not a "default" setting.. (no such thing for mtext mask so far).

    but you could use this..(a lisp I cooked up)

    ;| Tweeked by C Witt


    Original by Lee Ambrosius,

    Begins here
    90 - 1 if Background Mask is enabled
    2 if background mask is disabled
    3 if Background Mask is enabled and set to use Background Color
    63 - 1 if Background Mask is to use the specified color in 441
    256 specifies to use the background color
    45 - Specifies the Border Offset value
    421 - Specifies the True color that should be used for the Background Mask (mtext)
    441 - Specifies the True color that should be used for the Background Mask (dims)
    const int DXF_FILLBOXSCALE = 45;
    const int DXF_BITFLAGS = 90; (1 or 3)
    const int DXF_FILLTRANSPARENCY = 441;
    const int DXF_FILLCOLORSTART = 63;
    Acad::ErrorStatus acdbSetMTextBackground(AcDbMText*& pMtext, bool enable, AcCmColor* pColor, AcCmTransparency* pTransp, double* pScale)
    |;

    (defun c:MTMask (/ mtext_ss mask_list mtcont nel emax en sscount)
    (prompt "\nApply Mtext Mask")
    (setq MTEXT_SS (ssget (list (cons 0 "MTEXT"))))
    (setq emax (sslength MTEXT_SS) sscount 0)
    (progn
    (setq mask_list
    (list
    (cons 90 3)
    (cons 63 256)
    (cons 45 1.25)
    (cons 441 1616860)
    )
    )
    )
    (while (< sscount emax)
    (progn
    (setq EN (SSNAME MTEXT_SS ssCOUNT))
    (utacet-textmask-group-list)
    (utacet-textmask-unmask EN GLST)
    (setq el (entget en))
    (progn
    (foreach con '(102 102)
    (setq el (vl-remove (assoc con el) el))
    (entmod el)
    )
    (entmod el)
    (setq EN EL)
    (entmod EN)
    )
    )
    (setq EL EN)
    (setq mtcont nil)
    (setq nel nil)
    (progn
    (setq mtwidth (* (cdr (assoc 42 el))1.015))
    (setq EL (subst (cons 41 mtwidth) (assoc 41 EL) EL))
    (progn
    (setq nel el)
    (while (/= (assoc 3 nel) nil)
    (setq mtcont
    (if (= mtcont nil)
    (cdr (assoc 3 nel))
    (strcat mtcont (cdr (assoc 3 nel)))
    )
    )
    (setq nel (vl-remove (assoc 3 nel) nel))
    )
    (if (= mtcont nil)
    (setq mtcont (cdr (assoc 1 nel)))
    (setq mtcont (strcat mtcont (cdr (assoc 1 nel))))
    )
    (setq el nel)
    )
    (while (/= (vl-string-search " " mtcont) nil)
    (setq mtcont (vl-string-subst " " " " mtcont))
    )
    (setq EL (subst (cons 1 mtcont) (assoc 1 EL) EL))
    (entmod EL)
    (setq EN EL)
    (entmod EN)
    )
    (setq sscount (1+ sscount))
    )
    (princ)
    )

    (defun c:MTUnmask (/ sset mask_list emax en COUNT)
    (prompt "\nRemove Mtext Mask")
    (setq sset (ssget (list (cons 0 "MTEXT"))))
    (setq COUNT 0)
    (if (/= sset nil)(setq EN (ssname sset COUNT)))
    (if (/= sset nil)(setq EL (entget EN))(setq EN nil))
    (WHILE (/= EN nil)
    (setq EL (entget EN))
    (progn
    (foreach con '(63 45 441)
    (setq el (vl-remove (assoc con el) el))
    (entmod el)
    )
    (setq EL (subst (cons 90 2) (assoc 90 EL) EL))
    (entmod el)
    )
    (setq COUNT (1+ COUNT))
    (setq EN (SSNAME sset COUNT))
    )
    (princ)
    )
     
    C Witt, Oct 11, 2004
    #2
  3. Tom Hanley

    Tom Hanley Guest

    Thx, I tried it but it fails at the command line:
    no function definition: UTACET-TEXTMASK-GROUP-LIST

    AcCmColor* pColor, AcCmTransparency* pTransp, double* pScale)
     
    Tom Hanley, Oct 11, 2004
    #3
  4. Tom Hanley

    C Witt Guest

    just ";" comment these two lines out (or delete them)

    (utacet-textmask-group-list)
    (utacet-textmask-unmask EN GLST)

    forgot to remove them before posting.. (for in house use).
     
    C Witt, Oct 11, 2004
    #4
  5. Tom Hanley

    Tom Hanley Guest

    I've rem'd out the statements and now it doesn't fail but it doesn't mask
    either...I also tried to remask an already masked mtext to see if the
    settings of the mask would change but that didn't work either.
    mtunmask works fine though. :)
     
    Tom Hanley, Oct 11, 2004
    #5
  6. Tom Hanley

    C Witt Guest

    you have to make sure that the text is "in front" of the other objects
    (my lisp does not re-draw the text).

    look into the "texttofront" command (2k5 command)
     
    C Witt, Oct 11, 2004
    #6
  7. Tom Hanley

    Tom Hanley Guest

    Ok, but the reason I know it's not masking is that if I double click it and
    go into mtext editor...then right click to open the background mask dialog
    box, it isn't enabled. You can see the same thing in the properties dialog
    box when the mtext is selected. I'm sorry but it just isn't masking....
     
    Tom Hanley, Oct 11, 2004
    #7
  8. Tom Hanley

    C Witt Guest

    hmm.. odd..

    ok try this..



    ;| Tweeked by C Witt


    Original by Lee Ambrosius,

    Begins here
    90 - 1 if Background Mask is enabled
    2 if background mask is disabled
    3 if Background Mask is enabled and set to use Background Color
    63 - 1 if Background Mask is to use the specified color in 441
    256 specifies to use the background color
    45 - Specifies the Border Offset value
    421 - Specifies the True color that should be used for the Background Mask (mtext)
    441 - Specifies the True color that should be used for the Background Mask (dims)
    const int DXF_FILLBOXSCALE = 45;
    const int DXF_BITFLAGS = 90; (1 or 3)
    const int DXF_FILLTRANSPARENCY = 441;
    const int DXF_FILLCOLORSTART = 63;
    Acad::ErrorStatus acdbSetMTextBackground(AcDbMText*& pMtext, bool enable, AcCmColor* pColor, AcCmTransparency* pTransp, double* pScale)
    |;

    (defun c:MTMask (/ mtext_ss mask_list mtcont nel emax en sscount)
    (prompt "\nApply Mtext Mask")
    (setq MTEXT_SS (ssget (list (cons 0 "MTEXT"))))
    (setq emax (sslength MTEXT_SS) sscount 0)
    (progn
    (setq mask_list
    (list
    (cons 90 3)
    (cons 63 256)
    (cons 45 1.25)
    (cons 441 1616860)
    )
    )
    )
    (while (< sscount emax)
    (progn
    (setq EN (SSNAME MTEXT_SS ssCOUNT))
    (utacet-textmask-group-list)
    (utacet-textmask-unmask EN GLST)
    (setq el (entget en))
    (progn
    (foreach con '(102 102)
    (setq el (vl-remove (assoc con el) el))
    (entmod el)
    )
    (entmod el)
    )
    )
    (setq mtcont nil)
    (setq nel nil)
    (progn
    (setq mtwidth (* (cdr (assoc 42 el))1.015))
    (setq EL (subst (cons 41 mtwidth) (assoc 41 EL) EL))
    (progn
    (setq nel el)
    (while (/= (assoc 3 nel) nil)
    (setq mtcont
    (if (= mtcont nil)
    (cdr (assoc 3 nel))
    (strcat mtcont (cdr (assoc 3 nel)))
    )
    )
    (setq nel (vl-remove (assoc 3 nel) nel))
    )
    (if (= mtcont nil)
    (setq mtcont (cdr (assoc 1 nel)))
    (setq mtcont (strcat mtcont (cdr (assoc 1 nel))))
    )
    (setq el nel)
    )
    (while (/= (vl-string-search " " mtcont) nil)
    (setq mtcont (vl-string-subst " " " " mtcont))
    )
    (setq EL (subst (cons 1 mtcont) (assoc 1 EL) EL))
    (entmod EL)
    )
    (entmake el)
    (entdel en)
    (setq sscount (1+ sscount))
    )
    (princ)
    )

    (defun c:MTUnmask (/ sset mask_list emax en COUNT)
    (prompt "\nRemove Mtext Mask")
    (setq sset (ssget (list (cons 0 "MTEXT"))))
    (setq COUNT 0)
    (if (/= sset nil)(setq EN (ssname sset COUNT)))
    (if (/= sset nil)(setq EL (entget EN))(setq EN nil))
    (WHILE (/= EN nil)
    (setq EL (entget EN))
    (progn
    (foreach con '(63 45 441)
    (setq el (vl-remove (assoc con el) el))
    (entmod el)
    )
    (setq EL (subst (cons 90 2) (assoc 90 EL) EL))
    (entmod el)
    )
    (setq COUNT (1+ COUNT))
    (setq EN (SSNAME sset COUNT))
    )
    (princ)
    )
     
    C Witt, Oct 11, 2004
    #8
  9. Tom Hanley

    Tom Hanley Guest

    That still didn't work here...
    I found Lee Ambrosius original code and that works. I'll adjust it to mimick
    what you did. Thanks for your time in helping me out.
    Tom

    AcCmColor* pColor, AcCmTransparency* pTransp, double* pScale)
     
    Tom Hanley, Oct 11, 2004
    #9
  10. Tom Hanley

    C Witt Guest

    np.. duno why my version won't work for you..

     
    C Witt, Oct 11, 2004
    #10
  11. Tom Hanley

    Tom Hanley Guest

    If i figure it out, I'll post it...

     
    Tom Hanley, Oct 11, 2004
    #11
  12. Tom Hanley

    LUCAS Guest

    MAYBE ---NO ERROR CHECK
    (defun C:MTMASK (/ MASK_LIST ENT SS)
    (command "_.texttofront" "T")
    (setq SS (ssget "x" '((0 . "mtext"))))
    (setq MASK_LIST
    (list
    (cons 90 3)
    (cons 63 256)
    (cons 45 1.5)
    (cons 441 1616860)
    )
    N 0
    )
    (if SS
    (repeat (sslength SS)
    (setq ENT (entget (ssname SS N)))
    (setq ENT (append ENT MASK_LIST))
    (entmod ENT)
    (setq N (1+ N))
    )
    )
    (princ)
    )
     
    LUCAS, Oct 12, 2004
    #12
  13. Tom Hanley

    LUCAS Guest

    HI!UNMTMASK
    (defun C:UNMTMASK (/ SS N)
    (vl-load-com)
    (setq SS (ssget "x" '((0 . "mtext")))
    N 0
    )
    (if SS
    (repeat (sslength SS)
    (vla-put-backgroundfill
    (vlax-ename->vla-object (ssname SS N))
    0
    )
    (setq N (1+ N))
    )
    )
    (princ)
    )
     
    LUCAS, Oct 12, 2004
    #13
Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments (here). After that, you can post your question and our members will help you out.