How to invert text with entmake?

Discussion in 'AutoCAD' started by Rogerio_Brazil, Nov 29, 2004.

  1. Hello,

    How to invert text with entmake?

    Routine:

    ;texto com entmake
    (defun c:test (/ dist_pt1_pt2)
    (setq pt1 (getpoint "\n First point: "))
    (setq pt2 (getpoint pt1 "\n 2nd point: "))
    (setq fator 1)
    (setq dist_pt1_pt2 (distance pt1 pt2))
    (setq ang (angle pt1 pt2));angle
    (princ "\n Angle: ")(princ ang)(princ "\n")
    (setq PM_pt1_pt2 (mapcar '/ (mapcar '+ Pt1 Pt2) '(2.0 2.0 2.0)))
    (entmake (list (cons 0 "TEXT")
    (cons 1 (rtos dist_pt1_pt2 2 8));;string
    (cons 7 "STANDARD");style
    (cons 10 PM_pt1_pt2)
    (cons 11 PM_pt1_pt2)
    (cons 40 (* 0.2 fator));height
    (cons 50 ang);angle - how to invert?
    (cons 72 1);justif.
    (cons 73 2);justif.
    )
    )
    )
    ;texto com entmake
     
    Rogerio_Brazil, Nov 29, 2004
    #1
  2. Thanks,

    Rogerio
     
    Rogerio_Brazil, Nov 29, 2004
    #2
  3. Rogerio_Brazil

    BillZ Guest

    (cons 71 2) ??

    Bill
     
    BillZ, Nov 29, 2004
    #3
  4. Rogerio_Brazil

    ECCAD Guest

    (setq dist_pt1_pt2 (distance pt1 pt2))
    ;(setq ang (angle pt1 pt2));angle
    (setq ang (angle pt2 pt1));opposite angle

    Invert, using last line. Note angle relative to 1st point.

    Bob
     
    ECCAD, Nov 29, 2004
    #4
  5. To verify my question, try:

    pt1 - left and pt2 - right - text ok

    pt1 - right and pt2 - left = text inverted

    How to invert text angle to make ok the 2 conditions? (bad english, sorry)

    Thanks,

    Rogerio
     
    Rogerio_Brazil, Nov 29, 2004
    #5
  6. In language lisp, aproximated...

    (if (or (= ang 90)(>= ang 270)

    Thanks,

    Rogerio
     
    Rogerio_Brazil, Nov 29, 2004
    #6
  7. Rogerio_Brazil

    ECCAD Guest

    You can check which angle is greater, and use lesser angle.
    Like this:
    ;texto com entmake
    (defun c:test (/ dist_pt1_pt2)
    (setq pt1 (getpoint "\n First point: "))
    (setq pt2 (getpoint pt1 "\n 2nd point: "))
    (setq fator 1)
    (setq dist_pt1_pt2 (distance pt1 pt2))
    (setq ang1 (angle pt1 pt2))
    (setq ang2 (angle pt2 pt1))
    (if (> ang1 ang2)
    (setq ang (angle pt2 pt1))
    (setq ang (angle pt1 pt2))
    ); if
    (princ "\n Angle: ")(princ ang)(princ "\n")
    (setq PM_pt1_pt2 (mapcar '/ (mapcar '+ Pt1 Pt2) '(2.0 2.0 2.0)))
    (entmake (list (cons 0 "TEXT")
    (cons 1 (rtos dist_pt1_pt2 2 8));;string
    (cons 7 "STANDARD");style
    (cons 10 PM_pt1_pt2)
    (cons 11 PM_pt1_pt2)
    (cons 40 (* 0.2 fator));height
    (cons 50 ang);angle - how to invert?
    (cons 72 1);justif.
    (cons 73 2);justif.
    )
    )
    )
    ;texto com entmake

    Cheers:
    :)
    Bob
     
    ECCAD, Nov 29, 2004
    #7
  8. Yessss!!!

    Thank very much!!!!

    Simples, but funcional!!!

    Thanks,

    Rogerio
     
    Rogerio_Brazil, Nov 29, 2004
    #8
  9. Rogerio_Brazil

    Tom Smith Guest

    You can check which angle is greater, and use lesser angle.
    Shouldn't need to calculate the same angle twice. You could simply do:

    (setq ang
    (min
    (angle pt1 pt2)
    (angle pt2 pt1)))

    which to my eye is a lot easier to take in, even if it's formatted on one
    line.
     
    Tom Smith, Nov 29, 2004
    #9
  10. Thanks for solution.

    Test:

    Make a circle. Trace center lines. run the routine.

    A routine work good in quadrants 1 and 3 (text direction ok)

    In quadrants 2 and 4 fail (text direction inverted)

    How to correct to work in 4 quadrants?

    Thanks,

    Rogerio
     
    Rogerio_Brazil, Nov 29, 2004
    #10
  11. Rogerio_Brazil

    Tom Smith Guest

    How to correct to work in 4 quadrants?

    (defun c:test (/ dist_pt1_pt2)
    (setq pt1 (getpoint "\n First point: "))
    (setq pt2 (getpoint pt1 "\n 2nd point: "))
    (setq fator 1)
    (setq dist_pt1_pt2 (distance pt1 pt2))

    (setq ang (rem (angle pt1 pt2) pi)) ;quadrant 1 & 3
    (if (> ang (/ pi 2))
    (setq ang (+ pi ang))) ;quadrant 2 & 4

    (princ "\n Angle: ")(princ ang)(princ "\n")
    (setq PM_pt1_pt2 (mapcar '/ (mapcar '+ Pt1 Pt2) '(2.0 2.0 2.0)))
    (entmake (list (cons 0 "TEXT")
    (cons 1 (rtos dist_pt1_pt2 2 8));;string
    (cons 7 "STANDARD");style
    (cons 10 PM_pt1_pt2)
    (cons 11 PM_pt1_pt2)
    (cons 40 (* 0.2 fator));height
    (cons 50 ang);angle - how to invert?
    (cons 72 1);justif.
    (cons 73 2);justif.
    )
    )
    )
     
    Tom Smith, Nov 29, 2004
    #11
  12. Rogerio_Brazil

    ECCAD Guest

    ;texto com entmake
    (defun c:test (/ dist_pt1_pt2)
    (defun dtr (d) (* pi (/ d 180.0)))
    (defun rtd (r) (* 180.0 (/ r pi)))
    (setq pt1 (getpoint "\n First point: "))
    (setq pt2 (getpoint pt1 "\n 2nd point: "))
    (setq fator 1)
    (setq dist_pt1_pt2 (distance pt1 pt2))
    (setq ang1 (angle pt1 pt2))
    (setq ang2 (angle pt2 pt1))
    (if (> ang1 ang2)
    (setq ang (angle pt2 pt1))
    (setq ang (angle pt1 pt2))
    ); if
    (if (> ang (dtr 90))
    (setq ang (- ang (dtr 90)))
    ); if
    (princ "\n Angle: ")(princ ang)(princ "\n")
    (setq PM_pt1_pt2 (mapcar '/ (mapcar '+ Pt1 Pt2) '(2.0 2.0 2.0)))
    (entmake (list (cons 0 "TEXT")
    (cons 1 (rtos dist_pt1_pt2 2 8));;string
    (cons 7 "STANDARD");style
    (cons 10 PM_pt1_pt2)
    (cons 11 PM_pt1_pt2)
    (cons 40 (* 0.2 fator));height
    (cons 50 ang);angle - how to invert?
    (cons 72 1);justif.
    (cons 73 2);justif.
    )
    )
    )
    ;texto com entmake

    Bob
     
    ECCAD, Nov 29, 2004
    #12
  13. Rogerio_Brazil

    Tom Smith Guest

    Bob, we used the same basic approach, adding a rotation correction, but
    mine's more succinct. Both versions still need to have variables declared
    local.
     
    Tom Smith, Nov 29, 2004
    #13
  14. Rogerio_Brazil

    ECCAD Guest

    Tom,
    Points taken. You are correct. I did the 'long' route, so
    he/she would understand what is going on at each step (rather than use 'min' or 'rem') which are good, but may need further explaination (to a learner). My approach is to 'lead' the poster to draw a conclusion on their own..with simpler - more spread out code.

    He/she is in good hands..:))

    Bob
     
    ECCAD, Nov 29, 2004
    #14
  15. Bob and others,

    Thank very much.

    Rogerio
     
    Rogerio_Brazil, Nov 30, 2004
    #15
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.