Suits needs I have of my own right now, so thought I'd share (first pass, so let me know if you find errors):
(defun SSGetFloatingViewports ( )
;; note, returns all floating viewports,
;; including viewports that are not on
(ssget "x"
(list
'(0 . "viewport")
(cons 410
(strcat
(car (setq lst (layoutlist)))
(apply 'strcat
(mapcar
'(lambda (x) (strcat "," x))
(cdr lst)
)
)
)
)
'(-4 . "!=")
'(69 . 1) ;; paperspace = 1, we don't want it
)
)
)
(defun SSGetFloatingViewportBoundaries ( / ss i pair result )
;; create selection set of objects which
;; are boundaries for floating viewports
(cond
(
(and
(setq ss (SSGetFloatingViewports))
(setq result (ssadd))
)
(repeat (setq i (sslength ss))
(if
(setq pair
(assoc 340
(entget
(ssname ss (setq i (1- i)))
)
)
)
(ssadd (cdr pair) result)
)
)
(if (< 0 (sslength result)) result)
)
)
)
Edit: Renamed functions.