Tag Archives: CAD Modeling

ScriptCAD.org

Introduction

Faces + Edges

Back in 2003 I adapted OpenJsCad framework and extended it and documented it properly so it can be used in an easy way and then handed OpenJSCAD.org over to JS devs, who transformed it into the several NPM packages so it becomes usable for 3rd party packages easier.

I realized I wanted to have CAD with strong script capability with the focus on easy use and leave all the NPM package and JavaScript module conformity aside but refocus on easy and powerful 3D scene language, and so I started 2019/01 again, this time from scratch:

illu-stages
  1. Modeling in JavaScript
  2. Hierarchical Scene (computeScene())
  3. Compute Form
    • computeSolid()
      • computeSolidPolygon(): creates polyhedral approximation of solids
      • computeSolidImplicit(): create code for implicit rendering
  4. Rendering (renderScene())
    • polygon: throw triangles into WebGL space (e.g. with threejs)
    • implicit: render using GL shader
  5. Export
    • polygonal:
      • Browser: .stl, .amf, .obj, .3mf, .3mj
      • CLI: .stl, .amf, .obj, .3mf, .3mj, .png

Goals

  • true scripting capability like JavaScript (OpenSCAD’s .scad is a reduced language)
  • keep it simple (no NPM module export or alike complexity)
  • CSG capability (union, intersection, difference)
  • name parts and enumerate parts/id
  • parametrical designs (expose certain variables)
  • extrude 2D polygons to another (not just hull)
  • morph from one solid to another
  • simple fillets and chamfers (reduce sharp edges for real world parts)
  • extensive and detailed documentation
  • 100% API backward compatibility (no depreciation)

Few notes how to achieve those:

  • using three.js and ThreeCSG: reliable and well maintained package somewhat, ThreeCSG seems outdated/abandoned; alternatively using csg.js and/or OpenJSCAD packages as fallback, but hiding all the module handling
  • separate creating scene and rendering scene altogether:
    • polygons or rendering triangles are a stage, but not the core of the CAD, but true solids like a (perfect) sphere
    • use WebGL as one backend among others
    • use implict representations alternatives
  • fillets and chamfers: even those look simple, those are hard(er) to do in polygonal/triangulated stage, but simple to do with implicit representation
    • referencing individual edges (using consistent notion)

Prototype

Visit ScriptCAD.org

  • Chrome/Chromium provides full functionality
  • Firefox lacks marked source code from 3D space or Tree view

Status

  • 3D Forms: cube(), sphere(), cylinder(), polyhedron()
  • 2D Forms: square(), circle(), polygon(): line, lines, closed/open polygon
  • Operations: linear_extrude(), rotate_extrude(), transform(), scale(), rotate(), hull(), mesh()
  • CSG Operations: union(), difference(), intersection(), exclusive()
  • Import: STL (ASCII/Binary), AMF, OBJ, DXF, SCCAD (ScriptCAD), 3MJ
  • Export: STL (ASCII/Binary), AMF, OBJ, 3MF, SCAD (OpenSCAD), SCCAD (ScriptCAD), 3MJ, Gcode, PNG (CLI only)
  • Browser Support: Chrome (fully functional), Firefox (source select missing)

History

  • 2019/12/27: 0.3.3: experimental export of SCAD (OpenSCAD), 3MF, and SVG (only 2D) added:
  • 2019/12/05: 0.3.0: ScriptCAD.org Reference online, for now hosted on this site
  • 2019/11/25: 0.2.5: ScriptCAD.org launched as preview and a limited ScriptCAD Reference
  • 2019/11/05: 0.2.3: various features implemented, e.g. exclusive(), 3MJ import and export support added.
  • 2019/03/04: 0.1.5: more drawing models, selectable windows, more examples:

Brief overview of features of 0.1.5:

  • 2019/01/18: select Source -> TreeView -> 3D Scene or any stage and respective part is highlighted

Applications

I used ScriptCAD to generate paths with certain colors, and visualize it within ScriptCAD Web-GUI, and on the command-line the same code generated actual Gcode for one of my 3D printers, Ashtar K#2 equipped with Diamond Hotend 3-in-1 (mixing colors) – it allowed me to control every detail, something an ordinate slicer would not have provided:

Related Projects