-
-
Notifications
You must be signed in to change notification settings - Fork 375
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
Open
mangrove-art
wants to merge
19
commits into
pyrevitlabs:develop
Choose a base branch
from
mangrove-art:doorFlipState
base: develop
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Door flip state #2663
Changes from all commits
Commits
Show all changes
19 commits
Select commit
Hold shift + click to select a range
e1a2b6f
DoorFlipState with changes in door - Initial Commit
d32e049
Integrated correct output in changes list
159bcca
WIP
4aa8948
deleted
ec51d6d
DoorMirrorState
d85b745
FinalCleanup
58ce923
Update extensions/pyRevitTools.extension/pyRevit.tab/Analysis.panel/T…
jmcouffin 96b9894
General cleanup
jmcouffin 86f2888
Update extensions/pyRevitTools.extension/pyRevit.tab/Analysis.panel/T…
jmcouffin e9b7298
Update extensions/pyRevitTools.extension/pyRevit.tab/Analysis.panel/T…
jmcouffin 784d563
print statements cleanup
jmcouffin e3274f9
Update extensions/pyRevitTools.extension/pyRevit.tab/Analysis.panel/T…
jmcouffin 36a073c
Update extensions/pyRevitTools.extension/pyRevit.tab/Analysis.panel/T…
jmcouffin b5f794f
Update extensions/pyRevitTools.extension/pyRevit.tab/Analysis.panel/T…
jmcouffin 1537c8c
Update extensions/pyRevitTools.extension/pyRevit.tab/Analysis.panel/T…
jmcouffin fb72b7b
Update extensions/pyRevitTools.extension/pyRevit.tab/Analysis.panel/T…
jmcouffin e6a3caa
Update extensions/pyRevitTools.extension/pyRevit.tab/Analysis.panel/T…
jmcouffin e1ba260
Update extensions/pyRevitTools.extension/pyRevit.tab/Analysis.panel/T…
jmcouffin 1068981
Merge branch 'develop' into doorFlipState
jmcouffin File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
Binary file added
BIN
+1.01 KB
....panel/Tools.stack/Analyse.pulldown/Door Mirror State.pushbutton/DoorMirrorStateParam.txt
Binary file not shown.
46 changes: 46 additions & 0 deletions
46
....tab/Analysis.panel/Tools.stack/Analyse.pulldown/Door Mirror State.pushbutton/bundle.yaml
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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) |
Binary file added
BIN
+3.21 KB
...s.panel/Tools.stack/Analyse.pulldown/Door Mirror State.pushbutton/icon.dark.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added
BIN
+3.68 KB
...alysis.panel/Tools.stack/Analyse.pulldown/Door Mirror State.pushbutton/icon.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
113 changes: 113 additions & 0 deletions
113
...it.tab/Analysis.panel/Tools.stack/Analyse.pulldown/Door Mirror State.pushbutton/script.py
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,113 @@ | ||
# -*- 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 = get_doors(doc=doc) | ||
|
||
if not doors_collector: | ||
forms.alert("No doors found in the model.", title="Warning") | ||
script.exit() | ||
|
||
|
||
if not model_has_parameter(DOORDIR_WRITEBACK_PARAM, doc=doc): | ||
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 | ||
doors_without_parameter = set() | ||
data_doors_changed = [] | ||
|
||
with revit.Transaction(doc, "DoorMirrorState"): | ||
for door in doors_collector: | ||
try: | ||
param_name = DOORDIR_MIRRORED_PARAM if door.Mirrored else DOORDIR_STANDARD_PARAM | ||
value = get_param_value(get_param(door, param_name)) | ||
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) | ||
doors_without_parameter.add(door_name) | ||
|
||
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:") | ||
output.print_md("- " + "\n - ".join(doors_without_parameter)) | ||
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.*") | ||
|
||
elapsed_time = time.time() - timer_start | ||
output.print_md("---\n#### Script has finished in {:.2f}s".format(elapsed_time)) |
Binary file added
BIN
+115 KB
...sis.panel/Tools.stack/Analyse.pulldown/Door Mirror State.pushbutton/tooltip.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I believe this could be left out since it is
len(doors) - count_parameter