Skip to content

Commit

Permalink
More informative exception and prevent non-deleted child instances
Browse files Browse the repository at this point in the history
  • Loading branch information
PietroCampana committed Jun 8, 2024
1 parent 109d7c4 commit 4452d41
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 5 deletions.
2 changes: 1 addition & 1 deletion klayout_package/python/kqcircuits/util/layout_to_code.py
Original file line number Diff line number Diff line change
Expand Up @@ -362,7 +362,7 @@ def extract_pcell_data_from_views():
Returns: a tuple (views, instances) where
views: a list of lists. Each element corresponds to a view in KLayout and it is a list of
``(type, location, parameters)`` tuples. These tuples completely describe the type, position
``(type, location, parameters)`` tuples. These tuples completely describe the type, position
and parameters of a single PCell in the "Top Cell" of this view.
instances: flattened list of all instances of KQCircuits PCells found.
"""
Expand Down
10 changes: 6 additions & 4 deletions klayout_package/python/scripts/macros/0system/0reload.lym
Original file line number Diff line number Diff line change
Expand Up @@ -41,12 +41,14 @@ from kqcircuits.util.library_helper import load_libraries
from kqcircuits.util.layout_to_code import extract_pcell_data_from_views, restore_pcells_to_views

views, instances = extract_pcell_data_from_views()
try:
load_libraries(flush=True)
except:
raise RuntimeError("Failed to reload KQCircuits libraries, keeping current views.")
for inst in instances:
inst.delete()
try:
load_libraries(flush=True)
except Exception as e:
restore_pcells_to_views(views)
raise RuntimeError("Failed to reload KQCircuits libraries and redraw cells." +
f"\nThe following exception was raised: \n{type(e).__name__}: {e}")
restore_pcells_to_views(views)
</text>
</klayout-macro>

0 comments on commit 4452d41

Please sign in to comment.