Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Save alvpickmans/3dddfe28c0395a14c25bd68da3bc749d to your computer and use it in GitHub Desktop.
Save alvpickmans/3dddfe28c0395a14c25bd68da3bc749d to your computer and use it in GitHub Desktop.
Get ElementId of ViewType by its type Name.
import clr
clr.AddReference('RevitAPI')
from Autodesk.Revit.DB import *
clr.AddReference("RevitServices")
import RevitServices
from RevitServices.Persistence import DocumentManager
import System
doc = DocumentManager.Instance.CurrentDBDocument
def ViewFamilyTypeIdByName(document, name):
viewFamilyTypes = FilteredElementCollector(document).OfClass(ViewFamilyType).ToElements()
id = -1
for viewType in viewFamilyTypes:
typeName = viewType.get_Parameter(BuiltInParameter.SYMBOL_NAME_PARAM).AsString()
if typeName == name:
id = viewType.Id
break
return id
OUT = ViewFamilyTypeIdByTypeName(doc, IN[0])
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment