Hey Yall,
I am currently working on a script that allows for the user to select the sheet and specific viewport that they want applied to all the sections on the sheet. I have been searching for a way to collect all the viewports that are listed in my project template. However whenever I use Categories->Viewports->All Elements of Category, it only shows up active viewports in the project. I would like to be able to pull from a viewport that is already loaded into the project just not on a sheet, but I can’t seem to find any node that satisfies this. I can really use any help I can get here
Hello welcome ;)) guess you are after all viewport types in document, if that the case you can try something here
import clr
clr.AddReference('RevitAPI')
from Autodesk.Revit.DB import *
from Autodesk.Revit.UI import *
clr.AddReference('RevitServices')
from RevitServices.Persistence import DocumentManager
doc = DocumentManager.Instance.CurrentDBDocument
viewportTypes_all = FilteredElementCollector(doc).OfClass(ElementType).ToElements()
viewportTypes_all = [e for e in viewportTypes_all if e.FamilyName == "Viewport"]
OUT = viewportTypes_all
In later revit versions there should be a sheet.viewports node that ships with dynamo.
Many alternative ways to solve this, OOTB, archilab, Crumple and Python (full API solution)
Note: The OOTB version will have warnings due to non-convertible types for the Family Name
import clr
clr.AddReference("RevitServices")
from RevitServices.Persistence import DocumentManager
clr.AddReference("RevitAPI")
from Autodesk.Revit.DB import *
doc = DocumentManager.Instance.CurrentDBDocument
bip = ElementId(BuiltInParameter.SYMBOL_FAMILY_NAME_PARAM)
pfrf = ParameterFilterRuleFactory.CreateEqualsRule(bip, "Viewport")
epf = ElementParameterFilter(pfrf)
OUT = FilteredElementCollector(doc).OfClass(ElementType).WherePasses(epf).ToElements()
yeah great many ways
and if we already know the names for that in project or template, and guess we can find many other ways in many packages
Another way (multilanguage).
import clr
import sys
import System
clr.AddReference('RevitAPI')
import Autodesk
from Autodesk.Revit.DB import *
import Autodesk.Revit.DB as DB
clr.AddReference('RevitServices')
import RevitServices
from RevitServices.Persistence import DocumentManager
from RevitServices.Transactions import TransactionManager
doc = DocumentManager.Instance.CurrentDBDocument
clr.AddReference("System.Core")
clr.ImportExtensions(System.Linq)
all_viewport_types = (
FilteredElementCollector(doc)
.WhereElementIsElementType()
.Where(System.Func[DB.Element, System.Boolean](
lambda x: x.get_Parameter(BuiltInParameter.VIEWPORT_ATTR_SHOW_LABEL) is not None
))
.ToList()
)
OUT = all_viewport_types