Sample Files
Introducing sample Python script files.
Download all sample files here.
Sample 1: Boolean result to PDF
This script executes boolean (sub, or) operation on the specified layers, and then the result is output as a PDF.
Download here. (boolean_pdf_out.py)
# Open the file with rotate
input_data = "/path/to/input"
rotate = 90
input = pynebv.file.open(input_data, opts={"rotate":rotate})
# Get layer
layer_1 = input.layer(1)
layer_2 = input.layer(2)
layer_3 = input.layer(3)
# Get outline before boolean operation
outlined = True
# Boolean (sub)
sub_target ={"itemList":layer_2, "outline":outlined}
sub_result = pynebv.figure.boolean(layer_1, outlined, subtrahend=sub_target, operation='SUB')
# Boolean (or)
or_result = pynebv.figure.boolean([sub_result, layer_3], outlined, operation="OR")
# Close unnecessary files
input.close()
sub_result.close()
# Output PDF from screen
output_name = "output.pdf"
paper_size = "A4"
resolution = 800
scale_type = "Fit Paper Size" # "Full Scale" or "Fit Paper Size"
with_header = True
pynebv.screen.plot(output_name, outputType="PDF", sheet=paper_size, reso=resolution, scaleType=scale_type, withHeader=with_header)
Sample 2: Calculate density per layer
This script calculates the density of a specified range per layer for all layers.
Download here. (calc_density_per_layer.py)
# Specify the following
filepath = "/path/to/input"
calc_area = (0,0,10,10)
# Open file and get layers
input = pynebv.file.open(filepath)
layers = input.layers()
# Hide all layers once
for layer in layers:
layer.display = False
# Calculate density for each layer
print("Input Data : " + filepath)
print("Calculation Area : " + str(calc_area))
print("-------------------")
for layer in layers:
layer.display = True
density = pynebv.calculation.density(calc_area)
density_val = density.props()['Density']
layno = layer.name
print(layno + " : " + density_val + "%")
layer.display = False
print("-------------------")
Sample 3: Print information of top cells
This script prints the name, contained layers, and cell size of all top cells in the opened files.
Download here. (print_topcell_info.py)
# Get the list of files and iterate through each file
file_list = pynebv.file.list()
for file in file_list :
print("Input file : " + file.file_path)
# Iterate through all descendants in the file
for top_cell in file.descendants():
if not isinstance(top_cell, pynebv.TopCell):
continue
# Output the top cell name, layer numbers, and cell area size
print("MAIN " + top_cell.name)
layers = [str(layer.name.replace(" ", "").replace("L", "")) for layer in top_cell.layers()]
print("LAYNO " + ", ".join(layers))
print("SIZE " + ", ".join(map(str, top_cell.area)))
Last modified March 13, 2026