My First Assembly
Let's create your first assembly in DynaMaker!
In this tutorial, you will learn how to create an assembly, which is essentially a component with subcomponents, following the configurable size. As a product example, we will use a configurable indoor staircase consisting of steps and glass railings.
For this we will follow 3 steps:
Don't forget to check the common mistakes if you get stuck. Good luck!
1. Create App
- Create a new project and name it for example StaircaseApp.
- Create 3 new components:
- StairStep
- Railing
- Assembly
2. Prepare Subcomponents
Starting from the cube template, we will change the model for the StairStep and Railing needed for the Assembly.
A. StairStep
As for the step, we will only change its default properties and its color.
- Go to the app dashboard and go into the component StairStep.
- Go to COMPONENT and update the default property values, e.g. with these values:
constructor() {
super()
this.properties = {
width: 200,
depth: 500,
height: 20,
}
}
- In
generateGeometry()
, you can change quickly thecolor
of thematerial
to e.g. light brown. - In
generateGeometry()
, remove the dimension and itslayout
for now. - Doing this,
generateGeometry()
could look like this:
generateGeometry() {
const { width, depth, height } = this.getProperties()
const model = new SKYCAD.ParametricModel()
const baseSketch = SKYCAD.generateRectangleSketch(0, 0, width, depth)
const plane = new SKYCAD.Plane()
model.addExtrude(baseSketch, plane, height)
const geometryGroup = new SKYCAD.GeometryGroup()
geometryGroup.addGeometry(model, {
materials: [new SKYCAD.Material({ color: new SKYCAD.RgbColor(196, 164, 132) })]
})
return geometryGroup
}
See that we have wrapped the properties in a line with
getProperties()
and createdmaterials
in-line together withcolor
. Feel free to extract each value to a separate constant instead if that's clearer for you.
- Save & Update to apply the changes.
- Publish to be able to use it later in Assembly.
Don't worry about the configurator here, we will use the one of the Assembly instead.
Dimensions were added to the picture to help you understand the size.
B. Railing
Here we will add a fourth property railingHeight
, remove depth
, and change its shape and material.
- Go back to the app dashboard and go into the component Railing.
- Go to COMPONENT, create a new property
railingHeight
and removedepth
. Make sure you have:
constructor() {
super()
this.properties = {
width: 5000,
height: 3000,
railingHeight: 1200,
}
}
- You will see an IntelliSense error in
railingHeight
(highlighted in red), saying that this property does not exist inproperties
. Sinceproperties
are defined at the top of COMPONENT, make sure you have:
export interface Properties {
height: number
width: number
railingHeight: number
}
You will survive if you don't update the IntelliSense, but its purpose is to assist you when coding and make sure you are accessing the right functions. E.g. now you know that, within the class
Component
(COMPONENT), when you typethis.properties.
you only seeheight
,width
&railingHeight
as available options. This will not only avoid problems within this component but also wherever is used throughout the whole app!
-
Save & Update to apply changes (expect an error).
-
Let's fix the unexisting properties
depth
, together with the shape:- In COMPONENT, it is up to you to remove or adjust the dimension created at the end of
generateGeometry()
since we won't use it. - In COMPONENT, in
generateGeometry()
, sendheight
,width
&railingHeight
as arguments, so that:
generateGeometry() {
const { height, width, railingHeight } = this.getProperties()
const model = GEOM3D.generateModel(height, width, railingHeight)
const geometryGroup = new SKYCAD.GeometryGroup()
geometryGroup.addGeometry(model, {
materials: [new SKYCAD.Material({ color: new SKYCAD.RgbColor(83, 165, 199) })]
})
return geometryGroup
}- In GEOM2D, create the sketch (side view) for the railing in a function:
export function generateRailingSideViewSketch(height: number, width: number, railingHeight: number) {
const sketch = new SKYCAD.Sketch()
sketch.moveTo(0, 0)
sketch.lineTo(0, railingHeight)
sketch.lineTo(width, height + railingHeight)
sketch.lineTo(width, height)
sketch.lineToId(0)
const CORNER_RADIUS = 50
sketch.getNodes().forEach((node, nodeId) => {
if (nodeId === 1 || nodeId === 2) {
sketch.addFillet(CORNER_RADIUS, nodeId)
}
})
return sketch
}-
In GEOM3D:
- update the arguments of
generateModel()
, so it matches what you wrote ingenerateGeometry()
: - use the sketch you created in GEOM2D instead, change the plane direction and make the extrusion as thick as the glass (e.g. 15 mm):
export function generateModel(height: number, width: number, railingHeight: number) {
const model = new SKYCAD.ParametricModel()
const GLASS_THICKNESS = 20
const railingSideViewSketch = GEOM2D.generateRailingSideViewSketch(height, width, railingHeight)
const plane = new SKYCAD.Plane(0, -1, 0, 0)
model.addExtrude(railingSideViewSketch, plane, GLASS_THICKNESS)
return model
} - update the arguments of
- In COMPONENT, it is up to you to remove or adjust the dimension created at the end of
-
In COMPONENT, change the material directly in
generateGeometry()
to light blue and make it slightly transparent with the material settingopacity
(0 = invisible, 1 = opaque):geometryGroup.addGeometry(model, {
materials: [new SKYCAD.Material({ color: new SKYCAD.RgbColor(173, 216, 230), opacity: 0.5 })],
}) -
Save & Update to apply changes
-
Publish to be able to use it later in Assembly.
Dimensions were added to help you understand the size. They won't be visible later.
Notice that when you Save & Update a component, this will be flagged with a
*
in the app dashboard, meaning that the component has changed and needs to be published (viaPublish) if you want to see the latest version of your component in other components that might use it.
3. Build Assembly
To build the Assembly from other components, let's start by importing them.