svg and png conversion moved to docs

This commit is contained in:
Matt Venn
2023-02-22 10:40:43 +01:00
parent 7f3d197c4d
commit 77a0b2db7d
3 changed files with 22 additions and 0 deletions
+13
View File
@@ -2,6 +2,9 @@ import logging
import re import re
import subprocess import subprocess
import os import os
import glob
import gdstk
import cairosvg
# documentation # documentation
@@ -57,3 +60,13 @@ def create_pdf(yaml):
p = subprocess.run(pdf_cmd, shell=True) p = subprocess.run(pdf_cmd, shell=True)
if p.returncode != 0: if p.returncode != 0:
logging.error("pdf command failed") logging.error("pdf command failed")
def create_svg(args):
gds = glob.glob(os.path.join(args.run_dir, 'results/final/gds/*gds'))
library = gdstk.read_gds(gds[0])
top_cells = library.top_level()
top_cells[0].write_svg('gds_render.svg')
if args.create_png:
cairosvg.svg2png(url='gds_render.svg', write_to='gds_render.png')
+4
View File
@@ -0,0 +1,4 @@
gdstk
cairosvg
requests
yaml
+5
View File
@@ -24,6 +24,8 @@ if __name__ == '__main__':
# documentation # documentation
parser.add_argument('--create-project-pdf', help="create a single page PDF", action="store_const", const=True) parser.add_argument('--create-project-pdf', help="create a single page PDF", action="store_const", const=True)
parser.add_argument('--create-svg', help="create a svg of the GDS layout", action="store_const", const=True)
parser.add_argument('--create-png', help="create a png of the GDS layout", action="store_const", const=True)
# configure # configure
parser.add_argument('--create-user-config', help="create the user_config.tcl file with top module and source files", action="store_const", const=True) parser.add_argument('--create-user-config', help="create the user_config.tcl file with top module and source files", action="store_const", const=True)
@@ -67,5 +69,8 @@ if __name__ == '__main__':
elif args.create_project_pdf: elif args.create_project_pdf:
documentation.create_pdf(project_yaml) documentation.create_pdf(project_yaml)
elif args.create_svg or args.create_png:
documentation.create_svg(args)
else: else:
parser.print_help() parser.print_help()