Trying to collect all viewtemplates of active document but keep getting errors.
I’ve looked in RevitAPI 2023 but can’t se anything wrong on “IsTemplate”.
Dynamo version 2.16
from Autodesk.Revit.DB import *
import RevitServices
from RevitServices.Persistence import DocumentManager
doc = DocumentManager.Instance.CurrentDBDocument
All_views = FilteredElementCollector(doc).OfClass(View).ToElements()
viewTemplates = []
for view in All_views:
if view.**IsTemplate** and view.ViewType != ViewType.ThreeD:
viewTemplates.append(view)
OUT = viewTemplates
@BIM_Mrbrango This code will work if you remove the asterisks
from Autodesk.Revit.DB import *
import RevitServices
from RevitServices.Persistence import DocumentManager
doc = DocumentManager.Instance.CurrentDBDocument
All_views = FilteredElementCollector(doc).OfClass(View).ToElements()
viewTemplates = []
for view in All_views:
if view.IsTemplate and view.ViewType != ViewType.ThreeD:
viewTemplates.append(view)
OUT = viewTemplates
This theoretically should run in both IronPython2 and CPython3 … do you have a screenshot of the error that occurs? (Hover over the yellow icon that pop’s up to expand).
Hello @BIM_Mrbrango - My apologies, this slipped off my radar.
You can download and use the IronPython2 package if you like from the Package Manager, and we also have an IronPython3 package also (Albeit that’s a first pass) if you won’t want to go down the CPython route.
There are differences between IronPython and CPython that you can read about here.
For example, i.LookupParameter(<param>).AsValueString() is a .NET call that is only present in IronPython and not CPython.