Introduction to OCCT Solids
Solids are three-dimensional shapes that represent complete geometric objects with volume. OCCT provides several primitive solid types that serve as building blocks for more complex 3D modeling operations. These primitives are commonly used in CAD applications and can be combined, modified, and transformed to create sophisticated geometries.
This example demonstrates the creation of the most common primitive solid types:
- Box: A rectangular solid with specified width, length, and height
- Cube: A special case of a box where all dimensions are equal
- Cylinder: A circular solid with specified radius and height
- Sphere: A perfectly round solid with a specified radius
- Cone: A tapered solid with different radii at top and bottom
- Rete
- Blockly
- TypeScript
Script Source (rete)
{
"id": "rete-v2-json",
"nodes": {
"e43513e5f9c946b0": {
"id": "e43513e5f9c946b0",
"name": "bitbybit.occt.shapes.solid.createBox",
"customName": "box",
"async": true,
"drawable": true,
"data": {
"genericNodeData": {
"hide": false,
"oneOnOne": false,
"flatten": 0,
"forceExecution": false
},
"width": 3,
"length": 7,
"height": 8,
"center": [
0,
0,
0
],
"originOnCenter": true
},
"inputs": {},
"position": [
1095.4134994211415,
212.13676636576983
]
},
"25b61f24af681fc1": {
"id": "25b61f24af681fc1",
"name": "bitbybit.occt.shapes.solid.createCube",
"customName": "cube",
"async": true,
"drawable": true,
"data": {
"genericNodeData": {
"hide": false,
"oneOnOne": false,
"flatten": 0,
"forceExecution": false
},
"size": 5,
"center": [
0,
0,
0
],
"originOnCenter": true
},
"inputs": {
"center": {
"connections": [
{
"node": "448bcc9a53099187",
"output": "result",
"data": {}
}
]
}
},
"position": [
1096.2055156502413,
638.7451662706167
]
},
"448bcc9a53099187": {
"id": "448bcc9a53099187",
"name": "bitbybit.point.pointXYZ",
"customName": "point xyz",
"async": false,
"drawable": true,
"data": {
"genericNodeData": {
"hide": false,
"oneOnOne": false,
"flatten": 0,
"forceExecution": false
},
"x": 5,
"y": 0,
"z": 0
},
"inputs": {},
"position": [
725.9477971825983,
679.5545829434357
]
},
"a9f77700c1e1906f": {
"id": "a9f77700c1e1906f",
"name": "bitbybit.occt.shapes.solid.createCylinder",
"customName": "cylinder",
"async": true,
"drawable": true,
"data": {
"genericNodeData": {
"hide": false,
"oneOnOne": false,
"flatten": 0,
"forceExecution": false
},
"radius": 2,
"height": 3,
"center": [
0,
0,
0
],
"direction": [
0,
1,
0
],
"angle": 360,
"originOnCenter": true
},
"inputs": {
"center": {
"connections": [
{
"node": "8aca4ab6493670a2",
"output": "result",
"data": {}
}
]
}
},
"position": [
1101.6017421578954,
1056.9492391773358
]
},
"8aca4ab6493670a2": {
"id": "8aca4ab6493670a2",
"name": "bitbybit.point.pointXYZ",
"customName": "point xyz",
"async": false,
"drawable": true,
"data": {
"genericNodeData": {
"hide": false,
"oneOnOne": false,
"flatten": 0,
"forceExecution": false
},
"x": -5,
"y": 0,
"z": 0
},
"inputs": {},
"position": [
729.2621246892346,
1134.7941632755822
]
},
"ec2580a4c1ac2d9d": {
"id": "ec2580a4c1ac2d9d",
"name": "bitbybit.occt.shapes.solid.createSphere",
"customName": "sphere",
"async": true,
"drawable": true,
"data": {
"genericNodeData": {
"hide": false,
"oneOnOne": false,
"flatten": 0,
"forceExecution": false
},
"radius": 1.5,
"center": [
0,
0,
0
]
},
"inputs": {
"center": {
"connections": [
{
"node": "6b160cf261dd2fea",
"output": "result",
"data": {}
}
]
}
},
"position": [
1117.3865750518971,
1522.4103305452768
]
},
"6b160cf261dd2fea": {
"id": "6b160cf261dd2fea",
"name": "bitbybit.point.pointXYZ",
"customName": "point xyz",
"async": false,
"drawable": true,
"data": {
"genericNodeData": {
"hide": false,
"oneOnOne": false,
"flatten": 0,
"forceExecution": false
},
"x": 10,
"y": 0,
"z": 0
},
"inputs": {},
"position": [
712.3423435103973,
1562.1195996984645
]
},
"5a40465432d84f3b": {
"id": "5a40465432d84f3b",
"name": "bitbybit.occt.shapes.solid.createCone",
"customName": "cone",
"async": true,
"drawable": true,
"data": {
"genericNodeData": {
"hide": false,
"oneOnOne": false,
"flatten": 0,
"forceExecution": false
},
"radius1": 2,
"radius2": 1,
"height": 3,
"angle": 360,
"center": [
0,
0,
0
],
"direction": [
0,
1,
0
]
},
"inputs": {
"center": {
"connections": [
{
"node": "2d48f4fb2d21c489",
"output": "result",
"data": {}
}
]
}
},
"position": [
1118.347451513905,
1888.699223011909
]
},
"2d48f4fb2d21c489": {
"id": "2d48f4fb2d21c489",
"name": "bitbybit.point.pointXYZ",
"customName": "point xyz",
"async": false,
"drawable": true,
"data": {
"genericNodeData": {
"hide": false,
"oneOnOne": false,
"flatten": 0,
"forceExecution": false
},
"x": -10,
"y": 0,
"z": 0
},
"inputs": {},
"position": [
724.1861903355834,
2041.562153475275
]
}
}
}
Script Source (blockly)
<xml xmlns="https://developers.google.com/blockly/xml"><variables><variable id="box">box</variable><variable id="cube">cube</variable><variable id="cylinder">cylinder</variable><variable id="sphere">sphere</variable><variable id="cone">cone</variable></variables><block type="variables_set" id="create_box" x="50" y="50"><field name="VAR" id="box">box</field><value name="VALUE"><block type="bitbybit.occt.shapes.solid.createBox" id="box_solid"><value name="Width"><block type="math_number" id="box_width"><field name="NUM">3</field></block></value><value name="Length"><block type="math_number" id="box_length"><field name="NUM">7</field></block></value><value name="Height"><block type="math_number" id="box_height"><field name="NUM">8</field></block></value><value name="Center"><block type="bitbybit.point.pointXYZ" id="box_center"><value name="X"><block type="math_number" id="box_center_x"><field name="NUM">0</field></block></value><value name="Y"><block type="math_number" id="box_center_y"><field name="NUM">0</field></block></value><value name="Z"><block type="math_number" id="box_center_z"><field name="NUM">0</field></block></value></block></value><value name="OriginOnCenter"><block type="logic_boolean" id="box_origin_center"><field name="BOOL">TRUE</field></block></value></block></value><next><block type="variables_set" id="create_cube" x="50" y="150"><field name="VAR" id="cube">cube</field><value name="VALUE"><block type="bitbybit.occt.shapes.solid.createCube" id="cube_solid"><value name="Size"><block type="math_number" id="cube_size"><field name="NUM">5</field></block></value><value name="Center"><block type="bitbybit.point.pointXYZ" id="cube_center"><value name="X"><block type="math_number" id="cube_center_x"><field name="NUM">5</field></block></value><value name="Y"><block type="math_number" id="cube_center_y"><field name="NUM">0</field></block></value><value name="Z"><block type="math_number" id="cube_center_z"><field name="NUM">0</field></block></value></block></value><value name="OriginOnCenter"><block type="logic_boolean" id="cube_origin_center"><field name="BOOL">TRUE</field></block></value></block></value><next><block type="variables_set" id="create_cylinder" x="50" y="250"><field name="VAR" id="cylinder">cylinder</field><value name="VALUE"><block type="bitbybit.occt.shapes.solid.createCylinder" id="cylinder_solid"><value name="Radius"><block type="math_number" id="cylinder_radius"><field name="NUM">2</field></block></value><value name="Height"><block type="math_number" id="cylinder_height"><field name="NUM">3</field></block></value><value name="Center"><block type="bitbybit.point.pointXYZ" id="cylinder_center"><value name="X"><block type="math_number" id="cylinder_center_x"><field name="NUM">-5</field></block></value><value name="Y"><block type="math_number" id="cylinder_center_y"><field name="NUM">0</field></block></value><value name="Z"><block type="math_number" id="cylinder_center_z"><field name="NUM">0</field></block></value></block></value><value name="Direction"><block type="bitbybit.vector.vectorXYZ" id="cylinder_direction"><value name="X"><block type="math_number" id="cylinder_dir_x"><field name="NUM">0</field></block></value><value name="Y"><block type="math_number" id="cylinder_dir_y"><field name="NUM">1</field></block></value><value name="Z"><block type="math_number" id="cylinder_dir_z"><field name="NUM">0</field></block></value></block></value><value name="Angle"><block type="math_number" id="cylinder_angle"><field name="NUM">360</field></block></value><value name="OriginOnCenter"><block type="logic_boolean" id="cylinder_origin_center"><field name="BOOL">TRUE</field></block></value></block></value><next><block type="variables_set" id="create_sphere" x="50" y="350"><field name="VAR" id="sphere">sphere</field><value name="VALUE"><block type="bitbybit.occt.shapes.solid.createSphere" id="sphere_solid"><value name="Radius"><block type="math_number" id="sphere_radius"><field name="NUM">1.5</field></block></value><value name="Center"><block type="bitbybit.point.pointXYZ" id="sphere_center"><value name="X"><block type="math_number" id="sphere_center_x"><field name="NUM">10</field></block></value><value name="Y"><block type="math_number" id="sphere_center_y"><field name="NUM">0</field></block></value><value name="Z"><block type="math_number" id="sphere_center_z"><field name="NUM">0</field></block></value></block></value></block></value><next><block type="variables_set" id="create_cone" x="50" y="450"><field name="VAR" id="cone">cone</field><value name="VALUE"><block type="bitbybit.occt.shapes.solid.createCone" id="cone_solid"><value name="Radius1"><block type="math_number" id="cone_radius1"><field name="NUM">2</field></block></value><value name="Radius2"><block type="math_number" id="cone_radius2"><field name="NUM">1</field></block></value><value name="Height"><block type="math_number" id="cone_height"><field name="NUM">3</field></block></value><value name="Angle"><block type="math_number" id="cone_angle"><field name="NUM">360</field></block></value><value name="Center"><block type="bitbybit.point.pointXYZ" id="cone_center"><value name="X"><block type="math_number" id="cone_center_x"><field name="NUM">-10</field></block></value><value name="Y"><block type="math_number" id="cone_center_y"><field name="NUM">0</field></block></value><value name="Z"><block type="math_number" id="cone_center_z"><field name="NUM">0</field></block></value></block></value><value name="Direction"><block type="bitbybit.vector.vectorXYZ" id="cone_direction"><value name="X"><block type="math_number" id="cone_dir_x"><field name="NUM">0</field></block></value><value name="Y"><block type="math_number" id="cone_dir_y"><field name="NUM">1</field></block></value><value name="Z"><block type="math_number" id="cone_dir_z"><field name="NUM">0</field></block></value></block></value></block></value><next><block type="bitbybit.draw.drawAnyAsyncNoReturn" id="draw_box" x="50" y="550"><value name="Entity"><block type="variables_get" id="get_box"><field name="VAR" id="box">box</field></block></value><next><block type="bitbybit.draw.drawAnyAsyncNoReturn" id="draw_cube" x="50" y="650"><value name="Entity"><block type="variables_get" id="get_cube"><field name="VAR" id="cube">cube</field></block></value><next><block type="bitbybit.draw.drawAnyAsyncNoReturn" id="draw_cylinder" x="50" y="750"><value name="Entity"><block type="variables_get" id="get_cylinder"><field name="VAR" id="cylinder">cylinder</field></block></value><next><block type="bitbybit.draw.drawAnyAsyncNoReturn" id="draw_sphere" x="50" y="850"><value name="Entity"><block type="variables_get" id="get_sphere"><field name="VAR" id="sphere">sphere</field></block></value><next><block type="bitbybit.draw.drawAnyAsyncNoReturn" id="draw_cone" x="50" y="950"><value name="Entity"><block type="variables_get" id="get_cone"><field name="VAR" id="cone">cone</field></block></value></block></next></block></next></block></next></block></next></block></next></block></next></block></next></block></next></block></next></block></xml>
Script Source (typescript)
// Import required DTOs and types for solid creation
const { BoxDto, CubeDto, CylinderDto, SphereDto, ConeDto } = Bit.Inputs.OCCT;
type Point3 = Bit.Inputs.Base.Point3;
type Vector3 = Bit.Inputs.Base.Vector3;
// Get access to OCCT solid creation functions
const { solid } = bitbybit.occt.shapes;
// Define the main function to create various primitive solids
const start = async () => {
// Create a rectangular box
const boxOptions = new BoxDto();
boxOptions.width = 3;
boxOptions.length = 7;
boxOptions.height = 8;
boxOptions.center = [0, 0, 0] as Point3;
boxOptions.originOnCenter = true;
const box = await solid.createBox(boxOptions);
// Create a cube at a different position
const cubeOptions = new CubeDto();
cubeOptions.size = 5;
cubeOptions.center = [5, 0, 0] as Point3;
cubeOptions.originOnCenter = true;
const cube = await solid.createCube(cubeOptions);
// Create a cylinder
const cylinderOptions = new CylinderDto();
cylinderOptions.radius = 2;
cylinderOptions.height = 3;
cylinderOptions.center = [-5, 0, 0] as Point3;
cylinderOptions.direction = [0, 1, 0] as Vector3;
cylinderOptions.angle = 360;
cylinderOptions.originOnCenter = true;
const cylinder = await solid.createCylinder(cylinderOptions);
// Create a sphere
const sphereOptions = new SphereDto();
sphereOptions.radius = 1.5;
sphereOptions.center = [10, 0, 0] as Point3;
const sphere = await solid.createSphere(sphereOptions);
// Create a cone
const coneOptions = new ConeDto();
coneOptions.radius1 = 2;
coneOptions.radius2 = 1;
coneOptions.height = 3;
coneOptions.angle = 360;
coneOptions.center = [-10, 0, 0] as Point3;
coneOptions.direction = [0, 1, 0] as Vector3;
const cone = await solid.createCone(coneOptions);
// Draw all the created solids
bitbybit.draw.drawAnyAsync({ entity: box });
bitbybit.draw.drawAnyAsync({ entity: cube });
bitbybit.draw.drawAnyAsync({ entity: cylinder });
bitbybit.draw.drawAnyAsync({ entity: sphere });
bitbybit.draw.drawAnyAsync({ entity: cone });
}
// Execute the function
start();
These primitive solids serve as the foundation for more complex 3D modeling operations. They can be combined using boolean operations (union, intersection, difference), transformed, and modified to create sophisticated geometries for engineering and design applications.



