Skip to content

Instantly share code, notes, and snippets.

@urish
Created October 18, 2023 08:51
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save urish/ed306950fcc5374f7aeb4a881b942e84 to your computer and use it in GitHub Desktop.
Save urish/ed306950fcc5374f7aeb4a881b942e84 to your computer and use it in GitHub Desktop.
Compare two GDS files using klayout scripting
# Usage:
# klayout -b -r compare.py -rd gds1=file1.gds -rd gds2=file2.gds
import sys
import pya
def compare_gds(file1, file2):
diff = pya.LayoutDiff()
# Load the layouts
layout1 = pya.Layout()
layout1.read(file1)
layout2 = pya.Layout()
layout2.read(file2)
# Check if the layouts are identical
return diff.compare(layout1, layout2)
if __name__ == "__main__":
if compare_gds(gds1, gds2):
print(f"{gds1} and {gds2} are identical.")
sys.exit(0)
else:
print(f"{gds1} and {gds2} are different.")
sys.exit(-1)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment