Author Topic: Text spcaing from a line  (Read 2137 times)

0 Members and 1 Guest are viewing this topic.

One Shot

  • Guest
Text spcaing from a line
« on: November 02, 2004, 09:49:20 AM »
Is there a routine out there that lets you set the spacing of text from a line?

whdjr

  • Guest
Text spcaing from a line
« Reply #1 on: November 02, 2004, 10:03:36 AM »
Here is one I've had for a loooonnnggg time.  I'm not sure who wrote it, but I modified it a little.  It prompts you to select a piece of text and then starts another line of text below the selected line at the proper distance and the same text size and style.  It's pretty cool.
I hope this helps,
Will
Code: [Select]
(defun *dxf* (gcode elist)
  (cdr (assoc gcode elist))
)
(defun c:CONTXT (/ uecho fht ent ins alignx alignp)
  (setq uecho (getvar "cmdecho"))
  (setvar "cmdecho" 0)
  (and
    (setq ent (entsel "\nLast line of text: "))
    (setq ent (entget (car ent)))
    (= (*dxf* 0 ent) "TEXT")
    (or (/= (*dxf* '72 ent) 3)
(prompt "\nDoesn't work on ALIGNED text.")
    )
    (or (/= (*dxf* '72 ent) 5)
(prompt "\nDoesn't work on FIT text.")
    )
    (progn
      (setq ins (*dxf* 10 ent)
   fht (/= 0.0 (*dxf* 40 (tblsearch "STYLE" (*dxf* 7 ent))))
      )
      (if (/= (*dxf* 8 ent) (getvar "clayer"))
(command ".layer" "s" (*dxf* 8 ent) "")
      )
      (if (or (setq alignx (*dxf* (*dxf* 72 ent) '((1 . "c") (2 . "r") (4 . "m"))))
     (setq alignp (*dxf* (*dxf* 73 ent) '((1 . "b") (2 . "m") (3 . "t"))))
 )
(setq ins (*dxf* 11 ent))
      )
      (if (not alignx)
(setq alignx "l")
      )
      (if alignp
(setq alignx (strcat alignp alignx))
      )
      (command ".text" "s" (*dxf* 7 ent))
      (if (/= alignx "l")
(command alignx)
      )
      (command ins)
      (if (not fht)
(command (*dxf* 40 ent))
      )
      (command (angtos (*dxf* 50 ent)) " ")
      (prompt "\nNew text: ")
      (command ".dtext" "")
    )
  )
  (setvar "cmdecho" uecho)
  (princ)
)

daron

  • Guest
Text spcaing from a line
« Reply #2 on: November 02, 2004, 11:08:35 AM »
Look into polar. You should be able to take the dxf values 10 and 11 of a selected line, place text along that line and move it 90 degrees using polar once again, any distance you choose.

Adesu

  • Guest
Re: Text spcaing from a line
« Reply #3 on: February 14, 2005, 11:28:37 PM »
Quote from: One Shot
Is there a routine out there that lets you set the spacing of text from a line?


Hi One Shot,you can to attempt my script

; stfl is stand for spacing text from line
;        Design by Ade Suharna <mteybid@yuasabattery.co.id>
;        15 February 2005
;        Program no.190/02/2005
;        Edit by
(defun c:stfl (/ opt hit fin tx ssn sse str sp gap tb tb1 tlen
          ln ssln ssle spl epl gapl)  
  (prompt "\nSelect a (T)ext ot (L)ine to move it")
  (initget " T L")
  (setq opt (getkword "\nWHAT DO YOU WANT TO MOVE IT <T or L>; "))
  (setq hit "")
  (if opt (= opt hit)(alert "\nPlease try again,choose one"))
  (setq fin
    (cond
      ((= opt "T")
       (progn
         (prompt "\nCLICK A TEXT")
         (setq tx (ssget '((0 . "TEXT"))))
         (setq ssn (ssname tx 0))
         (setq sse (entget ssn))
         (setq str (cdr (assoc 1 sse)))
         (setq sp (cdr (assoc 10 sse)))
         (setq gap (getdist "\nENTER NEW GAP FROM LINE: "))
         (setq tb (textbox sse))
         (setq tb1 (nth 1 tb))
         (setq tlen (car tb1))
         (setq sp (list (car sp)(+ (cadr sp) gap)(caddr sp)))
         (setq ep (list (+ (car sp) tlen)(cadr sp)(caddr sp)))
         (entmake
      (list
        '(0 . "TEXT")
        '(8 . "0")
        (cons 10 sp)
        '(40 . 2.5)
        (cons 1 str)               ; name of text
        '(50 . 0.0)                ; text rotation
        '(41 . 1.0)                ; with factor
        '(51 . 0.0)                ; oblique angle
        '(7 . "Standard")          ; text style name
        '(71 . 0)                  ; 2 = backward,4 = upside down
        '(72 . 0)                  ; horizontal justification
        '(73 . 0)                  ; vertical justification
        )                          ; end of list
      )                            ; end of entmake
         (command "_erase" tx "")
         )                              ; end of progn
       )
      ((= opt "L")
       (progn
         (prompt "\nCLICK A LINE")
         (setq ln (ssget '((0 . "LINE"))))
         (setq ssln (ssname ln 0))
         (setq ssle (entget ssln))
         (setq spl (cdr (assoc 10 ssle)))
         (setq epl (cdr (assoc 11 ssle)))
         (setq gapl (getdist "\nENTER NEW GAP FROM TEXT: "))
         (setq spl (list (car spl)(- (cadr spl) gapl)(caddr spl)))
         (setq epl (list (car epl)(cadr spl)(caddr epl)))
         (entmake
      (list
        '(0 . "LINE")
        '(8 . "0")
        (cons 10 spl)
        (cons 11 epl)
        )                             ; end of list
      )                               ; end of entmake
         (command "_erase" ln "")
         )                                 ;end of progn
       )
      )                                    ; end of cond
   )                                       ; end of setq  
  (princ)
  )