Author Topic: Text above lines  (Read 1889 times)

0 Members and 1 Guest are viewing this topic.

antistar

  • Guest
Text above lines
« on: June 09, 2011, 09:17:31 AM »
Hi teachers. I need help.
How to write two standard texts (TEXT1 TEXT2) above multiple lines, observing the direction of these lines?

Thanks in advance.

Lee Mac

  • Seagull
  • Posts: 12929
  • London, England
Re: Text above lines
« Reply #1 on: June 09, 2011, 09:25:02 AM »
Would this help?

antistar

  • Guest
Re: Text above lines
« Reply #2 on: June 09, 2011, 09:40:33 AM »
Hi Lee, thanks for your attention.
His routine is amazing and now I apply in my works.
However, I need something more specific: Selecting multiple lines at once and draw two standard texts above them.

Lee Mac

  • Seagull
  • Posts: 12929
  • London, England
Re: Text above lines
« Reply #3 on: June 09, 2011, 09:49:17 AM »

CAB

  • Global Moderator
  • Seagull
  • Posts: 10401
Re: Text above lines
« Reply #4 on: June 09, 2011, 10:14:56 AM »
 :-) Very funny.

Time to learn LISP. 8-)
I've reached the age where the happy hour is a nap. (°¿°)
Windows 10 core i7 4790k 4Ghz 32GB GTX 970
Please support this web site.

fixo

  • Guest
Re: Text above lines
« Reply #5 on: June 10, 2011, 05:27:33 AM »
Hi teachers. I need help.
How to write two standard texts (TEXT1 TEXT2) above multiple lines, observing the direction of these lines?

Thanks in advance.

Try this instead
Code: [Select]

(defun C:TAL(/ ang bounds elist ent endpt txtgap txtheight1 txtheight2 linelayer startpt selset temppt txtstyle1 txtstyle2
      txtpoint1 txtpoint2 txtstring1 txtstring2 txtlayer1 txtlayer2 txtlength)
 
(setq txtheight1 25.;<-- big text height
      txtheight2 15.;<-- small text height
      txtgap (/ txtheight2 2.);<-- gap between line and text
      txtstring1 "TEXT1";<-- big text string
      txtstring2 "TEXT2";<-- small text string
      linelayer "SCO-___-VIG";<-- lines layer
      txtlayer1 "SCO-___-PIL-___-IDE";<-- big text layer
      txtlayer2 "SCO-___-PIL-___-DIM";<-- small text layer
      txtstyle1 "R100";<--big text style
      txtstyle2 "R60";<-- small text style
      )
 
(if
(setq selset (ssget (list (cons 0 "line")
  (cons 8 linelayer)))
      )
(while (setq ent (ssname selset 0))
  (setq elist (entget ent)
startpt (cdr (assoc 10 elist))
endpt (cdr (assoc 11 elist))
ang (angle startpt endpt))
(if (or (equal ang (* pi 1.5) 1e-08)(< (/ pi 2) ang (* pi 1.5))) (setq ang (+ ang pi))
  )
  ;;;swap points after the reverse angle
  (if (> (abs (- (angle startpt endpt) ang)) 1e-08)
    (progn
    (setq temppt startpt
startpt endpt
  endpt temppt))
    )


  (setq txtpoint1 (polar startpt (+ ang (/ pi 2)) txtgap)
txtpoint2 (polar endpt (+ ang (/ pi 2)) txtgap))
 
 (entmake (list
    '(0 . "TEXT")
    '(100 . "AcDbEntity")
    (cons 8 txtlayer1)
    '(100 . "AcDbText")
    (cons 10 txtpoint1)
    (cons 40 txtheight1)
    (cons 1 txtstring1)
    (cons 50 ang)
    (cons 41 1.)
    (cons 51 0.)
    (cons 7 txtstyle1)
    (cons 71 0)
    (cons 72 0)
    (cons 11 (list 0. 0. 0.))
    '(100 . "AcDbText")
    (cons 73 0)))


(setq bounds (textbox (list (cons 1 txtstring2)(cons 40 txtheight2)))
      )
 (setq txtlength (abs (apply '- (mapcar 'car bounds)))
       )
 
(entmake
  (list '(0 . "TEXT")
'(100 . "AcDbEntity")
(cons 8 txtlayer2)
'(100 . "AcDbText")
(cons 10
      (polar txtpoint2 (+ ang pi) txtlength));<-- calc right alignment point
(cons 40 txtheight2)
(cons 1 txtstring2)
(cons 50 ang)
(cons 41 1.)
(cons 51 0.)
(cons 7 txtstyle2)
(cons 71 0)
(cons 72 2)
(cons 11 txtpoint2)
'(100 . "AcDbText")
(cons 73 0)))
(ssdel ent selset)
  )
)
(princ)
)
(princ "\n\t\t***\tStart command with TAL to execute\t***")
(prin1)

antistar

  • Guest
Re: Text above lines
« Reply #6 on: June 10, 2011, 09:56:49 AM »
Fixo,
I have no words to thank you.
His routine will be very helpful to me.

Have a nice day.  :-)

fixo

  • Guest
Re: Text above lines
« Reply #7 on: June 10, 2011, 10:42:35 AM »
You're welcome
Glad to hear it
Cheers :)