diff --git a/extensions/pyRevitTools.extension/pyRevit.tab/Selection.panel/Close Views.pushbutton/bundle.yaml b/extensions/pyRevitTools.extension/pyRevit.tab/Selection.panel/Close Views.pushbutton/bundle.yaml new file mode 100644 index 000000000..90a23afc5 --- /dev/null +++ b/extensions/pyRevitTools.extension/pyRevit.tab/Selection.panel/Close Views.pushbutton/bundle.yaml @@ -0,0 +1,8 @@ +tooltip: Close everything but the selected views. +title: >- + Close + + Tabs +authors: + - thumDer + - Johannes Domeier diff --git a/extensions/pyRevitTools.extension/pyRevit.tab/Selection.panel/Close Views.pushbutton/icon.png b/extensions/pyRevitTools.extension/pyRevit.tab/Selection.panel/Close Views.pushbutton/icon.png new file mode 100644 index 000000000..299335866 Binary files /dev/null and b/extensions/pyRevitTools.extension/pyRevit.tab/Selection.panel/Close Views.pushbutton/icon.png differ diff --git a/extensions/pyRevitTools.extension/pyRevit.tab/Selection.panel/Close Views.pushbutton/script.py b/extensions/pyRevitTools.extension/pyRevit.tab/Selection.panel/Close Views.pushbutton/script.py new file mode 100644 index 000000000..f52973c61 --- /dev/null +++ b/extensions/pyRevitTools.extension/pyRevit.tab/Selection.panel/Close Views.pushbutton/script.py @@ -0,0 +1,25 @@ +"""Close selected views.""" +from pyrevit import forms, revit + +doc = revit.doc +uidoc = revit.uidoc + +uiviews = uidoc.GetOpenUIViews() +views = [doc.GetElement(uiview.ViewId) for uiview in uiviews] + +list_items = [forms.ViewOption(view) for view in views] + +views_to_keep = forms.SelectFromList.show(list_items, + multiselect=True, + title='Select views to keep open') + +if not views_to_keep: + script.exit() + +uiviews_to_close = filter( + lambda x: x.ViewId.IntegerValue not in \ + [view.Id.IntegerValue for view in views_to_keep], + uiviews) + +for uiview in uiviews_to_close: + uiview.Close() diff --git a/extensions/pyRevitTools.extension/pyRevit.tab/Selection.panel/bundle.yaml b/extensions/pyRevitTools.extension/pyRevit.tab/Selection.panel/bundle.yaml index ab2d1b396..eaeefe5b3 100644 --- a/extensions/pyRevitTools.extension/pyRevit.tab/Selection.panel/bundle.yaml +++ b/extensions/pyRevitTools.extension/pyRevit.tab/Selection.panel/bundle.yaml @@ -1,6 +1,7 @@ layout: - Pick + - Close Tabs - Set Workset - select - mema - - memo \ No newline at end of file + - memo