<?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[A design projects template]]></title><description><![CDATA[<p dir="auto">How does everyone do their new project layouts?</p>
<p dir="auto">I use OpenJSCAD for 3D printing, mostly, and have been tracking V2 and able to make the things I needs without too much issue. I have a package.json with:<br />
"main": "index.js"</p>
<p dir="auto">Then an index.js like:</p>
<pre><code class="language-javascript">//include your script here:
var inc = require('./mypart')

const getParameterDefinitions = () =&gt; {
    return inc.getParameterDefinitions()
}

const main = (params) =&gt; {
    return inc.main(params)
}

module.exports = { main, getParameterDefinitions }
</code></pre>
<p dir="auto">The do my parts like:</p>
<pre><code class="language-javascript">/* All the csg API functions: */
const { cube, sphere, cylinder, geodesicSphere, torus, polyhedron } = require('@jscad/csg/api').primitives3d
const { circle, square, polygon, triangle  } = require('@jscad/csg/api').primitives2d
const { difference, union, intersection } = require('@jscad/csg/api').booleanOps
const { translate, center, scale, rotate, transform, mirror, expand, contract, minkowski, hull, chain_hull } = require('@jscad/csg/api').transformations
const { extrudeInOrthonormalBasis, extrudeInPlane, extrude, linear_extrude, rotate_extrude, rotateExtrude, rectangular_extrude } = require('@jscad/csg/api').extrusions
const { css2rgb, color, rgb2hsl, hsl2rgb, rgb2hsv, hsv2rgb, html2rgb, rgb2html } = require('@jscad/csg/api').color
const { sin, cos, asin, acos, tan, atan, atan2, ceil, floor, abs, min, max, rands, log, lookup, pow, sign, sqrt, round } = require('@jscad/csg/api').maths
const { vector_char, vector_text, vectorChar, vectorText } = require('@jscad/csg/api').text
//const { echo } = require('@jscad/csg/api').echo
const {CAG, CSG} = require('@jscad/csg/api').csg
const { extrude_text } = require('./fonts/index.js')

const paramDefaults = {size: 10}

const getParameterDefinitions = () =&gt; {
  return [{ name: 'size', type: 'int', initial: 10, caption: 'Size?' }]
}

const main = (params) =&gt; {
	params = Object.assign({}, paramDefaults, params)

	let results = []
        // replace this
        myPart = cube(params.size)
	results.push(myPart)
	myText = extrude_text("Blank Project", 1, 1.5, {height:5, font:'camBamStick1Font'})
	myText = translate([-45,-10,0], myText) 
	results.push(myText)

	//

	return results 
}
module.exports = { main, getParameterDefinitions, paramDefaults }
</code></pre>
<p dir="auto">Then I just drag the folder to my browser running the web application.<br />
The "extrude_text" include is my integrating the single-line fonts from <a href="https://github.com/lautr3k/jscad-vector-fonts" rel="nofollow ugc">https://github.com/lautr3k/jscad-vector-fonts</a></p>
<p dir="auto">Now that a lot of the csg integration to packages/modeling has happened (Thanks kaosat-dev!) it works for me to replace stuff like:</p>
<pre><code class="language-javascript">const { cube, sphere } = require('@jscad/csg/api').primitives3d
</code></pre>
<p dir="auto">with:</p>
<pre><code class="language-javascript">const modeling = require('@jscad/modeling')
const { cube, sphere } = require('@jscad/modeling').primitives
</code></pre>
<p dir="auto">Is there a "recommended" project layout out there on a wiki somewhere? Would it be helpful for others if I post my "blank project" to github?</p>
]]></description><link>https://openjscad.nodebb.com/topic/116/a-design-projects-template</link><generator>RSS for Node</generator><lastBuildDate>Sun, 14 Jun 2026 06:45:18 GMT</lastBuildDate><atom:link href="https://openjscad.nodebb.com/topic/116.rss" rel="self" type="application/rss+xml"/><pubDate>Sun, 08 Dec 2019 19:22:41 GMT</pubDate><ttl>60</ttl></channel></rss>