Web Viewing of KiCAD Files

This is a question about what features the community would want to see in a web viewer for KiCAD files.

I’ve been using the STEMN beta for about a month, and I’m really liking it. It’s a way to share and collaborate on hardware projects online that uses Dropbox or Google Drive to keep files in sync.

https://dev.stemn.com/

They have in-browser rendering for many file types, and they’re currently discussing how to support more open source file formats: FreeCAD, KiCAD, etc. The EDA renderer is also up for a possible rework. If you scroll down to the 4th comment on this thread you’ll start to see the discussion that sparked this post. There’s also a separate feature request for KiCAD support here.

I’m interested in KiCAD file support in STEMN because one of my projects relies on KiCAD. However, I’m new to KiCAD, so I don’t know what features would be best in a viewer. There’s an online service called eyrie.io that seems to have a good web viewer that supports KiCAD, but again, I’m a newbie (to KiCAD and electronics design in general).

So that leads me to a few questions.

  1. Are people interested in web viewing/rendering of their KiCAD files?
  2. Are there already open source web viewers and/or parsers out there for KiCAD? I found a couple by Googling, but they seem to just be experiments.
  3. What views does a web viewer need to show from the file(s) (schematic, pcb, 3D)?
  4. What features do you feel are most important (mouse interactivity, layer handling, etc)?
  5. How many different versions of the KiCAD file format are there? Are they all backwards-compatible?
2 Likes

Id plot the schematics and/or PCB to svg format. Then it should be easy to compare different versions. GitHub does offer online SVG diff tool.

For PCB to svg all you need is a PCBnew, as all footprints are already part of the PCB file.

For schematics you need also need cache file, and you need to tweak the schematics file to force eeSchema to read from cache first.

Both of these should be doable from console (thus can bi scripted) but I’ve never used console interface to eeSchema or PCBnew. I just heard that it exists.

1 Like

There is another tool, at least for schematics. It is not web-based, though.

https://neo900.org/stuff/eeshow/

It would be useful to have a piece of Javascript to display a KiCAD schematic in the browser. Convert it to SVG and let the browser render the SVG. Great for discussion forums. Textbooks and how-to articles could use them. Github should have a viewer for them.

Board layout display isn’t as useful. People discuss and exchange schematics. Board design files go to the fab shop, and if there are problems, you need full EDA tools to deal with them. If you just want to show a board, you post an image.

2 Likes

eyrie is already pretty good displaying kicad boards, even very complex ones

It looks like stemn could handle the 3D assembly of a board, which eyrie doesn’t since its no easy task.

1 Like

Thanks for the information everyone. I think I’ll start looking into what it would take to script the conversion of schematics to SVG.

This might help:
http://scottbezek.blogspot.si/2016/04/automated-kicad-schematic-export.html

https://scottbezek.blogspot.si/2016/04/scripting-kicad-pcbnew-exports.html

1 Like

Awesome, thanks @MitjaN

There is this project too which does some clever plotting of a visual diff to pngs between schematic revisions.

1 Like

It seems that somebody was already working on eeschema and pcbnew command line interface, but their work has not been included in the release versions.

https://lists.launchpad.net/kicad-developers/msg06052.html

I am mostly posting this as a starting point for anybody looking for this feature and since not finding it has the time and means to implement it.

1 Like

I experimented with UI automation and eeSchema (Scott Bezek’s blog post), and hit a major problem (for me anyway). UI automation will work in headless mode when a monitor is not installed, but not in a purely console-only environment. I suspected that when looking at the readme for Scott Bezek’s project, but I went ahead and tried it anyway.

I’m still working through the other links that have been posted, and will check out eeshow next.

You could try xvfb:

1 Like

I actually had to install xvfb to get the script to run. The script is supposed to handle running xvfb, but I also tried running it manually.

Xvfb :1 -screen 0 1600x1200x32

Maybe I’m just using xvfb wrong? I’ve tried several iterations of the command above, but I keep getting this:

Error: Can't open display: (null)

Sounds like maybe the DISPLAY environment variable isn’t getting set?

1 Like

Ah, remembered the DISPLAY environment variable after posting the last message.

export DISPLAY=":0.0"

After running this Xvfb line

Xvfb :0 -screen 0 1280x1024x32

I’m at least getting non-display related errors now.

@ppelleti I think you and I hit post at the same time. Thanks!

I’ll report back once I work through these other errors.

Here’s what I did to get the export_schematic.py script working on a headless Ubuntu 16.04 minimal VM.

1. sudo apt-get install kicad
2. sudo apt-get install xvfb
3. sudo apt-get install xdotool
4. sudo apt-get install imagemagick
5. Xvfb :0 -screen - 1280x1024x16&
6. export DISPLAY=":0.0"

Additionally, to run the generate_svg.py script that seems to export the PCB file, I had to install Inkscape.

7. sudo apt-get install inkscape

Next step is accepting an arbitrary file to convert. The existing scripts focus on the hardware project the scripts are embedded with.

1 Like

I’ve got a script working on Ubuntu Server 16.04 (headless, text-only) which will convert a .sch file to a .svg file.

However, the eeschema file that I create on my Ubuntu 16.04 desktop throws an error about the motors library not being present. I’ve included the version info for each eeschema installation below. My question is how should I set the Ubuntu server KiCAD installation up to minimize the problems that users would have doing a conversion? Are there standard libraries that I need to install? Do I need to force the server to run the latest version of KiCAD? Once this script is working well the next step will be to wrap it in a sample Node.js app so that it can be used as a web service. I’d like to have instructions on how to install KiCAD available so that as many users as possible will be covered.

Ubuntu Server 16.04:

Ubuntu Desktop 16.04:

The -cache.lib file should come along the .sch file. All you need to do is parse .sch files and place the -cache.lib as the topmost library. You should also add -cache.lib to .pro file at the top of the list. This way the eeschema will find all of the symbols. It might still complain about not finding the rest of the libraries.

1 Like

@MitjaN I’m showing my inexperience with KiCAD here. How do I place the *-cache.lib file as the “topmost library”? I tried creating a lib_sch directory and set the library search path as described in this Hack-a-day post.

When you talk about adding *-cache.lib to the .pro file, do mean adding it as the value for LibDir here in the text of the .pro file?

[eeschema]
version=1
LibDir=
[eeschema/libraries]
LibName1=power
LibName2=device
LibName3=switches
LibName4=relays
LibName5=motors

Or should there be a “LibName0” entry that points to the cache library file?