| #!/usr/bin/env python3 |
| import subprocess |
| import sys |
| import os |
| |
| from gds_to_lef_gds_mag import _magic_tcl_header, run_magic |
| |
| |
| def convert_to_svg(input_gds, input_techfile): |
| input_gds = os.path.abspath(input_gds) |
| input_techfile = os.path.abspath(input_techfile) |
| |
| destdir, gdsfile = os.path.split(input_gds) |
| |
| basename, ext = os.path.splitext(gdsfile) |
| |
| tcl_path = os.path.join(destdir, "{}.gds2svg.tcl".format(basename)) |
| with open(tcl_path, 'w') as ofile: |
| _magic_tcl_header(ofile, input_gds) |
| |
| ofile.write("load " + basename + "\n") |
| ofile.write("box 0 0 0 0\n") |
| ofile.write("select top cell\n") |
| ofile.write("expand\n") |
| ofile.write("view\n") |
| ofile.write("select clear\n") |
| ofile.write("box position -1000 -1000\n") |
| ofile.write("plot svg " + basename + ".svg\n") |
| ofile.write("quit -noprompt\n") |
| |
| output = run_magic(destdir, tcl_path, input_techfile, " XR") |
| output_svg = os.path.join(destdir, "{}.svg".format(basename)) |
| assert os.path.exists(output_svg), output_svg + " doesn't exist!?" |
| print("Created", output_svg) |
| |
| convert_to_svg(*sys.argv[1:]) |