サンプルファイル
Python スクリプトのサンプルファイルをご紹介します。
サンプル 1: Boolean 結果を PDF 出力
指定したレイヤに対して Boolean (sub, or) 演算を行い、or の結果を PDF として出力するスクリプトです。
こちらからダウンロード (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)
サンプル 2: レイヤごとの密度を計算
全レイヤに対し、指定範囲の図形密度をレイヤごとに計算するスクリプトです。
こちらからダウンロード (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("-------------------")
サンプル 3: トップセルの情報を表示
開いているファイルの全トップセルについて名前・保持しているレイヤ・セルサイズを出力するスクリプトです。
こちらからダウンロード (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)))
最終更新 13.03.2026