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:
🎥 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:
- At the top of the code section click Sketch.
- Choose shape Circle.
- Click Create.
3. Create Model​
With the sketch ready, create the extrusion:
- Click Model.
- Select Extrude using the new generateCircleSketch.
4. Add Cut to Model​
Add the hole to the washer inside generateExtrudedCircleModel
:
-
Define the hole diameter (80% of the washer diameter).
const holeDiameter = 0.8 * diameter
-
Create the hole sketch using the GEOM2D function with
holeDiameter
.const holeSketch = GEOM2D.generateCircleSketch(holeDiameter)
-
Add the cut using the same plane and extrusion length.
model.addExtrudeCut(holeSketch, plane, extrudeLength)
-
Click Save & Run to apply changes.
tipYou 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.
-
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
}
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.