clr.AddReference("RevitServices") # Adding the RevitServices.dll special # Dynamo module to deal with Revit import RevitServices # Importing RevitServices from RevitServices.Persistence import DocumentManager # From RevitServices # import the Document Manager clr.AddReference("RevitAPI") # Adding the RevitAPI.dll module to access the # Revit API import Autodesk # Here we import the Autodesk namespace # From the Autodesk namespace - derived down to the Revit Database, we imoprt # only the Filtered Element Collector, Wall, ElementId and ElementLevelFilter # classes from Autodesk.Revit.DB import FilteredElementCollector, Wall, ElementId, ElementLevelFilter # Here we give the Revit Document a nickname of 'doc' which allows us to simply # call 'doc' later without having to type the long namespace name doc = DocumentManager.Instance.CurrentDBDocument # Here we create a a filter based on the a chosen Level - input via our Input # Port filter = ElementLevelFilter(Autodesk.Revit.DB.ElementId(IN[0].Id)) # We then run a 'Filtered Element Collector' with our created 'filter' (Chosen # Level), and discount any element that is an 'Element Type' before using the # 'ToElements' call to return real elements. elementAtLevelCollector = FilteredElementCollector(doc).WherePasses( filter).WhereElementIsNotElementType().ToElements() # To get our results back inside of Dynamo, we need to append a list to the OUT # port OUT = elementAtLevelCollector
# if tested against zero, but included so can be adapted to other values epsilon = 10**-3 # use rule for doubles ruleArea0 = FilterDoubleRule(providerArea0, evaluatorGr, testArea0, epsilon) # filter with rule filterArea0 = ElementParameterFilter(ruleArea0) # adapted with kudos to archilab getRoomsByLevel # https://gist.github.com/ksobon/8007f64a889df00afd22#file-getroomsbylevel-py # unwrap the level selected from the dynamo node levelUnwrapped = UnwrapElement(levelInput) # get the Id of the level levelUnwrappedId = levelUnwrapped.Id # filter elements by the unwrapped level id levelFilter = ElementLevelFilter(levelUnwrappedId) # alias areaFilter, for areas (not rooms) we will want to exclude areaFilter = AreaFilter() # change to room filter if you want svg of areas not rooms #areaFilter = RoomFilter() # collect elements to be excluded areaExcludes = fec(doc).WherePasses(areaFilter).ToElements() # convert to a list if not allready so areaExcludes = list(areaExcludes) # create empty set and list to store elements in element_set = ElementSet() excludes = List[ElementId]() # check if there are any areas to exclude if len(areaExcludes) == 0:
clr.AddReference("RevitServices") from RevitServices.Persistence import DocumentManager from RevitServices.Transactions import TransactionManager doc = DocumentManager.Instance.CurrentDBDocument uiapp = DocumentManager.Instance.CurrentUIApplication app = uiapp.Application def FindLevel(lev, name): for l in lev: if l.Name == name: return l.Id col_levels = FilteredElementCollector(doc).OfClass(Level).ToElements() elem_filter = ElementLevelFilter(FindLevel(col_levels, "Уровень 2")) cats = doc.Settings.Categories elems = [] for c in cats: collector = FilteredElementCollector(doc).OfCategory(c.Id).WherePasses( elem_filter).WhereElementIsNotElementType().ToElements() elems.append(collector) OUT = elems