Lisp to set Mtext to standards

Discussion in 'AutoCAD' started by DB, Sep 27, 2004.

  1. DB

    DB Guest

    Hi all,

    I have the following lisp routine which sets layer , color, font style and
    text size. This was developed for
    Dtext but I am trying to modify it for Mtext. I can't see where Acad holds
    the current text size and colour
    settings for Mtext. Can any one help ?? Lisp routine follows.

    ;---------------------------------------------------------------------------
    ------------------------------------
    ; Entering text of standard height, layer, & Colour - 2.5mm, 3.5mm, 5.0mm,
    7.0mm - This one uses Mtext
    ;---------------------------------------------------------------------------
    ------------------------------------
    (defun c:T2m ()
    (setq TH 2.5 TC "7" TSY "GHD_STANDARD" TXT_MESS "\nStart point of 2.5mm
    Text")
    (mTXTSTD)
    (princ)
    )
    ;
    (defun c:T3m ()
    (setq TH 3.5 TC "2" TSY "GHD_STANDARD" TXT_MESS "\nStart point of 3.5mm
    Text")
    (mTXTSTD)
    (princ)
    )
    ;
    (defun c:T5m ()
    (setq TH 5.0 TC "1" TSY "GHD_STANDARD" TXT_MESS "\nStart point of 5.0mm
    Text")
    (mTXTSTD)
    (princ)
    )
    ;
    (defun c:T7m ()
    (setq TH 7.0 TC "4" TSY "GHD_STANDARD" TXT_MESS "\nStart point of 7.0mm
    Text")
    (mTXTSTD)
    (princ)
    )
    ;---------------------------------------------------------------------------
    --------------------------
    ; Error checking
    ;---------------------------------------------------------------------------
    --------------------------
    (defun EXIT_mTXTSTD (errmsg)
    (setvar "cecolor" CCOL)
    (setvar "clayer" CL)
    (setvar "textstyle" ESTY)
    (princ "\nError, Try again")
    (setq *error* ORG_ERR)
    (princ)
    )
    ;---------------------------------------------------------------------------
    --------------------------
    ; Main program
    ;---------------------------------------------------------------------------
    --------------------------
    (defun mTXTSTD ()
    (setvar "cmdecho" 0) ;;;command echo off
    (setq CCOL (getvar "cecolor")) ;;;hold current colour
    (setq CL (getvar "clayer")) ;;;hold current layer
    (setq ESTY (getvar "textstyle")) ;;;hold current text style
    (setq ORG_ERR *error*) ;;;holds old error setting
    (setq *error* EXIT_TXTSTD) ;;;Error checking
    (prompt "\n.....Lisp Routine by GHD NZ.....\n")
    ;;;;;;;;;;;;;;;;;;layer checking;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
    (setq LAY (tblsearch "layer" "TEXT")) ;;;checks to see if layer exists
    (if (= LAY nil) (command "layer" "n" "TEXT" "")) ;;;creates layer if
    needed
    (setq FR_CHK (equal (cdr (assoc 70 LAY)) 64)) ;;;checks to see if layer
    is frozen
    (if (= FR_CHK nil) (command "layer" "t" "TEXT" "")) ;;;thaws layer if
    needed
    (if (< (cdr (assoc 62 LAY)) 0) (command "layer" "on" "TEXT" "")) ;;;turns
    layer on if needed
    (setvar "clayer" "TEXT")
    ;;;;;;;;;;;;;;;;;;;text style checking;;;;;;;;;;;;;;;;;;;;;;;;;;;;
    (setq STY (tblsearch "style" "GHD_STANDARD"))
    (if (= STY nil) (command "style" "GHD_STANDARD" "isocp2.shx" "0" "1" "0"
    "n" "n")) ; Creates styles if needed Modified by DBlake Sept 2004
    (setvar "textstyle" "GHD_STANDARD")
    ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
    (setvar "cecolor" TC)
    (princ TXT_MESS)
    (setq TS (getpoint))
    (if (= TR2 nil) (setq TR1 0) (setq TR1 TR2))
    (prompt "\nRotation <")
    (princ TR1)
    (setq TR2 (getangle TS ">:"))
    (if (= TR2 nil) (setq TR2 TR1) (setq TR2 (* TR2 (/ 180 pi))))
    (prompt "\nText:")
    (command "mtext" TS TH TR2)
    (setvar "cecolor" CCOL)
    (setvar "clayer" CL)
    (setvar "textstyle" ESTY)
    (princ)
    )
    ;
    ;
    ;
     
    DB, Sep 27, 2004
    #1
  2. DB

    Kelie Guest

    size: (getvar "textsize")
    color (getvar "cecolor")

    are these what you're looking for?

    regards,
     
    Kelie, Sep 28, 2004
    #2
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.