Python module

Parts of Horzion EDA are available as a python module for use in scripts.

Installation

The python module isn’t included in the all target. To build it, run make build/horizon.so. This requires the python 3 headers to be installed. You can then place it in python’s sys.path and import it using import horizon.

Usage

import horizon

#open project
p=horizon.Project("/path/to/project.hprj")

#open schematic
sch = p.open_top_schematic()

#export PDF
pdf_settings = sch.get_pdf_export_settings()
pdf_settings['output_filename'] = '/tmp/sch.pdf'
sch.export_pdf(pdf_settings)

#export BOM
bom_settings = sch.get_bom_export_settings()
bom_settings['output_filename'] = '/tmp/bom.csv'
sch.export_bom(bom_settings)

#open board
brd = p.open_board()

#export gerber
gerber_settings = brd.get_gerber_export_settings()
gerber_settings["output_directory"] = "/tmp/gerber"
brd.export_gerber(gerber_settings)

#export pick&place
pnp_settings = brd.get_pnp_export_settings()
pnp_settings["output_directory"] = "/tmp/pnp"
brd.export_pnp(pnp_settings)

#export STEP
step_settings = brd.get_step_export_settings()
step_settings["filename"] = "/tmp/pca.step"
brd.export_step(step_settings)

#run DRC
rules=brd.get_rules()
#modify rules if needed
rule_ids = brd.get_rule_ids()
#if needed, remove unneeded checks from rule_ids
result = brd.run_checks(rules, ids)

#export 3D rendering (see next section)
exporter = brd.export_3d(1920, 1080) #width, height
exporter.view_all()
exporter.load_3d_models() #optional
exporter.render_to_png("brd.png")

To further adjust the export settings, have a look at the dicts returned by the get_*_export_settings methods.

3D rendering usage

use brd.export_3d(1920, 1080) or similar to get an Image3DExporter object

class Image3DExporter
render_to_png(filename)

Render to png image

render_to_surface()

Render to pycairo surface

Return type:cairo.Surface
load_3d_models()

Loads 3D models if available

view_all()

Resets view to top side