Skip to main content

Extrusions & Cuts

In this tutorial you learn how to write the code to create a model from a sketch in DynaMaker. The example is a metal washer using one extrusion and one cut, similar to a stamping process.

You will complete four steps:

  1. Create component
  2. Create sketches
  3. Create model
  4. Add cut to model
tip

🎥 You can also follow the tutorial with this video:

1. Create Component​

Create a component container and name it WASHER.

2. Create Sketch​

Create the base circle sketch:

  1. At the top of the code section click Sketch.
  2. Choose shape Circle.
  3. Click Create.

3. Create Model​

With the sketch ready, create the extrusion:

  1. Click Model.
  2. Select Extrude using the new generateCircleSketch.

4. Add Cut to Model​

Add the hole to the washer inside generateExtrudedCircleModel:

  1. Define the hole diameter (80% of the washer diameter).

    const holeDiameter = 0.8 * diameter
  2. Create the hole sketch using the GEOM2D function with holeDiameter.

    const holeSketch = GEOM2D.generateCircleSketch(holeDiameter)
  3. Add the cut using the same plane and extrusion length.

    model.addExtrudeCut(holeSketch, plane, extrudeLength)
  4. Click Save & Run to apply changes.

    tip

    You can also use Ctrl/Cmd+S to Save & Run. If you are prompted to save the web page, first focus the code editor by clicking inside it before using the shortcut.

  5. The completed function matches the version below.

    export function generateExtrudedCircleModel(diameter: number, extrudeLength: number) {
    const model = new SKYCAD.ParametricModel()
    const sketch = GEOM2D.generateCircleSketch(diameter)
    const plane = new SKYCAD.Plane(0, 0, 1)
    model.addExtrude(sketch, plane, extrudeLength)

    const holeDiameter = 0.8 * diameter
    const holeSketch = GEOM2D.generateCircleSketch(holeDiameter)
    model.addExtrudeCut(holeSketch, plane, extrudeLength)

    return model
    }

If you do not want a dynamic thickness (extrudeLength), create a constant const thickness = 5 instead. Then the function can look like this:

export function generateExtrudedCircleModel(diameter: number) {
const thickness = 5

const model = new SKYCAD.ParametricModel()
const sketch = GEOM2D.generateCircleSketch(diameter)
const plane = new SKYCAD.Plane(0, 0, 1)
model.addExtrude(sketch, plane, thickness)

const holeDiameter = 0.8 * diameter
const holeSketch = GEOM2D.generateCircleSketch(holeDiameter)
model.addExtrudeCut(holeSketch, plane, thickness)

return model
}

note

The slider for extrudeLength disappears above the visualization because it is not an input to generateExtrudedCircleModel and is a constant thickness instead.


In the next tutorial (3D Models) you go deeper into functions and make more changes.