-
-
Notifications
You must be signed in to change notification settings - Fork 332
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #1655 from jmcouffin/feature/include_exclude_from_…
…view_template include exclude params from view templates
- Loading branch information
Showing
4 changed files
with
64 additions
and
1 deletion.
There are no files selected for viewing
7 changes: 7 additions & 0 deletions
7
...views.stack/Views.pulldown/Set View Template Controlled Parameters.pushbutton/bundle.yaml
This file contains 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,7 @@ | ||
title: | ||
fr_fr: Inclure ou exclure les paramètres du gabarit de vue | ||
en_us: Include or exclude template parameters | ||
tooltip: | ||
fr_fr: Inclure ou exclure les paramètres du gabarit de vue - non fonctionnel pour les gabarits de vue 3D | ||
en_us: Include or exclude template parameters, not functional for 3D view templates | ||
author: Jean-Marc Couffin |
Binary file added
BIN
+1.85 KB
...tack/Views.pulldown/Set View Template Controlled Parameters.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.
54 changes: 54 additions & 0 deletions
54
...l/views.stack/Views.pulldown/Set View Template Controlled Parameters.pushbutton/script.py
This file contains 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,54 @@ | ||
from pyrevit import script, revit, DB, forms | ||
|
||
output = script.get_output() | ||
output.close_others() | ||
|
||
doc = revit.doc | ||
|
||
templates = [v for v in DB.FilteredElementCollector( | ||
doc).OfClass(DB.View).ToElements() if v.IsTemplate] | ||
|
||
view_templates, view_templates_names = [], [] | ||
for template in templates: | ||
if str(template.ViewType) != 'ThreeD': | ||
view_templates.append(template) | ||
|
||
params_names, params = [], [] | ||
for template in view_templates: | ||
for p in template.Parameters: | ||
if p.Definition.Name not in params_names: | ||
params.append(p) | ||
params_names.append(p.Definition.Name) | ||
|
||
selected_view_templates = forms.SelectFromList.show( | ||
view_templates, button_name='Select Template', multiselect=True, name_attr='Name') | ||
|
||
parameters_processed = forms.SelectFromList.show( | ||
params_names, button_name='Select Parameters', multiselect=True) | ||
for param in params: | ||
if param.Definition.Name not in parameters_processed: | ||
params.remove(param) | ||
params_ids = [p.Id for p in params] | ||
|
||
inclusion = forms.CommandSwitchWindow.show( | ||
['Include', 'Exclude'], message='Include or Exclude parameters from selected templates?') | ||
if inclusion == 'Include': | ||
include = False | ||
else: | ||
include = True | ||
|
||
with revit.Transaction('set params in view templates'): | ||
results = [] | ||
for template in selected_view_templates: | ||
all_params = template.GetTemplateParameterIds() | ||
switch_off_param_ids = params_ids | ||
|
||
non_controlled_param_ids = template.GetNonControlledTemplateParameterIds() | ||
for switch_off_param_id in switch_off_param_ids: | ||
if include: | ||
non_controlled_param_ids.Add(switch_off_param_id) | ||
else: | ||
non_controlled_param_ids.Remove(switch_off_param_id) | ||
|
||
template.SetNonControlledTemplateParameterIds(non_controlled_param_ids) | ||
results.append(template) |
This file contains 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