START DOCUMENTATION

Parametric Cube

In this short tutorial we will create a cube by using OpenCascade OCCT kernel and we will control its size by using a variable component. This is a very simple example, but it shows how blockly can be used to create variables and parametric relationships.

Start The Application

First thing we will need to do is open up our Application on https://bitbybit.dev/app?editor=blockly. This will immediately start an empty Blockly workspace. You can also just use the embedded example editors in the tutorial, but it is good to practice finding the right components by following the given paths.

Draw Component

So first we will add a draw component to the canvas. Follow this path of navigation:

"Draw" -> "draw async" -> "drawAnyAsyncNoReturn"

Now we will need a cube component from OCCT. Here's the path:

"Occt" -> "Shapes" -> "Solid" -> "primitives" -> "createCube"

Drag and drop this component to the input called "entity" on the "drawAnyAsyncNoReturn" component. You can Run the code and see the result. You should see a cube appear on the canvas, which has the default size of 1 unit.

Now you will need to create a variable. Follow this path:

"Variables" -> "create variable"

In the modal that opens enter the name "size" and click "Create" button. Now you see three components under the variables flyout. Pick the "set size to" component so that it would be added to the canvas. Open "Variables" category again and pick a component that only has "size" written on it. Drag and drop it to the input called "size" on the "createCube" component. Open "Math" category and drag the number component with "0" written on it to the "set size to" component. You should now have a script that looks like this:

Blockly

Parametric cube example

Now that this is done feel free to set the size to a different number and see how variable named "size" passes it to the input of the cube. While this does not look like much, creating variables is a very fundamental concept in programming. You can use variables to store information and pass it to other components.