Annoying, you don’t have to use iselection, unfortunately not as satisfactory… but still does a job…
#credit to the forum for code
import clr
import sys
import System
clr.AddReference('RevitAPI')
import Autodesk
from Autodesk.Revit.DB import *
import Autodesk.Revit.DB as DB
clr.AddReference('RevitAPIUI')
from Autodesk.Revit.UI import *
from Autodesk.Revit.UI.Selection import *
from System.Collections.Generic import List
from RevitServices.Persistence import DocumentManager
doc = DocumentManager.Instance.CurrentDBDocument
uidoc=DocumentManager.Instance.CurrentUIApplication.ActiveUIDocument
pboxS=Autodesk.Revit.UI.Selection.PickBoxStyle.Enclosing
pickedBox = uidoc.Selection.PickObjects(ObjectType.Element, "Select viewports")
for element in pickedBox:
e_id = element.ElementId
a=doc.GetElement(e_id)
#if element category is viewport, do stuff with them....
#report elements which weren't viewports?
OUT=a