From 16e21939a9e72492b0900d9f1b455f80fe86b48d Mon Sep 17 00:00:00 2001 From: jan Date: Thu, 10 Apr 2025 18:05:47 -0700 Subject: [PATCH] initial commit --- grain.xml | 19 +++++++++++++++++++ pymacros/change_layer.lym | 37 +++++++++++++++++++++++++++++++++++++ pymacros/set_all_valid.lym | 38 ++++++++++++++++++++++++++++++++++++++ 3 files changed, 94 insertions(+) create mode 100644 grain.xml create mode 100644 pymacros/change_layer.lym create mode 100644 pymacros/set_all_valid.lym diff --git a/grain.xml b/grain.xml new file mode 100644 index 0000000..b7f5f9e --- /dev/null +++ b/grain.xml @@ -0,0 +1,19 @@ + + + layers_context_toolbox + + false + 1.0 + + Layers context toolbox + Adds items to the "Layers" pane context menu: "Change Layer of Objects", "Make All Valid" + + + GPLv3 + Jan Petykiewicz + jan@mpxd.net + + 2025-04-10T16:58:24 + + + diff --git a/pymacros/change_layer.lym b/pymacros/change_layer.lym new file mode 100644 index 0000000..e2d16c6 --- /dev/null +++ b/pymacros/change_layer.lym @@ -0,0 +1,37 @@ + + + add "Change Layer of Selection" to layer context menu + + pymacros + + + + true + false + 5 + + false + + @lcp_context_menu.end + python + + """ +Add "Change Layer of Objects" to Layer context menu + +Roughly follows method from https://www.klayout.de/forum/discussion/192/fill-klayout-dialogs-from-rba +""" +import pya + +mw = pya.Application.instance().main_window() +menu = mw.menu() + +change_layer_action = menu.action('edit_menu.selection_menu.change_layer') +change_layer_action.trigger + +new_action = pya.Action() +new_action.title = 'Change Layer of Objects' +new_action.on_triggered = change_layer_action.trigger + +menu.insert_separator('@lcp_context_menu.end', 'tb_separator') +menu.insert_item('@lcp_context_menu.end', 'change_layer', new_action) + diff --git a/pymacros/set_all_valid.lym b/pymacros/set_all_valid.lym new file mode 100644 index 0000000..e014da5 --- /dev/null +++ b/pymacros/set_all_valid.lym @@ -0,0 +1,38 @@ + + + add "Set All Valid" to layer context menu + + pymacros + + + + true + false + 3 + Ctrl+Shift+V + false + + @lcp_context_menu.end + python + + """ +Add "Change Layer of Objects" to Layer context menu +""" +import pya + + +def set_all_valid(): + view = pya.LayoutView.current() + for layer in view.each_layer(): + layer.valid = True + layer.visible = True + +mw = pya.Application.instance().main_window() +menu = mw.menu() + +new_action = pya.Action() +new_action.title = 'Set All Valid' +new_action.on_triggered = set_all_valid + +menu.insert_item('@lcp_context_menu.invvalid', 'change_layer', new_action) +