Object Rotation Angle Variable

Discussion in 'AutoCAD' started by haojan, Feb 25, 2004.

  1. haojan

    haojan Guest

    I'm trying to set a variable in my lisp to the rotation angle (that is shown
    when I list an object) of the object just by selecting it.
    Please let me know how I can incorporate that into my lisp. Thank You.
     
    haojan, Feb 25, 2004
    #1
  2. ;converts radians to degrees
    (defun rtd (r) (* 180.0 (/ r pi)))


    (setq obj (car (entsel "\nselect object: ")))

    ; vanilla lisp
    (rtd (cdr (assoc 50 (entget obj))))


    ; active x
    (setq obj (vlax-ename->vla-object obj))

    (rtd (vlax-get obj 'rotation))

    or

    (rtd (vla-get-rotation obj))
     
    Jason Piercey, Feb 25, 2004
    #2
  3. haojan

    haojan Guest

    Thanx Jason but I get some error

    For
    (defun c:robj ()
    (setq obj (car (entsel "\nselect object: ")))
    (setq obj (vlax-ename->vla-object obj))
    (setvar objang ((rtd (vlax-get obj 'rotation))))
    (princ "/n")
    (princ objang)
    )
    I get
    select object: ; error: bad function: 145.152

    For
    (defun c:robj ()
    (setq obj (car (entsel "\nselect object: ")))
    (setvar objang (rtd (cdr (assoc 50 (entget obj)))))
    (princ "/n")
    (princ objang)
    )
    I get
    select object: ; error: bad argument type: (or stringp symbolp): nil

    Also this rotation seems to be based on the WCS. I was actually looking more for the rotation based on the UCS.

    I am trying to rotate the objects (typically lines of DText) in one simple step to 0 based on the UCS. Hope you can help. Thank You.
     
    haojan, Feb 25, 2004
    #3
  4. Try using SETQ rather than SETVAR
    and drop the extra set of ( ).

    (setq objang (rtd (vlax-get obj 'rotation)))

    For the UCS part, have a look at the TRANS function.

    --

    -Jason
    Member of the Autodesk Discussion Forum Moderator Program


    based on the UCS. Hope you can help. Thank You.
     
    Jason Piercey, Feb 25, 2004
    #4
  5. haojan

    ECCAD Guest

    Replace:
    (princ "/n")
    with:
    (print "\n")

    notice the \ rather than /

    Bob
     
    ECCAD, Feb 25, 2004
    #5
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.