Last active
September 1, 2016 01:01
-
-
Save gtalarico/f8426cb069d3b77c4aca27adf09d01c6 to your computer and use it in GitHub Desktop.
RevitAPI::Code Snippets::Get Filled Region Id - by 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
from Autodesk.Revit.DB import Element, FilteredElementCollector | |
from Autodesk.Revit.DB import FilledRegionType, FilledRegion | |
def fregion_id_by_name(name=None): | |
"""Get Id of Filled Region Type by Name. | |
Loops through all types, tries to match name. | |
If name not supplied, first type is used. | |
If name supplied does not match any existing types, last type is used | |
""" | |
f_region_types = FilteredElementCollector(doc).OfClass(FilledRegionType) | |
for fregion_type in f_region_types: | |
fregion_name = Element.Name.GetValue(fregion_type) | |
if not name or name.lower() == fregion_name.lower(): | |
return fregion_type.Id | |
# Loops through all, not found: use last | |
else: | |
print('Color not specified or not found.') | |
return fregion_type.Id |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment