KLayout Visual Capture
Save the current KLayout layout to a temporary GDS file, convert it to PNG, and return both file paths for visual inspection.
Prerequisites
- KLayout running with KlayoutClaw plugin (v0.3+)
- A layout with geometry must be open
- Python packages:
gdstk,matplotlib,numpy(available in theinstrMCPdevconda env)
Script
capture.py 鈥?Capture layout as PNG
python scripts/capture.py [--output path.png] [--gds path.gds] [--dpi 200]
--output鈥?PNG output path. If the user has a working directory or stack path, save there instead of/tmp.--gds鈥?GDS output path. Same rule: prefer the user's working directory over/tmp.--dpi鈥?Image resolution (default: 200)
Returns the paths to both the GDS and PNG files, printed to stdout.
Example:
python scripts/capture.py
# Output:
# GDS saved: /tmp/klayoutclaw_capture.gds
# PNG saved: /tmp/klayoutclaw_capture.png
How It Works
- Calls
save_layoutvia MCP to write the current layout to a temp GDS file - Runs
tools/gds_to_image.pyfrom the KlayoutClaw repo to convert GDS to PNG - Prints both file paths
The GDS-to-PNG conversion uses gdstk to parse the GDS and matplotlib to render all layers with distinct colors and a legend.
After Capture
Use the Read tool on the PNG path to view the image directly in the conversation. This gives immediate visual feedback on layout geometry.