View Family Types selection

You need to to check the ViewType, not the ElementType.

#Sean Page, 2022
import clr

clr.AddReference('RevitAPI')
from Autodesk.Revit.DB import *
from Autodesk.Revit.DB.Structure import *

clr.AddReference('RevitAPIUI')
from Autodesk.Revit.UI import *

clr.AddReference('System')
from System.Collections.Generic import List

clr.AddReference('RevitNodes')
import Revit
clr.ImportExtensions(Revit.GeometryConversion)
clr.ImportExtensions(Revit.Elements)

clr.AddReference('RevitServices')
import RevitServices
from RevitServices.Persistence import DocumentManager
from RevitServices.Transactions import TransactionManager

doc = DocumentManager.Instance.CurrentDBDocument
uidoc=DocumentManager.Instance.CurrentUIApplication.ActiveUIDocument

#Preparing input from dynamo to revit
element = UnwrapElement(IN[0])
type = IN[1]
results = []
other = []
#Do some action in a Transaction
TransactionManager.Instance.EnsureInTransaction(doc)
views = FilteredElementCollector(doc).OfCategory(BuiltInCategory.OST_Views).ToElements()

for v in views:
	if not v.IsTemplate:
		if v.ViewType.ToString() == type:
			results.append(v)
		else:
			other.append(v)

TransactionManager.Instance.TransactionTaskDone()

OUT = results, other

Thanks for the reply.
Still having the issue.

Are the additional views synchronized / saved to the background document? If they are in the active document, then they should also be there if it is opened in the background as long as the models are the same there should be no different between them.

Hi @SeanP great code thanks, it works with an input list (I modified a bit to work also with one element) I have only one question, why you are using the TransactionManager ?
Thanks in advance, cheers

1 Like

There is no need in this case. That is just part of my boilerplate python node. Plus typically I’ll end up doing something that needs a transaction.

1 Like