Skip to content

Commit 159bcca

Browse files
EFjmcouffin
authored andcommitted
WIP
1 parent d32e049 commit 159bcca

File tree

6 files changed

+165
-0
lines changed

6 files changed

+165
-0
lines changed

extensions/pyRevitTools.extension/pyRevit.tab/Analysis.panel/Tools.stack/Analyse.pulldown/Door Flip State.pushbutton/bundle.yaml

Whitespace-only changes.
1.01 KB
Binary file not shown.
Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,34 @@
1+
title:
2+
ru: Направление двери
3+
fr_fr: Porte Miroir/Non Miroir
4+
en_us: Door Mirrored/Unmirrored
5+
de_de: Tür Gespiegelt/Ungespiegelt
6+
tooltip:
7+
en_us: >-
8+
Writes the mirror state (aka Left/Right) of doors back to an instance parameter 'Door Wing Opening Direction' in doors. This needs to be an instance parameter of type text with the option different values for group instances. Prints a summary of accomplished job including changes to previous state.
9+
10+
All families to treat need 2 shared parameters 'DoorFamilyOpeningDirection_standard' and 'DoorFamilyOpeningDirection_mirrored' as instances with values corresponding, as in family defined standard to write back to parameter 'Door Wing Opening Direction'.
11+
For families who have a symtetry chechbox "Door Mirrored" standard value my be changed by conditional statement in family: (f.ex -> if(Door Mirrored, "1 Wing Right", "1 Wing Left"))
12+
13+
Prerequisites:
14+
In 'FAMILY' as instance, standard value as "blocked" formula
15+
[Parameter] - 'DoorFamilyOpeningDirection_standard'
16+
[Parameter] - 'DoorFamilyOpeningDirection_mirrored'
17+
18+
In 'PROJECT' as instance:
19+
[Parameter] - 'Door Wing Opening Direction'
20+
de_de: >-
21+
Schreibt den Spiegelzustand (auch bekannt als Links/Rechts) von Türen zurück in einen Instanzparameter 'Door Wing Opening Direction' in doors. Dies muss ein Instanzparameter vom Typ Text sein, mit der Option verschiedene Werte für Gruppeninstanzen. Druckt eine Zusammenfassung des ausgeführten Auftrags einschließlich der Änderungen zum vorherigen Zustand.
22+
23+
Alle zu behandelnden Familien benötigen 2 gemeinsame Parameter 'DoorFamilyOpeningDirection_standard' und 'DoorFamilyOpeningDirection_mirrored' als Instanzen mit Werten, die dem in der Familie definierten Standard entsprechen, um in den Parameter 'Door Wing Opening Direction' zurückzuschreiben.
24+
Für Familien, die ein Symtetrie-Kästchen „Tür gespiegelt“ haben, kann der Standardwert durch eine bedingte Anweisung in der Familie geändert werden: (z.B. -> if(Tür gespiegelt, „1 Flügel rechts“, „1 Flügel links“))
25+
26+
Voraussetzungen:
27+
In 'FAMILY' als Instanz, Standardwert als „blockierte“ Formel
28+
[Parameter] - 'DoorFamilyOpeningDirection_standard'
29+
[Parameter] - 'DoorFamilyOpeningDirection_mirrored' (Türöffnungsrichtung gespiegelt)
30+
31+
Im 'PROJEKT' als Instanzparameter mit der Option verschiedene "Unterschiedliche Werte für das Exemplar einer Gruppe" (Türöffnungsrichtung):
32+
[Parameter] - 'Door Wing Opening Direction'
33+
fr_fr: >-
34+
author: Jakob Steiner (special thanks to Erik Frits)
3.21 KB
Loading
3.68 KB
Loading
Lines changed: 131 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,131 @@
1+
# -*- coding: utf-8 -*-
2+
3+
__title__ = "DoorMirrorState"
4+
__author__ = "Jakob Steiner"
5+
__doc__ = """Version = 0.3
6+
Date = 13.04.2025
7+
8+
"""
9+
#--------------------------------------------------------------------------------------------------------------------
10+
#IMPORTS
11+
# System
12+
import time, sys
13+
#pyRevit
14+
from pyrevit import script, DB
15+
from pyrevit.framework import List
16+
#Autodesk.Revit.DB
17+
from Autodesk.Revit.DB import Transaction, BuiltInParameter
18+
19+
doc = __revit__.ActiveUIDocument.Document
20+
uidoc = __revit__.ActiveUIDocument
21+
app = __revit__.Application
22+
output = script.get_output()
23+
#--------------------------------------------------------------------------------------------------------------------
24+
#GLOBAL PARAMETERS
25+
DOORDIR_STANDARD_PARAM = "DoorFamilyOpeningDirection_standard"
26+
DOORDIR_MIRRORED_PARAM = "DoorFamilyOpeningDirection_mirrored"
27+
DOORDIR_WRITEBACK_PARAM = "Door Wing Opening Direction"
28+
DOORDIR_ERROR_VALUE = "-" # Value if the family does't have shared param. above
29+
30+
#--------------------------------------------------------------------------------------------------------------------
31+
#MAIN
32+
timer_start = time.time()
33+
34+
# GET ALL DOORS
35+
doors_collector = DB.FilteredElementCollector(doc).OfCategory(DB.BuiltInCategory.OST_Doors).WhereElementIsNotElementType().ToElements()
36+
if not doors_collector:
37+
sys.exit("No doors were found in the project.")
38+
39+
# FUNCTION TO CHECK IF PARAMETER EXISTS
40+
def parameter_exists(parameter_name):
41+
binding_map = doc.ParameterBindings
42+
iterator = binding_map.ForwardIterator()
43+
iterator.Reset()
44+
while iterator.MoveNext():
45+
if iterator.Key.Name == parameter_name:
46+
return True
47+
return False
48+
49+
# CHECK IF TUERAUFG_WRITEBACK_PARAMETER EXISTS
50+
if not parameter_exists(DOORDIR_WRITEBACK_PARAM):
51+
print("The parameter '{}' does not exist in the current document.".format(DOORDIR_WRITEBACK_PARAM))
52+
print("Please create the parameter as an instance parameter, option different values for groupes,")
53+
print("for the category doors in the project.")
54+
55+
sys.exit()
56+
57+
# CREATE CONTAINERS
58+
count_parameter = 0
59+
count_not_parameter = 0
60+
doors_without_parameter = []
61+
# CREATE A LIST FOR DOORS WITH CHANGED PARAMETERS
62+
data_doors_changed = []
63+
64+
t = Transaction(doc,__title__)
65+
t.Start()
66+
#door_changed =[]
67+
# LOOP THROUGH ALL DOORS
68+
for door in doors_collector:
69+
# GET VALUE
70+
try:
71+
if door.Mirrored:
72+
value = door.LookupParameter(DOORDIR_MIRRORED_PARAM).AsString()
73+
else:
74+
value = door.LookupParameter(DOORDIR_STANDARD_PARAM).AsString()
75+
count_parameter +=1
76+
77+
except:
78+
# IF VALUE IS UNAVAILABLE - USE DEFAULT ERROR VALUE
79+
value = DOORDIR_ERROR_VALUE
80+
count_not_parameter += 1
81+
82+
# LOG DOOR TYPE WITHOUT VALUE
83+
door_family = door.get_Parameter(BuiltInParameter.ELEM_FAMILY_PARAM).AsValueString()
84+
door_type = door.get_Parameter(BuiltInParameter.ELEM_TYPE_PARAM).AsValueString()
85+
door_name = "{family}-{type}".format(family=door_family, type=door_type)
86+
if door_name not in doors_without_parameter:
87+
doors_without_parameter.append(door_name)
88+
89+
# SET PARAMETER
90+
try:
91+
# CHECK IF THE WRITEBACK PARAMETER EXISTS
92+
door_out_param = door.LookupParameter(DOORDIR_WRITEBACK_PARAM)
93+
94+
# WRITE CHANGES IN PARAMETERS
95+
door_out_param_old = door.LookupParameter(DOORDIR_WRITEBACK_PARAM).AsString()
96+
door_out_param_new = value
97+
if door_out_param_old != door_out_param_new:
98+
door_out_param_changed = "{} -> {}".format(door_out_param_old, door_out_param_new)
99+
door_name = door.Name
100+
door_changed_link = output.linkify(door.Id)
101+
data_doors_changed.append([door_name, door_out_param_changed, door_changed_link])
102+
# SET DOOR FLIP STATE TO THE WRITEBACK PARAMETER
103+
door_out_param.Set(str(value))
104+
except:
105+
print('Please make sure OUT instance parameter exists: {}'.format(DOORDIR_WRITEBACK_PARAM))
106+
sys.exit()
107+
t.Commit()
108+
109+
# FINAL PRINT
110+
output.print_md('### Number of doors found in the project: {} '.format(len(doors_collector)))
111+
output.print_md('of these with writeback parameters defined in door family: {}'.format(count_parameter))
112+
output.print_md('without writeback parameters defined in door family: {a}'.format(a=count_not_parameter,))
113+
output.print_md('parameters missing: '"'{b}'"', '"'{c}'"''.format(b=DOORDIR_STANDARD_PARAM, c=DOORDIR_MIRRORED_PARAM))
114+
output.print_md('you will find in the folder of the script a shared parameter file containing this parameters.')
115+
output.print_md('The default writeback value for doors without defined values will be : '" {d} "' '.format(d=DOORDIR_ERROR_VALUE))
116+
output.print_md('---')
117+
output.print_md('### Door families without writeback parameter defined in family:')
118+
for door_type in doors_without_parameter:
119+
print(door_type)
120+
output.print_md('---')
121+
output.print_md('### Changes to previous run of the script:')
122+
123+
# Create a table for changed parameter values
124+
if data_doors_changed:
125+
output.print_table(table_data=data_doors_changed, title="Doors with changed parameters:", columns=["Door", "Changed Value (old->new)", "ElementId"])
126+
else:
127+
output.print_md('#### No doors with changed parameters were found.')
128+
129+
# End
130+
output.print_md('---')
131+
output.print_md('#### Script has finished in {}s'.format(time.time() - timer_start))

0 commit comments

Comments
 (0)