Text Rotaion Value

Discussion in 'AutoCAD' started by Aaron Cunningham, Jun 15, 2004.

  1. Where does the text rotation angle get stored. Is it in a drawing variable?
     
    Aaron Cunningham, Jun 15, 2004
    #1
  2. Aaron Cunningham

    marcin dobek Guest

    Not in the drawing variable

    check dxf code no 50 in text

    (/ (* 180 (cdr(assoc 50 (entget (car(entsel)))))) pi) in degrees
    (cdr(assoc 50 (entget (car(entsel))))) in radian


    variable?
     
    marcin dobek, Jun 15, 2004
    #2
  3. Thanks for the info.

    Here is my problem. We have a lisp routine written in house that will let you insert text on a line and then break the line around the text. For some reason when this text is inserted it doesn't always come in at a straight angle. I'm getting something like 357d34'4" and I would like to reset the text rotation angle to 0 because it is getting set to the 357d34'4". I have attached the lisp routine below if someone has a suggestion to change it so the text does come in at a straight angle. I don't know enough about writing lisp routines to figure out why this isn't inserting the text at a straight angle.

    ; **BLKINLIN**
    ;
    ; To break a line and insert a block. Blk1 has not
    ; been defined. define as in a menu pick.(setq blk1 "Put block here")
    ;
    ; Pick line at the location you would like the text to be centered.
    ; If text is not at the location you would like, use the
    ; stretch command to move it.
    ;
    ; The width of the space can be changed by changing
    ; the 2nd line of the lisp. texinlin uses useri1 to get the
    ; dimscale of the drawing.
    ;
    ; By Lyn J. Neuhaus
    ; 1/16/91
    ; Updated 12/17/91 took out "var1"
    ;
    ;** Space must be defined before starting.
    ;** Blk must be defined before starting.
    ;** Var1 must be defined by (blkscl) or by setq before running program.
    ;
    (defun blkinlin ()
    (setq space (* space (getvar "dimscale"))) ;Space times dimscale
    (setq dis1 space) ;Total length to break out.
    (setq dis2 (/ dis1 2)) ;Divide distance by two

    ;Get point 1 (pt1)

    (setq oldosnap (getvar "osmode"))
    (setvar "osmode" 0)

    (setq pt (entsel "Pick Point On Line "))

    (setq pt1 (cadr pt))
    (setq pt1 (osnap pt1 "near"))
    ;Find angle

    (setq pt2 (osnap pt1 "endp"))
    (setq ang1 (angle pt2 pt1 ))
    (setq ang2 (+ pi ang1))
    (setq ang3 (rtd ang1))
    (setq a (and (> ang3 90) (<= ang3 270)))
    (setq ang4 (if (= a T)(+ ang3 180)(setq ang4 ang3)))

    ;Get points (pt3,pt4)

    (setq pt3 (polar pt1 ang1 dis2))
    (setq pt4 (polar pt3 ang2 dis1))

    ;Break line then insert block

    (command "BREAK" pt "F" pt3 pt4 "insert" blk "s" var1 pt1 ang4 )
    (setvar "osmode" oldosnap)

    )
     
    Aaron Cunningham, Jun 15, 2004
    #3
  4. Aaron:

    I assume from the way this is written that by a "straight angle" for the
    text (really a block that I assume consists of a piece of text), you mean
    not 0 degrees, but aligned with the line you pick.

    I don't find "rtd" in the AutoLisp reference, but I'm guessing it's another
    defined routine for "radians to degrees."

    What looks like the most likely problem to me: I don't think I've ever seen
    an (if) item used as a "value" to set in a (setq) statement. Usually (setq)
    statements are inside (if) statements, not the other way around. I'm not
    positive it wouldn't work your way, or whether it's causing any part of your
    problem, but I would have built it differently. I'd replace your

    (setq a (and (> ang3 90) (<= ang3 270)))
    (setq ang4 (if (= a T) (+ ang3 180) (setq ang4 ang3)))

    with:

    (if (and (> ang3 90) (<= ang3 270))
    (setq ang4 (+ ang3 180)) (setq ang4 ang3))

    so you don't need the "a" variable at all.

    But even if your syntax works, you shouldn't have the "setq ang4" in that
    line twice, because if ang3 is not between 90 & 270, it would try to set the
    value of ang4 to the overall (setq ang4 ang3), instead of to ang3. I'm not
    sure what that might mean later as a response to the rotation angle prompt
    for the insertion of the block. It should be:

    (setq ang4 (if (= a T) (+ ang3 180) ang3))

    Unrelated to your stated problem, there are some things that could be
    simplified. You should be able to replace your

    (setq pt (entsel "Pick Point On Line "))
    (setq pt1 (cadr pt))
    (setq pt1 (osnap pt1 "near"))

    with just:

    (setq pt1 (osnap (getpoint "Pick Point on Line ") "nea"))

    And you don't need to pick the line as a saved entity again for Breaking,
    then give it the F option, since you already have two points on it defined.
    You could replace your

    (command "BREAK" pt "F" pt3 pt4....

    with:

    (command "BREAK" pt3 pt4....

    so with both the two last adjustments, you don't need the "pt" variable at
    all.

    Hope that helps,
    Kent Cooper, AIA


    you insert text on a line and then break the line around the text. For some
    reason when this text is inserted it doesn't always come in at a straight
    angle. I'm getting something like 357d34'4" and I would like to reset the
    text rotation angle to 0 because it is getting set to the 357d34'4". I have
    attached the lisp routine below if someone has a suggestion to change it so
    the text does come in at a straight angle. I don't know enough about writing
    lisp routines to figure out why this isn't inserting the text at a straight
    angle.
     
    Kent Cooper, AIA, Jun 16, 2004
    #4
  5. Thanks for the information. When I get some time I will try and clean up the routine. I will post back with my findings.
     
    Aaron Cunningham, Jun 16, 2004
    #5
  6. Aaron Cunningham

    ECCAD Guest

    Couple of observations.
    Variable Var1 is not set, probably should be:
    (setq Var1 (getvar "dimscale"))
    Variable blk ? (is that a blank 'text' block ?), if so, should be
    on a support path or called explicitly with drive/path/blk.
    Missing function rtd, dtr
    (defun dtr (d) (* pi (/ d 180.0))); degrees to radians
    (defun rtd (r) (* 180.0 (/ r pi))); redians to degrees
    Add both functions.

    Bob
     
    ECCAD, Jun 16, 2004
    #6
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.