Visual LISP, AutoLISP and General Customization
cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 

Object Rotation Angle Variable

4 REPLIES 4
Reply
Message 1 of 5
Anonymous
375 Views, 4 Replies

Object Rotation Angle Variable

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.
4 REPLIES 4
Message 2 of 5
Anonymous
in reply to: Anonymous

;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 Member of the Autodesk Discussion Forum Moderator Program "haojan" wrote in message news:11127872.1077671631911.JavaMail.jive@jiveforum1.autodesk.com... > 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.
Message 3 of 5
Anonymous
in reply to: Anonymous

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.
Message 4 of 5
Anonymous
in reply to: Anonymous

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 "haojan" wrote in message news:17808646.1077743175142.JavaMail.jive@jiveforum2.autodesk.com... > 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.
Message 5 of 5
Anonymous
in reply to: Anonymous

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

notice the \ rather than /

Bob

Can't find what you're looking for? Ask the community or share your knowledge.

Post to forums  

Autodesk Design & Make Report

”Boost