It looks like you're new here. If you want to get involved, click one of these buttons!
Dear All,
I find difficulty in reading the GDS through the command line to extract the used GDS layer numbers, may I have your support pls, Kindly let m eknow
Command
klayout -b -r code1bk.py -rd input=/home/vlsicad3/CAD_VERF/DRYRUN_15Nov/TA.gds
Error: No GDS file specified. Run with '-rd input=/home/vlsicad3/CAD_VERF/DRYRUN_15Nov/TA.gds'.
CODE:
# Import pya (KLayout Python API)
import pya
import sys
# Print sys.argv for debugging
print("Command-line arguments received:", sys.argv)
# Check command-line arguments directly for the GDS file path
input_gds = None
for arg in sys.argv:
if arg.startswith("input="):
input_gds = arg.split("=")[1]
# Debugging message to verify input_gds
if not input_gds:
print("Error: No GDS file specified. Run with '-rd input=/home/vlsicad3/CAD_VERF/DRYRUN_15Nov/TA.gds'.")
sys.exit(1)
else:
print(f"Using GDS file path: {input_gds}")
# Create a new layout and load the specified GDS file
ly = pya.Layout()
ly.read(input_gds)
# Specify the output text file path
output_file = "/home/vlsicad3/CAD_VERF/DRYRUN_15Nov/layer_info.txt" # Update with your desired path
# Gather, sort, and filter layers
layers = sorted([str(l) for l in ly.layer_infos() if l])
# Write layer information to the file
with open(output_file, "w") as f:
f.write("Layers in Layout:\n")
for layer in layers:
f.write(layer + "\n")
print(f"Layer information has been written to {output_file}")
print(f"Processed GDS file path: {input_gds}")
Comments
Attached the code FYR
Hi Kumaran,
First, please
I modified your original code in two ways:
code1.py
--> to run the klayout main GUI executable in batch mode (as you tried).code2.py
--> to use the KLayout Python Module (https://www.klayout.org/klayout-pypi/).Both generated the identical layer information.:
However, I prefer to
code2.py
.Dear sekigawa,
Thanks for the prompt response, i did a few enhancements to setenv for the GDS and I run the code,
But my concern,
Say,
how can I extract the used layer file of 1.gds from TOP.GDSfrom INPUT_GDS2 , and compare the output file of 1.gds and the output file of TOP.gds(which should extract the used layer only of the 1.gds)
May I have your guidance pls
A code block should have been looked like this.
Please attach the tidy code.
BTW, can you provide a dummy data set for
"INPUT_GDS1", "INPUT_GDS2", and "ET_CSV"
?If my understanding is correct, you
If the above is OK, I can prepare a dummy data set.
Please confirm.
Again, please fix the code block in the post above so other visitors can read it quickly and correctly.
Cont.
Assuming that my above understanding is OK, I wrote
code3.py
for this problem.Some changes from your code include:
pandas
module instead ofcsv
.@sekigawa Thanks for your competent support!
I took the liberty and my admin power to reformat the code of @Kumaran above for readability. @Kumaran: put a single line with three backticks before and after the code to make it formatted as code.
Matthias