<?xml version="1.0" encoding="UTF-8"?><rss xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:atom="http://www.w3.org/2005/Atom" version="2.0"><channel><title><![CDATA[Newbie question: Write 2D drawing to SVG file?]]></title><description><![CDATA[<p dir="auto">Hello and thank you for creating and maintaining this very impressive library!<br />
I'm trying to use V2 for a simple project and am currently stuck on what I'm sure is a very elementary issue.</p>
<p dir="auto">I'd like to save an array of rectangles to an SVG file. Originally was hoping to save as PNG, but not sure if this is currently supported?</p>
<p dir="auto">Referring to the example on the @jscad/openjscad npm page, is it possible to do something like this:</p>
<pre><code>const jscad = require("@jscad/openJscad");
const { rectangle } = require("@jscad/modeling").primitives;
const fs = require("fs");

const input = rectangle({ center: [0, 0], size: [10, 20] });

const outputData = jscad.generateOutput("svg", input);

fs.writeFileSync("panels.svg", outputData.asBuffer());
</code></pre>
<p dir="auto">Running this code, I get these errors:</p>
<pre><code>TypeError: cag._toCSGWall is not a function
at Array.map (&lt;anonymous&gt;)
at CAG.union
at convertToSolid2
at prepareOutput
at Object.generateOutput
</code></pre>
<p dir="auto">Any tips or guidance on how to accomplish this would be greatly appreciated.</p>
<p dir="auto">Thank you in advance!</p>
]]></description><link>https://openjscad.nodebb.com/topic/241/newbie-question-write-2d-drawing-to-svg-file</link><generator>RSS for Node</generator><lastBuildDate>Mon, 09 Nov 2026 16:59:00 GMT</lastBuildDate><atom:link href="https://openjscad.nodebb.com/topic/241.rss" rel="self" type="application/rss+xml"/><pubDate>Tue, 06 Apr 2021 21:55:21 GMT</pubDate><ttl>60</ttl><item><title><![CDATA[Reply to Newbie question: Write 2D drawing to SVG file? on Wed, 07 Apr 2021 06:06:44 GMT]]></title><description><![CDATA[<p dir="auto"><a class="plugin-mentions-user plugin-mentions-a" href="/user/dburt" aria-label="Profile: dburt">@<bdi>dburt</bdi></a> welcome</p>
<p dir="auto">Yes. You can make that example work. You might want to take a look at this project, which uses the JSCAD CLI (command line interface) for compiling the design and exporting SVG. Specifically, the 'localfont' project.</p>
<p dir="auto"><a href="https://github.com/jscad-community/jscad-text" rel="nofollow ugc">https://github.com/jscad-community/jscad-text</a></p>
<p dir="auto">If you are going to work with other JavaScript libraries, especially those using async functions or promises then take a look at the 'googlefont' project.</p>
]]></description><link>https://openjscad.nodebb.com/post/729</link><guid isPermaLink="true">https://openjscad.nodebb.com/post/729</guid><dc:creator><![CDATA[z3dev]]></dc:creator><pubDate>Wed, 07 Apr 2021 06:06:44 GMT</pubDate></item></channel></rss>