Skip to content

Commit

Permalink
Merge pull request #1655 from jmcouffin/feature/include_exclude_from_…
Browse files Browse the repository at this point in the history
…view_template

include exclude params from view templates
  • Loading branch information
jmcouffin authored Dec 27, 2022
2 parents 8af3949 + 72abaca commit 1b44ae0
Show file tree
Hide file tree
Showing 4 changed files with 64 additions and 1 deletion.
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
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
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)
Original file line number Diff line number Diff line change
Expand Up @@ -21,4 +21,6 @@ layout:
- Create Parallel Section
- Add Views to Sheets
- Remove Empty Tags
- Remove Underlay From Selected Views
- Remove Underlay From Selected Views
- -----
- Set View Template Controlled Parameters

0 comments on commit 1b44ae0

Please sign in to comment.