from Autodesk.Revit.DB import *
from Autodesk.Revit.DB.Architecture import Room
from pyrevit import forms
uidoc = __revit__.ActiveUIDocument
doc = __revit__.ActiveUIDocument.Document
def create_area_solid(area):
area_boundary = area.GetBoundarySegments(SpatialElementBoundaryOptions())
if area_boundary:
if len(area_boundary) == 0:
return None
profile = CurveLoop()
for curve in area_boundary[0]:
profile.Append(curve.GetCurve())
extrusion_height = 10.0
return GeometryCreationUtilities.CreateExtrusionGeometry([profile], XYZ.BasisZ, extrusion_height)
all_areas = FilteredElementCollector(doc).OfCategory(BuiltInCategory.OST_Areas).WhereElementIsNotElementType().ToElements()
from collections import defaultdict
dict_areas = defaultdict(list)
for area in all_areas:
dict_areas[area.AreaScheme.Name].append(area)
from pyrevit import forms
sel_area_scheme = forms.SelectFromList.show(dict_areas.keys(), button_name='Select AreaScheme')
if not sel_area_scheme:
forms.alert('No AreaScheme was selected. Please Try Again')
areas = dict_areas[sel_area_scheme]
for area in areas:
try:
area_solid = create_area_solid(area)
except:
import traceback
print(traceback.format_exc())