Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Feature Request: command line interface #256

Closed
niclashoyer opened this issue May 7, 2019 · 5 comments
Closed

Feature Request: command line interface #256

niclashoyer opened this issue May 7, 2019 · 5 comments

Comments

@niclashoyer
Copy link

niclashoyer commented May 7, 2019

Provide a command line interface to automate creation of BOM, gerber export or DRC.

I tried to automate KiCad (which has no real CLI) and resorted to a docker container running xvfb which is a PITA and breaks continuously.

@carrotIndustries
Copy link
Member

I've though about this as well and it's certainly within the realms of possibility. One reason why we have no CLI yet is not having a clear idea of what it should be like:

  • Provide a limited set of features such as check drc, export pdf, etc accessible using command line args
  • Launch some sort of script interpreter that you'd tell to open the schematic and export the pdf (TCL would be the classical choice)
  • Create a python module (implemented in C/C++, calling into the horizon code) to the same as above:

From a programmer's perspective, having something based on python to achieve the latter would be preferable, but that doesn't package very well on windows.

Just writing from the top of my head of how that python thing could look like

>>> import horizon
>>> brd = horizon.load_board("path/to/project.hprj")
>>> settings = brd.get_fab_output_settings() #returns the fab output settings serialized to a dict
>>> #do something with the settings
>>> brd.export_gerber(settings)

Since windows users probably aren't interested in that kind of feature at all, the packaging issues are acceptable from my perspective.

@niclashoyer
Copy link
Author

If the python interface is simple to use, that would be the best idea. But if you take KiCad as an example, which also has a python interface for the board designer, it gets complicated quickly, even for simple tasks as checking DRC. There are even blogs just about kicad scripting. There are a lot of python scripts out there for KiCad, but most of them are unmaintained, don't do what the actually should do, or reinvent the wheel. Of course one can do fancy stuff with that (e.g. generative board outlines), but for simple tasks this might be too much.

Maybe a limited CLI and a scripting interface is orthogonal, so it may be good to have both. From an CI perspective you'd just want to check the rules, convert schematic to pdf, export BOM, convert the board(s) to gerber/pdf.

@carrotIndustries
Copy link
Member

If the python interface is simple to use, that would be the best idea.
Maybe a limited CLI and a scripting interface is orthogonal

I'm not planning on exposing all of horizon's guts in a python module. That module will just provide features similar to the ones you mentioned.

@carrotIndustries
Copy link
Member

5bc72b4 adds a python module that allows for exporting BOM and PDF

run make horizon.so to build the module

Usage:

import sys
sys.path.append(".")
import horizon
p=horizon.Project("/path/to/project.hprj")
sch = p.open_top_schematic()

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

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

@carrotIndustries
Copy link
Member

closing since the pyhon modules now also does DRC

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants