Last active
November 8, 2024 13:35
-
-
Save sequoiap/48af5f611cca838bb1ebc3008eef3a6e to your computer and use it in GitHub Desktop.
How to take a screenshot/image of a GDS file with colors defined by a layer properties file using the Klayout Python API.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
""" | |
Example taken from https://www.klayout.de/forum/discussion/2246/clip-gds-to-image | |
This example images the full GDS and saves it to some shape specified. | |
""" | |
from klayout import lay | |
in_file = "path/to/some.gds" | |
out_file = "out.png" | |
layer_file = "path/to/some/layers.lyp" | |
# Set display configuration options | |
lv = lay.LayoutView() | |
lv.set_config("background-color", "#ffffff") | |
lv.set_config("grid-visible", "false") | |
lv.set_config("grid-show-ruler", "false") | |
lv.set_config("text-visible", "false") | |
# Load the GDS and layer files | |
lv.load_layout(in_file, 0) | |
lv.load_layer_props(layer_file) | |
lv.max_hier() | |
# Important: event processing for delayed configuration events | |
# Here: triggers refresh of the image properties | |
lv.timer() | |
# Save the image | |
lv.save_image(out_file, 600, 400) | |
# lv.save_image_with_options(out_file, w, h, 0, 0, 0, db.DBox(x1, y1, x2, y2), False) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment