Author Topic: Not able to find vla-get-TwistAngle of selected Viewport  (Read 94 times)

0 Members and 1 Guest are viewing this topic.

mailmaverick

  • Bull Frog
  • Posts: 374
Not able to find vla-get-TwistAngle of selected Viewport
« 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.

roy_043

  • Swamp Rat
  • Posts: 1492
  • BricsCAD 16
Re: Not able to find vla-get-TwistAngle of selected Viewport
« Reply #1 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. )
« Last Edit: November 08, 2017, 08:08:03 am by roy_043 »

ronjonp

  • Needs a day job
  • Posts: 6398
Re: Not able to find vla-get-TwistAngle of selected Viewport
« Reply #2 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. )

Windows 10 x64 - AutoCAD /C3D 2018

Custom Build PC

Lee Mac

  • Seagull
  • Posts: 11831
  • AutoCAD 2015 Windows 7 London, England
Re: Not able to find vla-get-TwistAngle of selected Viewport
« Reply #3 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. )

mailmaverick

  • Bull Frog
  • Posts: 374
Re: Not able to find vla-get-TwistAngle of selected Viewport
« Reply #4 on: November 08, 2017, 12:44:24 pm »
Thanks a lot. Problem Solved !!!