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
- cam_azimuth: float¶
Camera azimuth angle in degrees
- cam_elevation: float¶
Camera elevation angle in degrees
- cam_fov: float¶
Camera field of view in degrees
- cam_distance: float¶
Camera distance in millimeters
- center_x: float¶
Where the camera looks at (millimeter)
- center_y: float¶
Where the camera looks at (millimeter)
- background_top_color: 3-tuple of float¶
Background color at the top, components range from 0 to 1
- background_bottom_color: 3-tuple of float¶
Background color at the bottom, components range from 0 to 1
- solder_mask_color: 3-tuple of float¶
Solder mask color, components range from 0 to 1
- substrate_mask_color: 3-tuple of float¶
Color of the PCB body, components range from 0 to 1
- ortho: bool¶
Use orthographic projection
- show_models: bool¶
Show 3D models
- show_silkscreen: bool¶
- show_solder_mask: bool¶
- show_solder_paste: bool¶
- show_substrate: bool¶
- use_layer_colors: bool¶
Use layer colors from 2D view for copper layers