Gschem is an open-source tool for drawing circuit diagrams. (And then go on to simulate the circuits or lay out a circuit board.) LyX can be used for documentation.

Gschem comes with a converter (gaf) for eps and pdf, so it was easy to add support through the external vector graphics inset. No changes to LyX source, only "preferences" and "external_templates"

"preferences" needs these file formats and converters:

\format "gschem" "sch" "Gschem schematic" "" "" "gschem" "vector" "application/x-geda-schematic" \format "gschem-sym" "sym" "Gschem symbol" "" "" "gschem" "vector" "application/x-geda-symbol"
\converter "gschem" "pdf6" "gaf export -o $$o -k 10 -m 1mm $$i" ""
\converter "gschem" "eps" "gaf export -o $$o -k 10 -m 1mm $$i" ""
\converter "gschem-sym" "eps" "gaf export -o $$o -k 10 -m 1mm $$i" ""
\converter "gschem-sym" "pdf6" "gaf export -o $$o -k 10 -m 1mm $$i" ""

The two formats are the same, but have a different filename ending. So it seems two formats are needed.

The converter can make eps and pdf for both formats, hence 4 converters. Conversions to svg, png jpg and ps is also possible, but I am not sure any of those are needed for LyX?

Updating "preferences" allows conversion of such files when entered into the external inset. The files are then previewed in LyX, they appear in output, and LyX can start gschem for external editing.

"external_templates" also need a patch to recognize .sym and .sch files:

--- /usr/share/lyx/external_templates    2017-05-17 17:31:22.000000000 +0200
+++ external_templates    2017-06-14 15:13:29.062668373 +0200
@@ -183,7 +183,7 @@
     InputFormat "*"
     # Globbing pattern used when browsing for a vector graphics file.
# xfig, dia, fen and ly are exlcuded, since we have specialized templates
-    FileFilter "*.{agr,dot,emf,eps,odg,obj,sxd,svg,svgz,tgo,pdf,wmf}"
+ FileFilter "*.{agr,dot,emf,eps,odg,obj,sxd,svg,svgz,tgo,pdf,wmf,sch,sym}"
     AutomaticProduction true
     # LyX has hard-coded support for these transformations
     Transform Rotate

I have tested these exports: postscript, dvi, PDF(dvipdfm), PDF(XeTeX), PDF(LuaTeX), PDF(pdflatex), and PDF(ps2pdf). All produced files with embedded circuit diagrams. Please tell if more work is needed before it may be included into LyX.

Helge Hafting

Reply via email to