-
-
Notifications
You must be signed in to change notification settings - Fork 393
Door flip state #2663
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: develop
Are you sure you want to change the base?
Door flip state #2663
Changes from 11 commits
e1a2b6f
d32e049
159bcca
4aa8948
ec51d6d
d85b745
58ce923
96b9894
86f2888
e9b7298
784d563
e3274f9
36a073c
b5f794f
1537c8c
fb72b7b
e6a3caa
e1ba260
1068981
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,46 @@ | ||
title: | ||
ru: Направление двери | ||
fr_fr: Porte Miroir/Non Miroir | ||
en_us: Door Mirrored/Unmirrored | ||
de_de: Tür Gespiegelt/Ungespiegelt | ||
tooltip: | ||
en_us: >- | ||
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. | ||
|
||
All families to treat need two 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'. | ||
For families who have a symmetry checkbox "Door Mirrored" standard value may be changed by conditional statement in family: (f.ex -> if(Door Mirrored, "1 Wing Right", "1 Wing Left")) | ||
|
||
Prerequisites: | ||
In 'FAMILY' as instance, standard value as "blocked" formula | ||
[Parameter] - 'DoorFamilyOpeningDirection_standard' | ||
[Parameter] - 'DoorFamilyOpeningDirection_mirrored' | ||
|
||
In 'PROJECT' as instance: | ||
[Parameter] - 'Door Wing Opening Direction' | ||
de_de: >- | ||
Schreibt den Zustand ungegespiegel/gespiegelt (Links/Rechts) von Türen zurück in einen Instanzparameter 'Door Wing Opening Direction' in doors. Es muss ein Instanzparameter vom Typ Text sein, mit der Option "Unterschiedliche Werte für das Exemplar einer Gruppe". Ein Bericht über den ausgeführten Auftrag einschließlich der Änderungen zum vorherigen Zustand wird angezeigt. | ||
|
||
Alle zu behandelnden Familien benötigen zwei gemeinsame genutzte 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. | ||
Für Familien, die eine Option (bool) „Tür gespiegelt“ haben, kann der Standardwert auch durch eine Formel in der Familie geändert werden: (z.B. -> if(Tür gespiegelt, „1 Flügel DIN/Rechts“, „1 Flügel DIN/Links“)) | ||
|
||
Voraussetzungen: | ||
In 'FAMILY' als Instanzparameter, Standardwert als „blockierte“ Formel | ||
[Parameter] - 'DoorFamilyOpeningDirection_standard' | ||
[Parameter] - 'DoorFamilyOpeningDirection_mirrored' | ||
|
||
Im 'PROJEKT' als Instanzparameter mit der Option verschiedene "Unterschiedliche Werte für das Exemplar einer Gruppe": | ||
[Parameter] - 'Door Wing Opening Direction' | ||
fr_fr: >- | ||
Réécrit l'état non-miroir/miroir (gauche/droite) des portes dans un paramètre d'instance 'Door Wing Opening Direction' dans les portes. Il doit s'agir d'un paramètre d'instance de type texte, avec l'option 'valeurs peuvent varier en fonction de l'occurrence de groupe'. Un rapport sur le travail effectué, y compris les modifications par rapport à l'état précédent, est affiché. | ||
|
||
Toutes les familles à traiter nécessitent deux paramètres communs utilisés 'DoorFamilyOpeningDirection_standard' et 'DoorFamilyOpeningDirection_mirrored' en tant qu'instances avec des valeurs correspondant au standard défini dans la famille, afin de pouvoir réécrire dans le paramètre 'Door Wing Opening Direction'. | ||
Pour les familles qui ont une option (bool) « Miroiter la porte », la valeur par défaut peut également être modifiée par une formule dans la famille : (par ex. -> if(Miroiter la porte, " 1 vantail droite ", " 1 vantail gauche ")) | ||
|
||
Conditions préalables : | ||
Dans la ' FAMILLE ' comme paramètre d'instance, valeur par défaut comme formule 'bloquée'. | ||
[paramètre] - 'DoorFamilyOpeningDirection_standard' | ||
[paramètre] - 'DoorFamilyOpeningDirection_mirrored' | ||
|
||
Dans le 'PROJET' comme paramètre d'instance avec l'option différentes 'valeurs peuvent varier en fonction de l'occurrence de groupe': | ||
[paramètre] - 'Door Wing Opening Direction' | ||
author: Jakob Steiner (special thanks to Erik Frits) |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,132 @@ | ||
# -*- coding: utf-8 -*- | ||
|
||
import time, sys | ||
from pyrevit import script, DB, revit, DOCS, forms | ||
from pyrevit.framework import List | ||
|
||
doc = DOCS.doc | ||
output = script.get_output() | ||
|
||
DOORDIR_STANDARD_PARAM = "DoorFamilyOpeningDirection_standard" | ||
DOORDIR_MIRRORED_PARAM = "DoorFamilyOpeningDirection_mirrored" | ||
DOORDIR_WRITEBACK_PARAM = "Door Wing Opening Direction" | ||
DOORDIR_ERROR_VALUE = "-" # Value if the family doesn't have shared param. above | ||
|
||
# MAIN | ||
timer_start = time.time() | ||
|
||
# GET ALL DOORS | ||
doors_collector = ( | ||
DB.FilteredElementCollector(doc) | ||
.OfCategory(DB.BuiltInCategory.OST_Doors) | ||
.WhereElementIsNotElementType() | ||
.ToElements() | ||
) | ||
|
||
if not doors_collector: | ||
forms.alert("No doors found in the model.", title="Warning") | ||
script.exit() | ||
|
||
|
||
def parameter_exists(parameter_name): | ||
binding_map = doc.ParameterBindings | ||
iterator = binding_map.ForwardIterator() | ||
iterator.Reset() | ||
while iterator.MoveNext(): | ||
if iterator.Key.Name == parameter_name: | ||
return True | ||
return False | ||
|
||
|
||
if not parameter_exists(DOORDIR_WRITEBACK_PARAM): | ||
jmcouffin marked this conversation as resolved.
Outdated
Show resolved
Hide resolved
|
||
print( | ||
"The parameter '{}' does not exist in the current document.\n" | ||
"Please create the parameter as an instance parameter, option different values for groupes,\n" | ||
"for the category doors in the project.".format(DOORDIR_WRITEBACK_PARAM) | ||
) | ||
script.exit() | ||
|
||
count_parameter = 0 | ||
count_not_parameter = 0 | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I believe this could be left out since it is |
||
doors_without_parameter = [] | ||
jmcouffin marked this conversation as resolved.
Outdated
Show resolved
Hide resolved
|
||
data_doors_changed = [] | ||
|
||
with revit.Transaction(doc, "DoorMirrorState"): | ||
for door in doors_collector: | ||
try: | ||
if door.Mirrored: | ||
value = door.LookupParameter(DOORDIR_MIRRORED_PARAM).AsString() | ||
else: | ||
value = door.LookupParameter(DOORDIR_STANDARD_PARAM).AsString() | ||
jmcouffin marked this conversation as resolved.
Outdated
Show resolved
Hide resolved
|
||
count_parameter += 1 | ||
|
||
except AttributeError: | ||
value = DOORDIR_ERROR_VALUE | ||
count_not_parameter += 1 | ||
|
||
door_family = door.get_Parameter( | ||
DB.BuiltInParameter.ELEM_FAMILY_PARAM | ||
).AsValueString() | ||
door_type = door.get_Parameter( | ||
DB.BuiltInParameter.ELEM_TYPE_PARAM | ||
).AsValueString() | ||
door_name = "{family}-{type}".format(family=door_family, type=door_type) | ||
if door_name not in doors_without_parameter: | ||
doors_without_parameter.append(door_name) | ||
jmcouffin marked this conversation as resolved.
Outdated
Show resolved
Hide resolved
|
||
|
||
try: | ||
door_out_param = door.LookupParameter(DOORDIR_WRITEBACK_PARAM) | ||
|
||
door_out_param_old = door_out_param.AsString() | ||
door_out_param_new = value | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. just use |
||
if door_out_param_old != door_out_param_new: | ||
door_out_param_changed = "{} -> {}".format( | ||
door_out_param_old, door_out_param_new | ||
) | ||
door_name = door.Name | ||
door_changed_link = output.linkify(door.Id) | ||
data_doors_changed.append( | ||
[door_name, door_out_param_changed, door_changed_link] | ||
) | ||
door_out_param.Set(str(value)) | ||
except AttributeError: | ||
forms.alert( | ||
"Please make sure instance parameter exists: {}".format( | ||
DOORDIR_WRITEBACK_PARAM | ||
) | ||
) | ||
script.exit() | ||
|
||
output.print_md( | ||
"### Number of doors found in the project: {} \n" | ||
"- With writeback parameters defined in door family: {}\n" | ||
"- Without writeback parameters defined in door family: {}\n" | ||
"- Parameters missing: '{}', '{}'\n" | ||
"- You will find in the folder of the script a shared parameter file containing these parameters.\n" | ||
"- The default writeback value for doors without defined values will be: '{}'\n" | ||
"---\n".format( | ||
len(doors_collector), | ||
count_parameter, | ||
count_not_parameter, | ||
DOORDIR_STANDARD_PARAM, | ||
DOORDIR_MIRRORED_PARAM, | ||
DOORDIR_ERROR_VALUE, | ||
) | ||
) | ||
|
||
output.print_md("### Door families without writeback parameter defined in family:") | ||
for door_type in doors_without_parameter: | ||
print(door_type) | ||
jmcouffin marked this conversation as resolved.
Outdated
Show resolved
Hide resolved
|
||
output.print_md("---\n### Changes to previous run of the script:") | ||
|
||
if data_doors_changed: | ||
output.print_table( | ||
table_data=data_doors_changed, | ||
title="Doors with changed parameters:", | ||
columns=["Door", "Changed Value (old->new)", "ElementId"], | ||
) | ||
else: | ||
output.print_md("#### No doors with changed parameters were found.") | ||
jmcouffin marked this conversation as resolved.
Outdated
Show resolved
Hide resolved
|
||
|
||
elapsed_time = time.time() - timer_start | ||
output.print_md("---\n#### Script has finished in {:.2f}s".format(elapsed_time)) |
Uh oh!
There was an error while loading. Please reload this page.