Center align text

Center align text

etilley327KA
Advocate Advocate
630 Views
6 Replies
Message 1 of 7

Center align text

etilley327KA
Advocate
Advocate

Im trying to place my text centered at the angle of the line. Is it possible to use 72 or 73 to center it? Or perhaps some other way? Currently with the 72 or 73 the text doesnt appear.

 

(defun c:TEST (/ pnt1 BD D DD DD2 QD DG MN MN2 SEC BEARING BRGDIS lastline linedata startPoint endPoint cont objl size1 size2 zoomScale label centerPoint 1x 1y labeltxtpnt labelrot)
  (setq pnt1 (getpoint "\nPick point: "))
  (setq cont t)

  (while cont
    (setq BD (getstring "\nBearing (Qddmmss): "))
    (if (not (equal BD ""))
      (progn
        (setq D (getstring "\nEnter distance: "))
        (setq DD2 (strcat D "'"))
        (setq DD (strcat "@" D))
        (setq QD (substr BD 1 1))
        (setq DG (substr BD 2 2))
        (setq MN (strcat "d" (substr BD 4 2) "'"))
        (setq MN2 (strcat "°" (substr BD 4 2) "'"))
        (setq SEC (substr BD 6 2))

        (cond
          ((= QD "1") (setq QD (strcat "N")) (setq SEC (strcat SEC "\"E")))
          ((= QD "2") (setq QD (strcat "S")) (setq SEC (strcat SEC "\"E")))
          ((= QD "3") (setq QD (strcat "S")) (setq SEC (strcat SEC "\"W")))
          ((= QD "4") (setq QD (strcat "N")) (setq SEC (strcat SEC "\"W")))
        )
        (setq QD1 (strcat "<" QD))
        (setq BEARING (strcat QD1 DG MN SEC))
        (setq BRGDIS (strcat DD BEARING))
        (setq label (strcat QD DG MN2 SEC "  " DD2))
        (command "_line" pnt1 BRGDIS "" "");@123<S12d34'56"E
        (setq lastline (entlast))
        (setq size1 5)
        (setq linedata (entget lastline))
        (setq startPoint (cdr (assoc 10 linedata)))
        (setq endPoint (cdr (assoc 11 linedata)))
        (setq centerPoint (polar startPoint (angle startPoint endPoint) (/ (distance startPoint endPoint) 2.0)))
        (setq labelRotation (angle startPoint endPoint))
        (setq offsetDistance 1.0)
        (setq offsetVector (polar centerPoint (+ labelRotation (/ pi 2)) offsetDistance))
        (setq objl (distance startPoint endPoint))
        (setq textScaleFactor (/ objl 100.0))
        (setq textSize (* size1 textScaleFactor))
        (setq textEntity (entmake
                          (list
                            '(0 . "TEXT")
                            (cons 8 "BDLABEL")
                            (cons 10 offsetVector)
                            (cons 40 textSize)
                            (cons 50 labelRotation)
                            (cons 1 label)
                            (cons 72 2)
                            (cons 73 2)
                          )
                        )
        )
        (setq size 2.5)
        (setq zoomScale (/ size objl))
            ;-----ZOOMS------
            (command "_.zoom" "O" lastline "")
            (command "_.zoom" "W" startPoint endPoint "")
            (command "_.zoom" "S" zoomScale "")
        (setq pnt1 endPoint)
      )
      (setq cont nil)
    )
  )
)
0 Likes
Accepted solutions (1)
631 Views
6 Replies
Replies (6)
Message 2 of 7

Moshe-A
Mentor
Mentor

@etilley327KA ,

 

may i give you an advice?

 

i think using (entmake) is advanced code level (because all it's dxf codes mysterious)

instead why don't you use (command "text") call. it's more simple easy to accomplish - don't you thinks so?!

 

for (entmake) dxf code 11 is to be used to center text that is not start point justified.

 

so solve the problem with (command) first then if you still not satisfied, go to (entmake)

 

Moshe

 

 

 

 

 

0 Likes
Message 3 of 7

etilley327KA
Advocate
Advocate

Yeah I tried that route first and could not figure out how to align it to the angle. This is the umpteenth way ive tried and it came the closest. Guess I can go back and try again with the command. Thanks

0 Likes
Message 4 of 7

Kent1Cooper
Consultant
Consultant
Accepted solution

Try adding

  (cons 11 centerPoint)

to your (entmake) list.

Kent Cooper, AIA
0 Likes
Message 5 of 7

paullimapa
Mentor
Mentor

also for center justification:

                            (cons 72 1)
                            (cons 73 0)

Paul Li
IT Specialist
@The Office
Apps & Publications | Video Demos
Message 6 of 7

etilley327KA
Advocate
Advocate
Thanks so much.
0 Likes
Message 7 of 7

Sea-Haven
Mentor
Mentor

If your only doing a few like Moshe-A, it will be fast enough. Need also setvar for layer.

 

(command "text" "J" "MC" pt ht rot str)

 

 

0 Likes