From a6a247589c66d155f015e3ee9fb52dbb3ab66592 Mon Sep 17 00:00:00 2001 From: Jean-Marc Couffin Date: Thu, 30 Jun 2022 14:41:52 +0200 Subject: [PATCH] Tool to delete Arrowheads Types - Bazooka Style --- .../bundle.yaml | 7 +++ .../script.py | 43 +++++++++++++++++++ .../Project.panel/Wipe.pulldown/bundle.yaml | 3 +- 3 files changed, 52 insertions(+), 1 deletion(-) create mode 100644 extensions/pyRevitTools.extension/pyRevit.tab/Project.panel/Wipe.pulldown/Wipe Arrowheads Types.pushbutton/bundle.yaml create mode 100644 extensions/pyRevitTools.extension/pyRevit.tab/Project.panel/Wipe.pulldown/Wipe Arrowheads Types.pushbutton/script.py diff --git a/extensions/pyRevitTools.extension/pyRevit.tab/Project.panel/Wipe.pulldown/Wipe Arrowheads Types.pushbutton/bundle.yaml b/extensions/pyRevitTools.extension/pyRevit.tab/Project.panel/Wipe.pulldown/Wipe Arrowheads Types.pushbutton/bundle.yaml new file mode 100644 index 000000000..2db4a1ce9 --- /dev/null +++ b/extensions/pyRevitTools.extension/pyRevit.tab/Project.panel/Wipe.pulldown/Wipe Arrowheads Types.pushbutton/bundle.yaml @@ -0,0 +1,7 @@ +title: + fr_fr: Supprimer les têtes de flèches de manière radicale + en_us: Delete ArrowHeads type - Bazzoka style +tooltip: + fr_fr: Supprimer les têtes de flèches de manière radicale + en_us: Delete ArrowHeads type - Bazzoka style +highlight: new \ No newline at end of file diff --git a/extensions/pyRevitTools.extension/pyRevit.tab/Project.panel/Wipe.pulldown/Wipe Arrowheads Types.pushbutton/script.py b/extensions/pyRevitTools.extension/pyRevit.tab/Project.panel/Wipe.pulldown/Wipe Arrowheads Types.pushbutton/script.py new file mode 100644 index 000000000..79f3e0add --- /dev/null +++ b/extensions/pyRevitTools.extension/pyRevit.tab/Project.panel/Wipe.pulldown/Wipe Arrowheads Types.pushbutton/script.py @@ -0,0 +1,43 @@ +# -*- coding: utf-8 -*- +from pyrevit import revit, script, DB, forms + +doc = revit.doc + +# takes care of closing previous output windows +output = script.get_output() +output.close_others() + +arrowhead_types, arrowhead_types_names, deleted, not_deleted = [], [], '','' + +# collect arrowhead types +element_types = DB.FilteredElementCollector(doc).OfClass(DB.ElementType).WhereElementIsElementType() + +for element_type in element_types: + # check if element type is arrowhead + if element_type.get_Parameter(DB.BuiltInParameter.ARROW_CLOSED) and element_type.get_Parameter(DB.BuiltInParameter.SYMBOL_NAME_PARAM).AsString()!='': + # collect arrowhead types and arrowhead types names separately + arrowhead_types_names.append(element_type.get_Parameter(DB.BuiltInParameter.SYMBOL_NAME_PARAM).AsString()) + arrowhead_types.append(element_type) + +# The selection form +selection = forms.SelectFromList.show(arrowhead_types_names, 'Select arrowhead types you wand to delete', multiselect = True, infopanel = 'Select arrowhead type you wish to delete') + +# checking if there is a selection +if selection: + with revit.Transaction('Delete Arrowheads'): + # get arrowhead_type from arrowhead_types_names selected + for e_name, e_type in zip(arrowhead_types_names, arrowhead_types): + if e_name in selection: + try: + # delete arrowhead_type + doc.Delete(e_type.Id) + deleted = deleted + '- ' + e_name + '\n' + except: + # not deleted - BECASUE YOU CANNOT DELETE ALL OF THEM + not_deleted = not_deleted + '- ' + e_name + '\n' + # show results + output.set_width(200) + output.print_md('#Deleted arrowheads: \n{}\n'.format(deleted)) + output.print_md('#Not deleted arrowheads: \n{}\n'.format(not_deleted)) +else: + script.exit() \ No newline at end of file diff --git a/extensions/pyRevitTools.extension/pyRevit.tab/Project.panel/Wipe.pulldown/bundle.yaml b/extensions/pyRevitTools.extension/pyRevit.tab/Project.panel/Wipe.pulldown/bundle.yaml index 8422237da..4317ba007 100644 --- a/extensions/pyRevitTools.extension/pyRevit.tab/Project.panel/Wipe.pulldown/bundle.yaml +++ b/extensions/pyRevitTools.extension/pyRevit.tab/Project.panel/Wipe.pulldown/bundle.yaml @@ -12,4 +12,5 @@ layout: - Wipe SubCategories - Wipe Unused Filters - Wipe Unused View Templates - - Wipe Empty Elevation Tags \ No newline at end of file + - Wipe Empty Elevation Tags + - Wipe Arrowheads Types \ No newline at end of file