circuitjs1 icon indicating copy to clipboard operation
circuitjs1 copied to clipboard

getCircuitAsSVG() API gives undefined

Open Romaxx opened this issue 3 months ago • 2 comments

Hi,

I've tried local and falstad website getCircuitAsSVG() API function from javascript but it return "undefined" in the two cases. export to SVG in the menu working (in base64 form) in the two cases.. I don't understand what's the problem.

Any Help :) ?

Romaxx avatar Sep 21 '25 19:09 Romaxx

Sorry, there's an error in the doc. It's asynchronous, because the package that does the SVG conversion may need to be initialized and that is asychronous.

function svgRendered(sim, svg) { console.log('here is svg data:', svg); } sim.onsvgrendered = svgRendered; sim.getCircuitAsSVG();

See here for an example:

https://www.falstad.com/circuit/jsinterface.html

pfalstad avatar Sep 21 '25 19:09 pfalstad

That was a fast reply 🙂 Thanks a lot, it’s working perfectly now! Also, thank you for CircuitJS it’s an amazing tool !

Romaxx avatar Sep 21 '25 19:09 Romaxx