meta data for this page
Projects
As designs grow in complexity, the need for smaller, reusable parts becomes apparent. This is the time to consider using a “project”.
Projects are simple directories, containing several files (parts) of the design. For example, a project for a RC car design would have various parts. And the reusable parts can be separated out.
- …/rc-car
- chassis.js
- body.js
- tire.js
- index.js
The 'index' within the project is the entry point of the project. The main function of the 'index' creates each of the pieces, move the pieces into position, and returns the complete design. And by convention, exports the main function.
const chassis = require('./chassis') const body = require('./body') const tire = require('./tire') const main = (params) => { const partA = chassis(params) const partB = body(params) const tires = [ ... ] return [partA, partB, tires] } module.exports = { main }
Projects can also be used when working with external formats, such as STL files. This allows designs to include STL meshes just like any other part. The STL file is placed within the project directory just like any other part.
- …/rc-car
- chassis.js
- body.js
- tire.js
- index.js
- rc_receiver.stl
And the design is adjusted to include the new part from the STL file.
const chassis = require('./chassis') const body = require('./body') const tire = require('./tire') const receiver = require('./rc_receiver.stl') const main = (params) => { const partA = chassis(params) const partB = body(params) const tires = [ ... ] return [partA, partB, tires, receiver] } module.exports = { main }