Custom Dtext Solved...

Discussion in 'AutoCAD' started by akdrafter, Mar 2, 2004.

  1. akdrafter

    akdrafter Guest

    Hello All,

    Well, this is not what I really wanted to do, but it works. I had to use the Mtext command to get the true bottom left justification and then I simiply exploded the mtext entity after all of the text was entered which converted the mtext to plain text. Would have been nice to be able to see the text created while typing it....dynamically. Code below.

    "Catch" Ya Later,
    AKDRAFTER

    ;; TBL2.lsp
    ;;
    ;; By Timothy J. Jaronik Sr.
    ;; March, 2004
    ;;
    ;; A routine to create Dtext with a justification of bottom left and moved 3/16" to the east (0 angle) of the user picked point
    ;;
    ;;;;;;;;;;;;;;;BEGIN ERROR HANDLING FUNCTION;;;;;;;;;;;;;;;
    ;;
    (defun ERRTRAP (msg)
    (princ "\n Error: ")
    (if msg (princ msg))
    (setvar "CLAYER" CLA)
    (setvar "CMDECHO" CME)
    (setvar "OSMODE" OSM)
    (setvar "ORTHOMODE" OTHM)
    (setvar "SNAPMODE" SNM)
    (setvar "TEXTSTYLE" TSTYLE)
    (setq *ERROR* OLDERR)
    (prompt "\n Resetting System Variables... ")
    (princ)
    )
    ;;
    ;;;;;;;;;;;;;;;END ERROR HANDLING FUNCTION;;;;;;;;;;;;;;;
    ;;
    ;;;;;;;;;;;;;;;BEGIN DTR FUNCTION;;;;;;;;;;;;;;;
    ;;
    (defun DTR (a)
    (* PI (/ a 180.0))
    )
    ;;
    ;;;;;;;;;;;;;;;END DTR FUNCTION;;;;;;;;;;;;;;;
    ;;
    ;;
    (defun C:TBL2 ( / OLDERR *ERROR* CLA CME OSM OTHM SNM TSTYLE DIMSC TXTSZ TXTH TXTEVAL SP0 SP1 EL)
    (setq OLDERR *ERROR*)
    (setq *ERROR* ERRTRAP)
    (setq CLA(getvar "CLAYER"))
    (setq CME(getvar "CMDECHO"))
    (setvar "CMDECHO" 0)
    (setq OSM(getvar "OSMODE"))
    (setvar "OSMODE" 0)
    (setq OTHM(getvar "ORTHOMODE"))
    (setvar "ORTHOMODE" 0)
    (setq SNM(getvar "SNAPMODE"))
    (setvar "SNAPMODE" 0)
    (setq TSTYLE(getvar "TEXTSTYLE"))
    (setq DIMSC(getvar "DIMSCALE"))
    (setq TXTSZ(getvar "TEXTSIZE"))
    (setq TXTH(setvar "TEXTSIZE"(* DIMSC 0.09375000)))
    (setq TXTEVAL(getvar "TEXTEVAL"))
    (setvar "TEXTEVAL" 1)
    (command "-layer" "thaw" "TEXT" "on" "TEXT" "make" "TEXT" "color" "4" "TEXT" "lt" "continuous" "TEXT" "")
    (command "-style" "ROMANS" "ROMANS.shx" "0.00000000" "1.00000000" "0.00000000" "N" "N" "N")
    (setq SP0(getpoint "\n Pick the BOTTOM LEFT point: "))
    (setq SP1(polar SP0 (DTR 0.0) (* DIMSC 0.18750000)))
    (command "_mtext" SP1 "_J" "_BL" "S" "ROMANS" "H" TXTH "W" "0.0")
    (princ "\nEnter Text: ")
    (while (= (logand (getvar "cmdactive") 1) 1)
    (command pause)
    (princ "\nEnter Text: ")
    )
    (setq EL(entlast))
    (command "explode" EL)
    (setq *ERROR* OLDERR)
    (setvar "CLAYER" CLA)
    (setvar "CMDECHO" CME)
    (setvar "OSMODE" OSM)
    (setvar "ORTHOMODE" OTHM)
    (setvar "SNAPMODE" SNM)
    (setvar "TEXTSTYLE" TSTYLE)
    (setvar "TEXTSIZE" TXTSZ)
    (setvar "TEXTEVAL" TXTEVAL)
    (princ)
    )
     
    akdrafter, Mar 2, 2004
    #1
  2. akdrafter

    Joe Burke Guest

    Timothy,

    Kinda funky, but might be of interest.
    Joe Burke

    ;; 3/1/2004
    (defun c:LLText ( / *Error* ent ss dist osm p1 p2 )
    (defun *Error* (Msg)
    (cond
    ((or (not Msg)
    (member Msg '("console break"
    "Function cancelled"
    "quit / exit abort"))))
    ((princ (strcat "\nError: " Msg)))
    )
    (setvar "osmode" osm)
    (princ)
    ) ;end

    (setq ent (entlast))
    (setq ss (ssadd))
    (setq dist (* 1.62 (getvar "textsize")))
    (setq osm (getvar "osmode"))
    (setvar "osmode" 0)
    (setq p1 (getpoint "Pick lower left insertion point: "))
    (setq p2 (polar p1 (* pi 0.5) dist))
    (command "dtext" p1 "" "")
    (while (setq ent (entnext ent))
    (ssadd ent ss)
    (command "move" ss "" p1 p2)
    (command "dtext" p1 "" "")
    )
    (command "move" ss "" p2 p1)
    ;; another move here to offset 3/16"
    (*Error* nil)
    (princ)
    ) ;end

    ;; example: <enter> <enter> after each line of text
    Command: LLText
    Pick lower left insertion point:
    Enter text: TESTING PROGRAM <enter>
    Enter text: <enter>
    Enter text: WORKING OK? <enter>
    Enter text: <enter>
    Enter text: <enter> null text ends program
    Command:
     
    Joe Burke, Mar 2, 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.