I asked ChatGPT, it answered a wrong script like this:
import pya
# Open the GDS file
layout = pya.Layout()
layout.read("pnl.gds")
# Specify the layer number you want to visualize
target_layer = 10
# Find all shapes on the target layer
shapes = layout.each_shape_on_layer(pya.LayerInfo(target_layer))
# Set color and stipple properties
for shape in shapes:
shape.presentation().fill_color = pya.Color(0, 0, 0) # Black color
shape.presentation().fill_pattern = pya.FillPattern.FillFilledStipple
# Specify the image file path
image_path = "output_image.png"
# Export the image
layout_view = layout.view()
layout_view.save_image(image_path)
Please tell me how to make it right?
A way that fill the gap which pya.FillPattern
should have done.
The answer is in this thread
layout_view = pya.LayoutView()
layout_view.load_layout(gds_path)
layout_view.max_hier()
layout_view.set_config("background-color", "#ffffff")
layout_view.set_config("grid-show-ruler", "false")
layout_view.set_config("grid-visible", "false")
for lyp in layout_view.each_layer():
lyp.fill_color = 0
lyp.frame_color = 0
lyp.dither_pattern = 0
if lyp.layer_index() in [4]:
lyp.visible = False
layout_view.update_content()
Thanks to @s910324!