Skip to content

Commit 369bf6f

Browse files
authored
Merge PR Added "Get Openings" tool to analyze panel
Added "Get Openings" tool to analyze panel
2 parents 326b1e5 + 74a7947 commit 369bf6f

File tree

4 files changed

+92
-0
lines changed

4 files changed

+92
-0
lines changed
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
title:
2+
ru: Получить отверстия
3+
fr_fr: Obtenir les ouvertures
4+
en_us: Get Openings
5+
de_de: Öffnungen ermitteln
6+
tooltip: >
7+
en_us: |
8+
Scans through the project for openings. A list with clickable links will be presented. Open a 3D view to access and see the selected openings. A selection filter will be created or updated to select all openings with one click.
9+
de_de: |
10+
Durchsucht das Projekt nach Öffnungen. Eine Liste mit anklickbaren Links wird angezeigt. Öffnen Sie eine 3D-Ansicht, um auf die ausgewählten Öffnungen zuzugreifen und diese zu sehen. Es wird ein Auswahlfilter erstellt oder aktualisiert, um alle Öffnungen mit einem Klick auszuwählen.
11+
fr_fr: |
12+
Examine le projet à la recherche d'ouvertures. Une liste avec des liens cliquables sera présentée. Ouvrez une vue 3D pour accéder et voir les ouvertures sélectionnées. Un filtre de sélection sera créé ou mis à jour pour sélectionner toutes les ouvertures en un seul clic.
13+
authors: Jakob Steiner, inspired by the initial work of Andreas Draxl, Mohamed Bedair, special thanks to Erik Frits
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,79 @@
1+
# -*- coding: utf-8 -*-
2+
3+
"""Lists all openings in the project and creates
4+
a selection filter for them."""
5+
6+
# Sytem
7+
import time
8+
9+
# pyRevit
10+
from pyrevit import revit, script, DB
11+
from pyrevit.framework import List
12+
doc =__revit__.ActiveUIDocument.Document
13+
uidoc =__revit__.ActiveUIDocument
14+
output = script.get_output()
15+
selection = uidoc.Selection
16+
timer_start = time.time()
17+
18+
# GET ALL OPENINGS IN THE PROJECT
19+
20+
# List of categories
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)
26+
27+
# Create filter
28+
multi_cat_filter = DB.ElementMulticategoryFilter(list_cats)
29+
30+
# Apply filter to filteredElementCollector
31+
all_elements = DB.FilteredElementCollector(doc)\
32+
.WherePasses(multi_cat_filter)\
33+
.WhereElementIsNotElementType()\
34+
.ToElements()
35+
36+
# Get elements for selection filter
37+
element_ids = DB.FilteredElementCollector(doc).OfClass(DB.Opening).ToElementIds()
38+
element_ids = List[DB.ElementId](element_ids)
39+
40+
# Declaration of a list to contains list of wanted element properties
41+
data = []
42+
43+
# Collect information about the object and put it into in the data list.
44+
for e in all_elements:
45+
el = []
46+
el.append(e.Name)
47+
el.append(e.Id)
48+
# add IFC Classification if parameter exist
49+
e_link = output.linkify(e.Id)
50+
el.append(e_link)
51+
data.append(el)
52+
53+
# Get All Selection Filters
54+
all_sel_filters = DB.FilteredElementCollector(doc).OfClass(DB.SelectionFilterElement).ToElements()
55+
dict_sel_filters = {f.Name: f for f in all_sel_filters}
56+
57+
# Transaction to create a new selection filter
58+
with revit.Transaction('Create Openings Filter'):
59+
new_filter_name = '0_ShaftOpenings'
60+
if new_filter_name not in dict_sel_filters:
61+
new_fil = DB.SelectionFilterElement.Create(doc, new_filter_name)
62+
new_fil.AddSet(element_ids)
63+
print ('Created a filter called : {}'.format(new_filter_name))
64+
else:
65+
existing_fil = dict_sel_filters[new_filter_name]
66+
existing_fil.AddSet(element_ids)
67+
print ('Updated a filter called : {}'.format(new_filter_name))
68+
69+
# Report
70+
output.print_md("#### There are {} openings (floor, wall, shaft, roof) in the project.".format(len(all_elements))) # TO DO Output link for all.
71+
if data:
72+
output.print_table(table_data=data, title="Shafts:", columns=["Family" ,"ElementId", "Select/Show Element"])
73+
#output.print_md("#####Total {} WDB/WA elements has been updated.".format(len(data)))
74+
else:
75+
output.print_md("#####There are no openings (floor, wall, shaft, roof) in the project")
76+
77+
# End
78+
output.print_md('---')
79+
output.print_md('#### Script has finished in {}s'.format(time.time() - timer_start))

0 commit comments

Comments
 (0)