|
6 | 6 | # Sytem
|
7 | 7 | import time
|
8 | 8 |
|
9 |
| -# Revit |
10 |
| -from Autodesk.Revit.DB import BuiltInCategory, ElementMulticategoryFilter, FilteredElementCollector, Opening, SelectionFilterElement, Transaction, ElementId |
11 |
| - |
12 | 9 | # pyRevit
|
13 |
| -from pyrevit import revit, script |
| 10 | +from pyrevit import revit, script, DB |
14 | 11 | from pyrevit.framework import List
|
15 | 12 | doc =__revit__.ActiveUIDocument.Document
|
16 | 13 | uidoc =__revit__.ActiveUIDocument
|
|
21 | 18 | # GET ALL OPENINGS IN THE PROJECT
|
22 | 19 |
|
23 | 20 | # List of categories
|
24 |
| -cats = [BuiltInCategory.OST_FloorOpening, |
25 |
| - BuiltInCategory.OST_SWallRectOpening, |
26 |
| - BuiltInCategory.OST_ShaftOpening, |
27 |
| - BuiltInCategory.OST_RoofOpening] |
28 |
| -list_cats = List[BuiltInCategory](cats) |
| 21 | +cats = [DB.BuiltInCategory.OST_FloorOpening, |
| 22 | + DB.BuiltInCategory.OST_SWallRectOpening, |
| 23 | + DB.BuiltInCategory.OST_ShaftOpening, |
| 24 | + DB.BuiltInCategory.OST_RoofOpening] |
| 25 | +list_cats = List[DB.BuiltInCategory](cats) |
29 | 26 |
|
30 | 27 | # Create filter
|
31 |
| -multi_cat_filter = ElementMulticategoryFilter(list_cats) |
| 28 | +multi_cat_filter = DB.ElementMulticategoryFilter(list_cats) |
32 | 29 |
|
33 | 30 | # Apply filter to filteredElementCollector
|
34 |
| -all_elements = FilteredElementCollector(doc)\ |
| 31 | +all_elements = DB.FilteredElementCollector(doc)\ |
35 | 32 | .WherePasses(multi_cat_filter)\
|
36 | 33 | .WhereElementIsNotElementType()\
|
37 | 34 | .ToElements()
|
38 | 35 |
|
39 | 36 | # Get elements for selection filter
|
40 |
| -element_ids = FilteredElementCollector(doc).OfClass(Opening).ToElementIds() |
41 |
| -element_ids = List[ElementId](element_ids) |
| 37 | +element_ids = DB.FilteredElementCollector(doc).OfClass(DB.Opening).ToElementIds() |
| 38 | +element_ids = List[DB.ElementId](element_ids) |
42 | 39 |
|
43 | 40 | # Declaration of a list to contains list of wanted element properties
|
44 | 41 | data = []
|
|
54 | 51 | data.append(el)
|
55 | 52 |
|
56 | 53 | # Get All Selection Filters
|
57 |
| -all_sel_filters = FilteredElementCollector(doc).OfClass(SelectionFilterElement).ToElements() |
| 54 | +all_sel_filters = DB.FilteredElementCollector(doc).OfClass(DB.SelectionFilterElement).ToElements() |
58 | 55 | dict_sel_filters = {f.Name: f for f in all_sel_filters}
|
59 | 56 |
|
60 | 57 | # Transaction to create a new selection filter
|
61 | 58 | with revit.Transaction('Create Openings Filter'):
|
62 | 59 | new_filter_name = '0_ShaftOpenings'
|
63 | 60 | if new_filter_name not in dict_sel_filters:
|
64 |
| - new_fil = SelectionFilterElement.Create(doc, new_filter_name) |
| 61 | + new_fil = DB.SelectionFilterElement.Create(doc, new_filter_name) |
65 | 62 | new_fil.AddSet(element_ids)
|
66 | 63 | print ('Created a filter called : {}'.format(new_filter_name))
|
67 | 64 | else:
|
|
0 commit comments