Created
May 25, 2018 13:58
-
-
Save alvpickmans/3dddfe28c0395a14c25bd68da3bc749d to your computer and use it in GitHub Desktop.
Get ElementId of ViewType by its type Name.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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