TheSwamp

Code Red => AutoLISP (Vanilla / Visual) => Topic started by: mailmaverick on November 08, 2017, 07:39:06 AM

Title: Not able to find vla-get-TwistAngle of selected Viewport
Post by: mailmaverick on November 08, 2017, 07:39:06 AM
Hi

I have a Viewport which is rotated and I want to find its angle of rotation. When I run the command :

(setq ang (vla-get-TwistAngle (vlax-ename->vla-object (car (entsel)))))

it gives error. Please help.
Title: Re: Not able to find vla-get-TwistAngle of selected Viewport
Post by: roy_043 on November 08, 2017, 08:00:45 AM
Check if the entity is the VP and not the clipping boundary entity belonging to the VP.
Code - Auto/Visual Lisp: [Select]
  1. (setq elist (entget ename))
  2.   (= "VIEWPORT" (cdr (assoc 0 elist)))
  3.   (and
  4.     (setq ename (cdadr (member '(102 . "{ACAD_REACTORS") elist)))
  5.     (setq elist (entget ename))
  6.     (= "VIEWPORT" (cdr (assoc 0 elist)))
  7.   )
  8.   (prompt "\nError: not a viewport ")
  9. )
Title: Re: Not able to find vla-get-TwistAngle of selected Viewport
Post by: ronjonp on November 08, 2017, 09:09:36 AM
Another to return the ename:
Code - Auto/Visual Lisp: [Select]
  1. (defun _getvport (e)
  2.   (if (= 'ename (type e))
  3.     (cond ((= "VIEWPORT" (cdr (assoc 0 (entget e)))) e)
  4.           ((and (setq e (cdr (assoc 330 (entget e)))) (= "VIEWPORT" (cdr (assoc 0 (entget e))))) e)
  5.     )
  6.   )
  7. )
  8. ;; Usage
  9. (if (setq e (_getvport (car (entsel))))
  10.   (setq a (cdr (assoc 51 (entget e))))
  11. )
Title: Re: Not able to find vla-get-TwistAngle of selected Viewport
Post by: Lee Mac on November 08, 2017, 12:37:34 PM
And another:
Code - Auto/Visual Lisp: [Select]
  1. (defun c:test ( / sel )
  2.     (if (setq sel (ssget "_+.:E:S" '((0 . "VIEWPORT"))))
  3.         (cdr (assoc 51 (entget (ssname sel 0))))
  4.     )
  5. )
Title: Re: Not able to find vla-get-TwistAngle of selected Viewport
Post by: mailmaverick on November 08, 2017, 12:44:24 PM
Thanks a lot. Problem Solved !!!