Skip to content

Commit

Permalink
Update Duplicate Views Dependent (#1202)
Browse files Browse the repository at this point in the history
* fixed host adder and added 2020.2.3

* added 2020.1.1 to hosts

* Add Duplicate View Support Dependent

* Remove Print Test

Co-authored-by: Ehsan Iran-Nejad <eirannejad@gmail.com>
  • Loading branch information
chuongmep and eirannejad authored Mar 26, 2021
1 parent c0f6c78 commit 6f0eb8e
Showing 1 changed file with 13 additions and 12 deletions.
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
"""Batch duplicates the selected views with or without detailing."""
"""Batch duplicates the selected views with or without detailing, or as dependents"""

from pyrevit import revit, DB
from pyrevit import forms
Expand All @@ -12,15 +12,10 @@ def duplicableview(view):
return view.CanViewBeDuplicated(DB.ViewDuplicateOption.Duplicate)


def duplicate_views(viewlist, with_detailing=True):
def duplicate_views(viewlist, dupop):
dup_view_ids = []
with revit.Transaction('Duplicate selected views'):
for el in viewlist:
if with_detailing:
dupop = DB.ViewDuplicateOption.WithDetailing
else:
dupop = DB.ViewDuplicateOption.Duplicate

try:
dup_view_ids.append(el.Duplicate(dupop))
except Exception as duplerr:
Expand All @@ -37,14 +32,20 @@ def duplicate_views(viewlist, with_detailing=True):
selected_option = \
forms.CommandSwitchWindow.show(
['WITH Detailing',
'WITHOUT Detailing'],
'WITHOUT Detailing',
'AS Dependent'],
message='Select duplication option:'
)

if selected_option:
dupop = DB.ViewDuplicateOption.AsDependent
if selected_option == 'WITH Detailing':
dupop = DB.ViewDuplicateOption.WithDetailing
if selected_option == 'WITHOUT Detailing':
dupop = DB.ViewDuplicateOption.Duplicate
if selected_option == 'As Dependent':
dupop = DB.ViewDuplicateOption.AsDependent
dup_view_ids = duplicate_views(
selected_views,
with_detailing=True if selected_option == 'WITH Detailing'
else False)
selected_views,dupop)
if dup_view_ids:
revit.get_selection().set_to(dup_view_ids)
revit.get_selection().set_to(dup_view_ids)

0 comments on commit 6f0eb8e

Please sign in to comment.