Skip to content

Instantly share code, notes, and snippets.

@gtalarico
Last active September 1, 2016 01:01
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save gtalarico/f8426cb069d3b77c4aca27adf09d01c6 to your computer and use it in GitHub Desktop.
Save gtalarico/f8426cb069d3b77c4aca27adf09d01c6 to your computer and use it in GitHub Desktop.
RevitAPI::Code Snippets::Get Filled Region Id - by Name
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