Printing Schematic To SVG -- Solved?

There are a lot of complaints about QSpice not directly supporting SVG. If I understand correctly PDF has SVG internally… (Edit: Maybe not SVG but definitely vector graphics.)

I used the built-in Windows print-to-PDF driver. When opened in Inkscape, the various “objects” can be selected and their properties can be adjusted. Sample below (strokes, sizes, etc., randomly changed):

Does this solve anyone’s problems?

–robert

2 Likes

Thanks for this post !!

My view of the situation is still the same as when I posted 6 months ago about this issue.

QSPICE still only supports exporting Schematic and Waveform by…

  • File → Print → Microsoft Print to PDF → PDF file
  • Right Click → Copy Bitmap to Clipboard

I still believe QSPICE needs a simple one-step method to export the schematic to each of the following file types without being forced to use 3rd party software to accomplish the task.

  • Export Schematic to SVG vector file as Color.
  • Export Schematic to SVG vector file as Monochrome (Black on White).
  • Export Schematic to PNG bitmap file as Color.
  • Export Schematic to PNG bitmap file as Monochrome (Black on White).
3 Likes

Well, for those who absolutely must generate *.svg directly, there’s this open source tool: ClawPDF. The install creates a printer driver (clawPDF) that can be configured to output a SVG file. I tried it and it works fine.

Of course, for those on a corporate network, you’ll probably need the techs to install it. Which, of course, they won’t want to do. Maybe you can convince them to buy/install a commercial product that does the same thing. Which, of course, they won’t want to do.

But for the rest of us, it’s an option.

–robert

1 Like

And here’s option #3 for those that could use Postscript files instead of SVG for vector graphics: Use the Microsoft PS printer driver. It’s not installed/enabled by default so you’ll need to set it up in Printer Settings.

–robert

Microsoft Print to PDF (*.pdf) and Microsoft XPS Document Writer (*.oxps) printer drivers work reasonably well. However, Adobe PDF (*.pdf) printer driver (if Acrobat, etc., is installed) in general provides superior quality because it turns the arcs and coils approximated by polylines in QSPICE into Bézier curves. Of course this will only work as long as QSPICE won’t switch to print bitmaps only…

As I understand it, the XPS stuff is vector graphics so, yeah, should work. But I’ve not found any programs that support opening/importing the files other than the Microsoft-supplied viewer. What are you using?

Not sure what that means. Could you elaborate?

–robert

Also only XPS Viewer. But the XML format is sometimes convenient to extract exact coordinates.

Since, currently, all drawing is implemented twice, once for the screen and once for printing, there are (or were) apparently considerations to consolidate the code (for more consistency and possible acceleration by the GPU) and generate bitmaps only.

Anyways, after that response I got bored with QSPICE. Maybe the workaround would be to convert the input files ourselves to vector formats (the values calculated by the simulation would possibly be missing then).

For those still motivated, it looks like (besides of the obvious GDI objects like ellipse and arc) the coil and arc3p objects are constructed as follows, where the coils could be reasonably well approximated with elliptical arcs (A in SVG paths) and the arc3ps would possibly need numerically fitted Bézier curves (C in SVG paths):

arc3p can be viewed as a degenerate Archimedean/arithmetic spiral (or mosquito coil or [toilet] paper [sc]roll) with turn < 1, and as an arc with constant radius if both arc points have the same distance to the center. coil is an orthographic projection of a helix with k = 2 instead of the usual √3. For zigzag, n = int(¾ y/x + 1) and d = y / 4n.

KiCad 8 (due within a month or so) will be able to import LTspice files, so it should probably be possible to adapt it to QSPICE files with these additional graphics primitives.

Thanks RDunn for the tip about ClawPDF printer driver. It does allow QSPICE to print to SVG, which I can view a schematic on 3 different web browsers, and Inkscape likes it too.

I still believe SVG exporting should be built-in to QSPICE to make it as easy as possible for all users.

3 Likes

this is the best way

1 Like

@ThalesPo thanks for sharing. FYI, I released this recently.

1 Like

Cool. My script allows symbol abstraction, so you can can change all symbols at once on InkScape, and does the curved shapes with cubic curves, so there are less nodes, yielding smaller files. Let me know if you know of any scripts to convert QSpice to KiCAD. If there aren’t any, I’ll be getting on my way to writing that. We will need that for producing PCBs. One important detail is that KiCAD allows for multiple symbols for a single footprint, like when you have multiple op-amps in a single chip, so we will have to invent language for that, to add the directives to QSpice schematics, telling KiCAD the footprint information. I know that KiCAD can open LTSpice schematics, so maybe I can get inspiration from that.

Sweet.

KiCad is on my radar. I’ve been mulling over whether to work on a QSpice → KiCad schematic converter, a KiCad ->QSpice schematic converter, or integrate QSpice64/80 as a simulator back-end for KiCad. It will be at least a few weeks before I can even begin researching. Hopefully, you’ll have it solved before I get around to it. :wink:

1 Like

@RDunn My thoughts are, running the simulations and generating schematics on QSpice, which is more powerful for that than KiCAD, and then exporting to KiCAD only to produce PCBs. I’ve ran a few tests and was able produce a few scrappy KiCAD schematics from QSpice files. A few months of work and I’m sure I can do that.

Bug report on your converter: If you open QSpice example file “TripleCompositeAmplifierwithCommon-emitterOutputStage.qsch” you will see that there are problems with the drawing order of the elements by your code.

Thanks. Fixed. (Now I type more text so that the forum will accept the response. :roll_eyes:)

1 Like

@RDunn Actually, still wrong. There are 3 different drawing orders: One for the symbol editor, one for the used symbol in the schematic and one for the shallowest schematic level->

SCHEMATIC_LEVEL_DRAWING_ORDER = [RECT, ELLIPSE, TRIANGLE, TAP, LINE, ARC, ARC3P, COIL, ZIGZAG, PIN, PINLABEL, WIRE, JUNCTION, TEXT, JUMPER, NET]
SYMBOL_INSTANCE_DRAWING_ORDER =[RECT, ELLIPSE, LINE, TAP, TRIANGLE, ARC3P, COIL, ZIGZAG, ARC, PIN, PINLABEL, WIRE, JUNCTION, TEXT, JUMPER, NET]
SYMBOL_EDITOR_DRAWING_ORDER = Should be ignored because the symbol editor should show the same as when the symbol is used in the schematic

Thanks for the excellent detail. I’m curious: How did you determine the order?

I drew all the elements overlapping on a schematic, took a print, copy and pasted into the symbol editor, took another print, saved the symbol and used it back on the schematic and took another print. The elements that are not supported in the symbol are present for forward compatibility.

If you could do me a favor, only if it’s not going to be too much trouble for you, but if you could paste into a .txt file and send to me, the functions from your code that have to do with translating the text that is shown in the SVG(like from “someattribute=<100k>” to “someattribute=100k”, etc…), so that I can convert it to Python and implement it for my script. I didn’t do this part but I left a placeholder for patching it later.

Could share your symbol/schematic for me to test with?

I’ll happily share code. Are you trying to parse programmable attributes? Maybe post a sample schematic/symbol of what you’re looking for?

copy this and paste into the schematic at QSpice:

«line (9400,-13600) (8950,-14100) 7 0 0xa0a0ff -1 -1»
«rect (8750,-13500) (9200,-13950) 0 7 0 0xc0c0 0xff92 -1 0 -1»
«ellipse (9400,-13600) (9150,-14100) 0 7 0 0xa0ffa1 0x96c0 -1 -1»
«arc (9250,-13950) (8950,-13250) (7950,-13200) (8700,-12800) 0 7 0 0x1000000 -1 -1»
«arc3p (9100,-13600) (9700,-13650) (9400,-13400) 7 0 0x9dc000 -1 -1»
«triangle (9300,-13550) (9050,-14100) (9150,-14150) 7 0 0x528000 0xffff00 -1 -1»
«coil (8650,-13650) (9400,-13800) 0 7 0 0xc000ff -1 -1»
«zigzag (9300,-13400) (9100,-14150) 0 7 0 0xff57d2 -1 -1»
«component (10100,-13700) 0 0
  «symbol
    «shorted pins: false»
    «line (300,150) (-150,-350) 7 0 0xa0a0ff -1 -1»
    «rect (-350,250) (100,-200) 0 7 0 0xc0c0 0xff92 -1 0 -1»
    «ellipse (300,150) (50,-350) 0 7 0 0xa0ffa1 0x96c0 -1 -1»
    «arc (150,-200) (-150,500) (-1150,550) (-400,950) 0 7 0 0x1000000 -1 -1»
    «arc3p (0,150) (600,100) (300,350) 7 0 0x9dc000 -1 -1»
    «triangle (200,200) (-50,-350) (50,-400) 7 0 0x528000 0xffff00 -1 -1»
    «coil (-450,100) (300,-50) 0 7 0 0xc000ff -1 -1»
    «zigzag (200,350) (0,-400) 0 7 0 0xff57d2 -1 -1»
  »
»

What I’m interested in, is the translation procedure from the text that is actually written in the .qsch file for the text attributes, and what appears on the schematic when it’s displayed by QSpice’s schematic editor, so when I generate the .svg, the text will appear the same as in QSpice’s schematic editor.

Edit: I missed the first line in the code above. Now it’s correct.