initial commit

This commit is contained in:
jan 2025-04-10 18:05:47 -07:00
commit 16e21939a9
3 changed files with 94 additions and 0 deletions

19
grain.xml Normal file
View File

@ -0,0 +1,19 @@
<?xml version="1.0" encoding="utf-8"?>
<salt-grain>
<name>layers_context_toolbox</name>
<token/>
<hidden>false</hidden>
<version>1.0</version>
<api-version/>
<title>Layers context toolbox</title>
<doc>Adds items to the "Layers" pane context menu: "Change Layer of Objects", "Make All Valid"</doc>
<doc-url/>
<url/>
<license>GPLv3</license>
<author>Jan Petykiewicz</author>
<author-contact>jan@mpxd.net</author-contact>
<authored-time/>
<installed-time>2025-04-10T16:58:24</installed-time>
<icon/>
<screenshot/>
</salt-grain>

37
pymacros/change_layer.lym Normal file
View File

@ -0,0 +1,37 @@
<?xml version="1.0" encoding="utf-8"?>
<klayout-macro>
<description>add "Change Layer of Selection" to layer context menu</description>
<version/>
<category>pymacros</category>
<prolog/>
<epilog/>
<doc/>
<autorun>true</autorun>
<autorun-early>false</autorun-early>
<priority>5</priority>
<shortcut/>
<show-in-menu>false</show-in-menu>
<group-name/>
<menu-path>@lcp_context_menu.end</menu-path>
<interpreter>python</interpreter>
<dsl-interpreter-name/>
<text>"""
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)</text>
</klayout-macro>

View File

@ -0,0 +1,38 @@
<?xml version="1.0" encoding="utf-8"?>
<klayout-macro>
<description>add "Set All Valid" to layer context menu</description>
<version/>
<category>pymacros</category>
<prolog/>
<epilog/>
<doc/>
<autorun>true</autorun>
<autorun-early>false</autorun-early>
<priority>3</priority>
<shortcut>Ctrl+Shift+V</shortcut>
<show-in-menu>false</show-in-menu>
<group-name/>
<menu-path>@lcp_context_menu.end</menu-path>
<interpreter>python</interpreter>
<dsl-interpreter-name/>
<text>"""
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)</text>
</klayout-macro>