Last active
May 25, 2018 13:57
-
-
Save alvpickmans/987c86b7a579b338b8f5e5f992005233 to your computer and use it in GitHub Desktop.
Retrieve the ViewFamilyType id by its name. Helpful in order to create new views in Revit.
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 ViewFamilyIdByName(document, name): | |
type = System.Enum.Parse(ViewFamily, name) | |
viewFamilyTypes = FilteredElementCollector(document).OfClass(ViewFamilyType).ToElements() | |
id = -1 | |
for viewType in viewFamilyTypes: | |
if viewType.ViewFamily == type: | |
id = viewType.Id | |
break | |
return id |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment