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("-------------------")
Last modified April 16, 2025