Author Topic: Search for viewport ...  (Read 5017 times)

0 Members and 3 Guests are viewing this topic.

alanjt

  • Needs a day job
  • Posts: 5352
  • Standby for witty remark...
Re: Search for viewport ...
« Reply #15 on: February 03, 2011, 04:04:12 PM »
Note that the Paperspace Viewport won't be visible, but is inherent to each layout - you can check this by iterating through the collection of objects in the Layout Block Object.
Code: [Select]
(defun c:Test (/)
  (foreach x (layoutlist)
    (print (cons x (sslength (ssget "_X" (list '(0 . "VIEWPORT") (cons 410 x))))))
  )
  (princ)
)
Civil 3D 2019 ~ Windohz 7 64bit
Dropbox

Hangman

  • Swamp Rat
  • Posts: 566
Re: Search for viewport ...
« Reply #16 on: February 03, 2011, 04:15:44 PM »
Note that the Paperspace Viewport won't be visible, but is inherent to each layout - you can check this by iterating through the collection of objects in the Layout Block Object.
Code: [Select]
(defun c:Test (/)
  (foreach x (layoutlist)
    (print (cons x (sslength (ssget "_X" (list '(0 . "VIEWPORT") (cons 410 x))))))
  )
  (princ)
)

Ahhh, ... Understood.  I see what I wasn't seeing.  Interesting.
Hangman  8)

~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
Drafting Board, Mechanical Arm, KOH-I-NOOR 0.7mm
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

alanjt

  • Needs a day job
  • Posts: 5352
  • Standby for witty remark...
Re: Search for viewport ...
« Reply #17 on: February 03, 2011, 04:22:54 PM »
Note that the Paperspace Viewport won't be visible, but is inherent to each layout - you can check this by iterating through the collection of objects in the Layout Block Object.
Code: [Select]
(defun c:Test (/)
  (foreach x (layoutlist)
    (print (cons x (sslength (ssget "_X" (list '(0 . "VIEWPORT") (cons 410 x))))))
  )
  (princ)
)

Interesting.
AKA: Pain in the a$$.
Civil 3D 2019 ~ Windohz 7 64bit
Dropbox

ronjonp

  • Needs a day job
  • Posts: 7533
Re: Search for viewport ...
« Reply #18 on: February 03, 2011, 04:23:10 PM »
Try this as well (mostly CAB's code):

Code: [Select]
(defun getvports (/ a b c lst ss to)
  (if (setq ss (ssget "x" '((0 . "VIEWPORT"))))
    (progn (foreach e (mapcar 'cadr (ssnamex ss))
     (setq a  (cdr (assoc 330 (entget e)))
   b  (cdr (assoc 340 (entget a)))
   c  (cdr (assoc 331 (entget b)))
   to (cdr (assoc 71 (entget b)))
     )
     (or (equal c e) (setq lst (cons (list e to) lst)))
   )
    )
  )
  ;;Sort the list by taborder L 2 R
  (mapcar 'car (vl-sort lst (function (lambda (x y) (< (cadr x) (cadr y))))))
)

(mapcar '(lambda (x) (print (list (cdr (assoc 410 (entget x))) x))) (getvports))

Windows 11 x64 - AutoCAD /C3D 2023

Custom Build PC

alanjt

  • Needs a day job
  • Posts: 5352
  • Standby for witty remark...
Re: Search for viewport ...
« Reply #19 on: February 03, 2011, 04:26:30 PM »
Try this as well (mostly CAB's code):

Code: [Select]
(defun getvports (/ a b c lst ss to)
  (if (setq ss (ssget "x" '((0 . "VIEWPORT"))))
    (progn (foreach e (mapcar 'cadr (ssnamex ss))
     (setq a  (cdr (assoc 330 (entget e)))
   b  (cdr (assoc 340 (entget a)))
   c  (cdr (assoc 331 (entget b)))
   to (cdr (assoc 71 (entget b)))
     )
     (or (equal c e) (setq lst (cons (list e to) lst)))
   )
    )
  )
  ;;Sort the list by taborder L 2 R
  (mapcar 'car (vl-sort lst (function (lambda (x y) (< (cadr x) (cadr y))))))
)

(mapcar '(lambda (x) (print (list (cdr (assoc 410 (entget x))) x))) (getvports))
nice.  :kewl:
Civil 3D 2019 ~ Windohz 7 64bit
Dropbox

ronjonp

  • Needs a day job
  • Posts: 7533
Re: Search for viewport ...
« Reply #20 on: February 03, 2011, 04:32:38 PM »
Try this as well (mostly CAB's code):

Code: [Select]
(defun getvports (/ a b c lst ss to)
  (if (setq ss (ssget "x" '((0 . "VIEWPORT"))))
    (progn (foreach e (mapcar 'cadr (ssnamex ss))
     (setq a  (cdr (assoc 330 (entget e)))
   b  (cdr (assoc 340 (entget a)))
   c  (cdr (assoc 331 (entget b)))
   to (cdr (assoc 71 (entget b)))
     )
     (or (equal c e) (setq lst (cons (list e to) lst)))
   )
    )
  )
  ;;Sort the list by taborder L 2 R
  (mapcar 'car (vl-sort lst (function (lambda (x y) (< (cadr x) (cadr y))))))
)

(mapcar '(lambda (x) (print (list (cdr (assoc 410 (entget x))) x))) (getvports))
nice.  :kewl:
:-) Thanks Alan.

Windows 11 x64 - AutoCAD /C3D 2023

Custom Build PC

Lee Mac

  • Seagull
  • Posts: 12929
  • London, England
Re: Search for viewport ...
« Reply #21 on: February 03, 2011, 04:42:57 PM »
Note that the Paperspace Viewport won't be visible, but is inherent to each layout - you can check this by iterating through the collection of objects in the Layout Block Object.
Code: [Select]
(defun c:Test (/)
  (foreach x (layoutlist)
    (print (cons x (sslength (ssget "_X" (list '(0 . "VIEWPORT") (cons 410 x))))))
  )
  (princ)
)

Interesting.
AKA: Pain in the a$$.

 :-D

Hangman

  • Swamp Rat
  • Posts: 566
Re: Search for viewport ...
« Reply #22 on: February 03, 2011, 04:56:57 PM »
Well, I can see now I definitely went the wrong way with the code I was using.  But I also learned something ... Interesting.   ;)
Thank you guys.
Hangman  8)

~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
Drafting Board, Mechanical Arm, KOH-I-NOOR 0.7mm
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~