Build Multi-Part Assemblies from Scratch
This tutorial demonstrates how to create an assembly programmatically using parts and instances, then export it as a structured STEP file.
Parts, Instances, and Nodes
An assembly document organizes your 3D model into a hierarchy:
- Parts are the unique component designs (e.g., a wheel, a door, an engine)
- Instances are the actual placements of those parts in your model (e.g., "put a wheel at each corner of the chassis")
- Assembly nodes are containers that group related instances together (e.g., "the drivetrain" containing engine and transmission)
Why Create an Assembly?
You can simply export flat BRep shapes to STEP files, but it's worth creating an assembly before you hit that export button. Here's why:
1. Preserved Structure in CAD Software
When you open the exported STEP file in professional CAD software like FreeCAD, Fusion 360, SolidWorks, CATIA, or Onshape, you'll see:
- Each part listed separately in the model tree
- Individual instances that can be selected, modified, or replaced
- The full hierarchy of your assembly
2. Efficient File Size
When you have multiple copies of the same shape (like the 14 plugs in our example), the assembly stores the geometry once and references it multiple times with different transformations. This makes files smaller and faster to load.
3. Part Metadata
Each part and instance can have:
- A unique ID for programmatic access
- A human-readable name that appears in CAD software
- Colors that are preserved in the STEP export
- Author and organization information embedded in the file
4. Professional Workflow Compatibility
STEP files with assembly structure are the industry standard for exchanging CAD data between different software packages. Your colleagues using different CAD tools can open and work with your designs seamlessly.
STEP File Format
The STEP (Standard for the Exchange of Product Data) format is an ISO standard (ISO 10303) widely supported by virtually all CAD software. When you export with the .stpZ extension, the file is compressed for faster downloads and smaller storage.
Example: Base with Plugs Assembly
In the example below, we create an assembly with:
- A base part with holes arranged in a circle
- A plug part that fits into the holes
- 14 instances of the plug positioned around the base
After running the script, download the generated .stpZ file and open it in your favorite CAD software to see the full assembly structure!
- Rete
- Blockly
- TypeScript
{
"id": "rete-v2-json",
"nodes": {
"4fe8e8be91a7f5ba": {
"id": "4fe8e8be91a7f5ba",
"name": "bitbybit.occt.shapes.wire.createCircleWire",
"customName": "circle wire",
"async": true,
"drawable": true,
"data": {
"genericNodeData": {
"hide": true,
"oneOnOne": false,
"flatten": 0,
"forceExecution": false
},
"radius": 10,
"center": [
0,
0,
0
],
"direction": [
0,
1,
0
]
},
"inputs": {
"radius": {
"connections": [
{
"node": "3b411188f9c758db",
"output": "result",
"data": {}
}
]
}
},
"position": [
364.23046875,
192.4609375
]
},
"be417d03b5d85770": {
"id": "be417d03b5d85770",
"name": "bitbybit.occt.shapes.wire.createCircleWire",
"customName": "circle wire",
"async": true,
"drawable": true,
"data": {
"genericNodeData": {
"hide": true,
"oneOnOne": false,
"flatten": 0,
"forceExecution": false
},
"radius": 7,
"center": [
0,
0,
0
],
"direction": [
0,
1,
0
]
},
"inputs": {
"radius": {
"connections": [
{
"node": "2af6ba4512540d9c",
"output": "result",
"data": {}
}
]
}
},
"position": [
816.7140490444849,
556.3591546575002
]
},
"69519ae3aafb49fa": {
"id": "69519ae3aafb49fa",
"name": "bitbybit.math.numberSlider",
"customName": "from outer radius",
"data": {
"options": {
"min": 2,
"max": 7,
"step": 0.1,
"width": 350,
"updateOnDrag": false
},
"number": 4
},
"inputs": {},
"position": [
-344.363017592156,
983.6005689176313
]
},
"2af6ba4512540d9c": {
"id": "2af6ba4512540d9c",
"name": "bitbybit.math.subtract",
"customName": "subtract",
"async": false,
"drawable": false,
"data": {
"genericNodeData": {
"hide": false,
"oneOnOne": false,
"flatten": 0,
"forceExecution": false
},
"first": 1,
"second": 2
},
"inputs": {
"second": {
"connections": [
{
"node": "69519ae3aafb49fa",
"output": "result",
"data": {}
}
]
},
"first": {
"connections": [
{
"node": "3b411188f9c758db",
"output": "result",
"data": {}
}
]
}
},
"position": [
371.36055072161906,
567.111764039391
]
},
"3b411188f9c758db": {
"id": "3b411188f9c758db",
"name": "bitbybit.math.numberSlider",
"customName": "main radius",
"data": {
"options": {
"min": 10,
"max": 20,
"step": 0.1,
"width": 350,
"updateOnDrag": false
},
"number": 13.3
},
"inputs": {},
"position": [
-357.85242764425567,
426.97840137892
]
},
"2490c58c788f0566": {
"id": "2490c58c788f0566",
"name": "bitbybit.math.divide",
"customName": "divide",
"async": false,
"drawable": false,
"data": {
"genericNodeData": {
"hide": false,
"oneOnOne": false,
"flatten": 0,
"forceExecution": false
},
"first": 1,
"second": 3
},
"inputs": {
"first": {
"connections": [
{
"node": "69519ae3aafb49fa",
"output": "result",
"data": {}
}
]
}
},
"position": [
496.046276856815,
1292.564460371842
]
},
"4060c9957222ebcd": {
"id": "4060c9957222ebcd",
"name": "bitbybit.occt.shapes.wire.divideWireByParamsToPoints",
"customName": "divide wire by params to points",
"async": true,
"drawable": true,
"data": {
"genericNodeData": {
"hide": true,
"oneOnOne": false,
"flatten": 0,
"forceExecution": false
},
"nrOfDivisions": 14,
"removeStartPoint": false,
"removeEndPoint": true
},
"inputs": {
"shape": {
"connections": [
{
"node": "be417d03b5d85770",
"output": "result",
"data": {}
}
]
}
},
"position": [
1188.6737414784734,
549.4890135906844
]
},
"9d0a571b8601732c": {
"id": "9d0a571b8601732c",
"name": "bitbybit.occt.shapes.wire.createCircleWire",
"customName": "circle wire",
"async": true,
"drawable": true,
"data": {
"genericNodeData": {
"hide": true,
"oneOnOne": false,
"flatten": 0,
"forceExecution": false
},
"radius": 1,
"center": [
0,
0,
0
],
"direction": [
0,
1,
0
]
},
"inputs": {
"radius": {
"connections": [
{
"node": "2490c58c788f0566",
"output": "result",
"data": {}
}
]
}
},
"position": [
882.8356573520075,
1291.2236147194417
]
},
"bd98e7140385a6e8": {
"id": "bd98e7140385a6e8",
"name": "bitbybit.occt.shapes.wire.reversedWire",
"customName": "reversed wire",
"async": true,
"drawable": true,
"data": {
"genericNodeData": {
"hide": true,
"oneOnOne": false,
"flatten": 0,
"forceExecution": false
}
},
"inputs": {
"shape": {
"connections": [
{
"node": "9d0a571b8601732c",
"output": "result",
"data": {}
}
]
}
},
"position": [
1262.8796807244462,
1289.0259394305124
]
},
"77a1d4eeb5d51aeb": {
"id": "77a1d4eeb5d51aeb",
"name": "bitbybit.occt.transforms.translate",
"customName": "translate",
"async": true,
"drawable": true,
"data": {
"genericNodeData": {
"hide": true,
"oneOnOne": false,
"flatten": 0,
"forceExecution": false
},
"translation": [
0,
0,
0
]
},
"inputs": {
"shape": {
"connections": [
{
"node": "bd98e7140385a6e8",
"output": "result",
"data": {}
}
]
},
"translation": {
"connections": [
{
"node": "2e4c94de1681cf77",
"output": "result",
"data": {}
}
]
}
},
"position": [
2093.110995458188,
372.5009228342478
]
},
"2e4c94de1681cf77": {
"id": "2e4c94de1681cf77",
"name": "bitbybit.lists.flatten",
"customName": "flatten",
"data": {
"nrLevels": 1
},
"inputs": {
"list": {
"connections": [
{
"node": "4060c9957222ebcd",
"output": "result",
"data": {}
}
]
}
},
"position": [
1697.3853300238575,
728.5089431594602
]
},
"00358cea88d40ae7": {
"id": "00358cea88d40ae7",
"name": "bitbybit.occt.shapes.face.createFaceFromWires",
"customName": "face from wires",
"async": true,
"drawable": true,
"data": {
"genericNodeData": {
"hide": true,
"oneOnOne": false,
"flatten": 0,
"forceExecution": false
},
"planar": true
},
"inputs": {
"shapes": {
"connections": [
{
"node": "5072ed908458bdad",
"output": "list",
"data": {}
}
]
}
},
"position": [
2875.3937112061635,
202.5056771050418
]
},
"5072ed908458bdad": {
"id": "5072ed908458bdad",
"name": "bitbybit.lists.createList",
"customName": "create list",
"data": {},
"inputs": {
"listElements": {
"connections": [
{
"node": "4fe8e8be91a7f5ba",
"output": "result",
"data": {}
},
{
"node": "77a1d4eeb5d51aeb",
"output": "result",
"data": {}
},
{
"node": "19d3bc1328a4d1dd",
"output": "result",
"data": {}
}
]
}
},
"position": [
2484.192308888684,
246.52802284002826
]
},
"4425aa07fdbe0e35": {
"id": "4425aa07fdbe0e35",
"name": "bitbybit.occt.operations.extrude",
"customName": "extrude",
"async": true,
"drawable": true,
"data": {
"genericNodeData": {
"hide": true,
"oneOnOne": false,
"flatten": 0,
"forceExecution": false
},
"direction": [
0,
1,
0
]
},
"inputs": {
"shape": {
"connections": [
{
"node": "00358cea88d40ae7",
"output": "result",
"data": {}
}
]
}
},
"position": [
3262.7843329641687,
200.30213198957557
]
},
"3cc3305e16a6d73a": {
"id": "3cc3305e16a6d73a",
"name": "bitbybit.occt.transforms.translate",
"customName": "translate",
"async": true,
"drawable": true,
"data": {
"genericNodeData": {
"hide": true,
"oneOnOne": false,
"flatten": 0,
"forceExecution": false
},
"translation": [
0,
0,
0
]
},
"inputs": {
"shape": {
"connections": [
{
"node": "c0321f9a85a6e6bc",
"output": "result",
"data": {}
}
]
},
"translation": {
"connections": [
{
"node": "2e4c94de1681cf77",
"output": "result",
"data": {}
}
]
}
},
"position": [
2428.1754726559784,
2126.157507059406
]
},
"9c83db7e8239f74e": {
"id": "9c83db7e8239f74e",
"name": "bitbybit.occt.operations.extrude",
"customName": "extrude",
"async": true,
"drawable": true,
"data": {
"genericNodeData": {
"hide": true,
"oneOnOne": false,
"flatten": 0,
"forceExecution": false
},
"direction": [
0,
1,
0
]
},
"inputs": {
"direction": {
"connections": [
{
"node": "c5efbda08b74a7d2",
"output": "result",
"data": {}
}
]
},
"shape": {
"connections": [
{
"node": "47267f55fd0dc09c",
"output": "result",
"data": {}
}
]
}
},
"position": [
1547.2312455459576,
1742.3182757154816
]
},
"c5efbda08b74a7d2": {
"id": "c5efbda08b74a7d2",
"name": "bitbybit.vector.vectorXYZ",
"customName": "vector xyz",
"async": false,
"drawable": true,
"data": {
"genericNodeData": {
"hide": true,
"oneOnOne": false,
"flatten": 0,
"forceExecution": false
},
"x": 0,
"y": 4,
"z": 0
},
"inputs": {},
"position": [
895.5136231726993,
2027.122560459715
]
},
"47267f55fd0dc09c": {
"id": "47267f55fd0dc09c",
"name": "bitbybit.occt.shapes.face.createCircleFace",
"customName": "circle face",
"async": true,
"drawable": true,
"data": {
"genericNodeData": {
"hide": true,
"oneOnOne": false,
"flatten": 0,
"forceExecution": false
},
"radius": 1,
"center": [
0,
0,
0
],
"direction": [
0,
1,
0
]
},
"inputs": {
"radius": {
"connections": [
{
"node": "2490c58c788f0566",
"output": "result",
"data": {}
}
]
},
"center": {
"connections": [
{
"node": "efc9692172f0e809",
"output": "result",
"data": {}
}
]
}
},
"position": [
897.026819330392,
1665.3984122841898
]
},
"efc9692172f0e809": {
"id": "efc9692172f0e809",
"name": "bitbybit.vector.vectorXYZ",
"customName": "vector xyz",
"async": false,
"drawable": true,
"data": {
"genericNodeData": {
"hide": true,
"oneOnOne": false,
"flatten": 0,
"forceExecution": false
},
"x": 0,
"y": -1.5,
"z": 0
},
"inputs": {},
"position": [
492.149966205328,
1705.9174505052958
]
},
"c0321f9a85a6e6bc": {
"id": "c0321f9a85a6e6bc",
"name": "bitbybit.occt.fillets.chamferEdges",
"customName": "chamfer edges",
"async": true,
"drawable": true,
"data": {
"genericNodeData": {
"hide": true,
"oneOnOne": false,
"flatten": 0,
"forceExecution": false
},
"distance": 0.4
},
"inputs": {
"shape": {
"connections": [
{
"node": "9c83db7e8239f74e",
"output": "result",
"data": {}
}
]
}
},
"position": [
1933.8961459964344,
1739.9618523510107
]
},
"b1f2db70c1008f7c": {
"id": "b1f2db70c1008f7c",
"name": "bitbybit.occt.fillets.chamferEdges",
"customName": "chamfer edges",
"async": true,
"drawable": true,
"data": {
"genericNodeData": {
"hide": true,
"oneOnOne": false,
"flatten": 0,
"forceExecution": false
},
"distance": 0.4
},
"inputs": {
"shape": {
"connections": [
{
"node": "4425aa07fdbe0e35",
"output": "result",
"data": {}
}
]
}
},
"position": [
3953.0963887440007,
199.18131032042854
]
},
"6c1f6c6b5b8649e2": {
"id": "6c1f6c6b5b8649e2",
"name": "bitbybit.draw.drawAnyAsync",
"customName": "draw any async",
"async": true,
"drawable": true,
"data": {
"genericNodeData": {
"hide": false,
"oneOnOne": false,
"flatten": 0,
"forceExecution": false
}
},
"inputs": {
"options": {
"connections": [
{
"node": "86336b0f9d2d252c",
"output": "result",
"data": {}
}
]
},
"entity": {
"connections": [
{
"node": "b1f2db70c1008f7c",
"output": "result",
"data": {}
}
]
}
},
"position": [
4789.389670057871,
205.98347025524913
]
},
"86336b0f9d2d252c": {
"id": "86336b0f9d2d252c",
"name": "bitbybit.draw.optionsOcctShapeSimple",
"customName": "options occt shape simple",
"async": false,
"drawable": false,
"data": {
"genericNodeData": {
"hide": false,
"oneOnOne": false,
"flatten": 0,
"forceExecution": false
},
"precision": 0.01,
"drawFaces": true,
"faceColour": "#001eff",
"drawEdges": true,
"edgeColour": "#ffffff",
"edgeWidth": 2,
"drawTwoSided": false,
"backFaceColour": "#0000ff",
"backFaceOpacity": 1
},
"inputs": {
"faceColour": {
"connections": [
{
"node": "6ec48045997edff0",
"output": "result",
"data": {}
}
]
}
},
"position": [
3952.6742368393698,
600.8920963947206
]
},
"54c64090204fedb9": {
"id": "54c64090204fedb9",
"name": "bitbybit.babylon.scene.drawDirectionalLight",
"customName": "draw directional light",
"async": false,
"drawable": false,
"data": {
"genericNodeData": {
"hide": false,
"oneOnOne": false,
"flatten": 0,
"forceExecution": false
},
"direction": [
-100,
-100,
-100
],
"intensity": 3,
"diffuse": "#ffffff",
"specular": "#ffffff",
"shadowGeneratorMapSize": 1024,
"enableShadows": true,
"shadowDarkness": 0,
"shadowUsePercentageCloserFiltering": true,
"transparencyShadow": false,
"shadowContactHardeningLightSizeUVRatio": 0.2,
"shadowBias": 0.0001,
"shadowNormalBias": 0.002,
"shadowMaxZ": 1000,
"shadowMinZ": 0,
"shadowRefreshRate": 1
},
"inputs": {
"direction": {
"connections": [
{
"node": "8b9f1863796ef844",
"output": "result",
"data": {}
}
]
}
},
"position": [
417.5983457425817,
2663.7591363527213
]
},
"9c2442cf2b23c8b8": {
"id": "9c2442cf2b23c8b8",
"name": "bitbybit.occt.assembly.manager.createPart",
"customName": "create part",
"async": true,
"drawable": false,
"data": {
"genericNodeData": {
"hide": false,
"oneOnOne": false,
"flatten": 0,
"forceExecution": false
},
"id": "base-with-holes",
"name": "Base With Holes",
"colorRgba": {
"r": 0.5,
"g": 0.5,
"b": 0.5,
"a": 1
}
},
"inputs": {
"colorRgba": {
"connections": [
{
"node": "a31d265397b0db2c",
"output": "result",
"data": {}
}
]
},
"shape": {
"connections": [
{
"node": "b1f2db70c1008f7c",
"output": "result",
"data": {}
}
]
}
},
"position": [
4963.231294877409,
1317.5873025740095
]
},
"a31d265397b0db2c": {
"id": "a31d265397b0db2c",
"name": "bitbybit.color.rgba1Color",
"customName": "rgba 1 color",
"async": false,
"drawable": false,
"data": {
"genericNodeData": {
"hide": false,
"oneOnOne": false,
"flatten": 0,
"forceExecution": false
},
"colorRgba": {
"r": 0,
"g": 0,
"b": 1,
"a": 1
}
},
"inputs": {},
"position": [
3011.3047531870516,
1441.7811478324286
]
},
"6ec48045997edff0": {
"id": "6ec48045997edff0",
"name": "bitbybit.color.rgbObjToHex",
"customName": "rgb obj to hex",
"async": false,
"drawable": false,
"data": {
"genericNodeData": {
"hide": false,
"oneOnOne": false,
"flatten": 0,
"forceExecution": false
},
"rgb": {
"r": 0,
"g": 0,
"b": 1
},
"min": 0,
"max": 1
},
"inputs": {
"rgb": {
"connections": [
{
"node": "a31d265397b0db2c",
"output": "result",
"data": {}
}
]
}
},
"position": [
3560.957619335378,
680.4396951212099
]
},
"c1ffc6bc5f489622": {
"id": "c1ffc6bc5f489622",
"name": "bitbybit.occt.assembly.manager.combineStructure",
"customName": "combine structure",
"async": true,
"drawable": false,
"data": {
"genericNodeData": {
"hide": false,
"oneOnOne": false,
"flatten": 0,
"forceExecution": false
},
"parts": [],
"nodes": [],
"clearDocument": false
},
"inputs": {
"parts": {
"connections": [
{
"node": "ae93183994c1b3af",
"output": "list",
"data": {}
}
]
},
"nodes": {
"connections": [
{
"node": "3e537c2b7d44085b",
"output": "list",
"data": {}
}
]
},
"removals": {
"connections": [
{
"node": "9fc457d753ed3400",
"output": "list",
"data": {}
}
]
},
"partUpdates": {
"connections": [
{
"node": "19dabb504f020b76",
"output": "list",
"data": {}
}
]
}
},
"position": [
6192.723669762441,
1778.8757833971981
]
},
"18365fb391f22df6": {
"id": "18365fb391f22df6",
"name": "bitbybit.occt.assembly.manager.createInstanceNode",
"customName": "create instance node",
"async": true,
"drawable": false,
"data": {
"genericNodeData": {
"hide": false,
"oneOnOne": false,
"flatten": 0,
"forceExecution": false
},
"id": "base-with-holes-id",
"partId": "base-with-holes",
"name": "Base With Holes Instance",
"parentId": "",
"translation": [
0,
0,
0
],
"rotation": [
0,
0,
0
],
"scale": 1,
"colorRgba": {
"r": 0,
"g": 0,
"b": 1,
"a": 1
}
},
"inputs": {
"colorRgba": {
"connections": [
{
"node": "a31d265397b0db2c",
"output": "result",
"data": {}
}
]
}
},
"position": [
4960.740311536943,
2485.354702318758
]
},
"1b50b9d990cb3056": {
"id": "1b50b9d990cb3056",
"name": "bitbybit.occt.assembly.manager.createAssemblyNode",
"customName": "create assembly node",
"async": true,
"drawable": false,
"data": {
"genericNodeData": {
"hide": false,
"oneOnOne": false,
"flatten": 0,
"forceExecution": false
},
"id": "assembly-node",
"name": "Bitbybit Assembly Example",
"parentId": "",
"colorRgba": {
"r": 0.5,
"g": 0.5,
"b": 0.5,
"a": 1
}
},
"inputs": {},
"position": [
4964.808588367014,
2094.733052114731
]
},
"3e537c2b7d44085b": {
"id": "3e537c2b7d44085b",
"name": "bitbybit.lists.createList",
"customName": "create list",
"data": {},
"inputs": {
"listElements": {
"connections": [
{
"node": "1b50b9d990cb3056",
"output": "result",
"data": {}
},
{
"node": "18365fb391f22df6",
"output": "result",
"data": {}
},
{
"node": "f72a39f256c98dcf",
"output": "result",
"data": {}
}
]
}
},
"position": [
5504.49420068239,
1888.09677357345
]
},
"ae93183994c1b3af": {
"id": "ae93183994c1b3af",
"name": "bitbybit.lists.createList",
"customName": "create list",
"data": {},
"inputs": {
"listElements": {
"connections": [
{
"node": "9c2442cf2b23c8b8",
"output": "result",
"data": {}
},
{
"node": "4438120ebff3fe5d",
"output": "result",
"data": {}
}
]
}
},
"position": [
5502.5788689302735,
1720.7438554058674
]
},
"d51ccbc3953afbfb": {
"id": "d51ccbc3953afbfb",
"name": "bitbybit.occt.assembly.manager.buildAssemblyDocument",
"customName": "build assembly document",
"async": true,
"drawable": false,
"data": {
"genericNodeData": {
"hide": false,
"oneOnOne": false,
"flatten": 0,
"forceExecution": false
}
},
"inputs": {
"structure": {
"connections": [
{
"node": "c1ffc6bc5f489622",
"output": "result",
"data": {}
}
]
}
},
"position": [
6579.951559225871,
1776.477635862857
]
},
"1a4b8fd5054696c5": {
"id": "1a4b8fd5054696c5",
"name": "bitbybit.occt.assembly.manager.exportDocumentToStep",
"customName": "export document to step",
"async": true,
"drawable": false,
"data": {
"genericNodeData": {
"hide": false,
"oneOnOne": false,
"flatten": 0,
"forceExecution": false
},
"fileName": "Bitbybit Assembly.stpZ",
"author": "Bitbybit user",
"organization": "Bitbybit",
"compress": true,
"tryDownload": true
},
"inputs": {
"document": {
"connections": [
{
"node": "d51ccbc3953afbfb",
"output": "result",
"data": {}
}
]
}
},
"position": [
6950.197906134728,
1773.5596282336016
]
},
"9fc457d753ed3400": {
"id": "9fc457d753ed3400",
"name": "bitbybit.lists.createList",
"customName": "create list",
"data": {},
"inputs": {},
"position": [
5504.811486963638,
2051.558689716352
]
},
"19dabb504f020b76": {
"id": "19dabb504f020b76",
"name": "bitbybit.lists.createList",
"customName": "create list",
"data": {},
"inputs": {},
"position": [
5507.042031820943,
2214.3198547314073
]
},
"f72a39f256c98dcf": {
"id": "f72a39f256c98dcf",
"name": "bitbybit.occt.assembly.manager.createInstanceNode",
"customName": "create instance node",
"async": true,
"drawable": false,
"data": {
"genericNodeData": {
"hide": false,
"oneOnOne": false,
"flatten": 0,
"forceExecution": false
},
"id": "plug-id",
"partId": "plug",
"name": "Plug",
"parentId": "",
"translation": [
0,
0,
0
],
"rotation": [
0,
0,
0
],
"scale": 1,
"colorRgba": {
"r": 0,
"g": 0,
"b": 1,
"a": 1
}
},
"inputs": {
"translation": {
"connections": [
{
"node": "d7d867d4d2aa3bf7",
"output": "item",
"data": {}
}
]
},
"colorRgba": {
"connections": [
{
"node": "81814fe4f15a8285",
"output": "result",
"data": {}
}
]
}
},
"position": [
4968.1147498041355,
3030.1762607621604
]
},
"4438120ebff3fe5d": {
"id": "4438120ebff3fe5d",
"name": "bitbybit.occt.assembly.manager.createPart",
"customName": "create part",
"async": true,
"drawable": false,
"data": {
"genericNodeData": {
"hide": false,
"oneOnOne": false,
"flatten": 0,
"forceExecution": false
},
"id": "plug",
"name": "Plug",
"colorRgba": {
"r": 0.5,
"g": 0.5,
"b": 0.5,
"a": 1
}
},
"inputs": {
"shape": {
"connections": [
{
"node": "c0321f9a85a6e6bc",
"output": "result",
"data": {}
}
]
}
},
"position": [
4963.09209876649,
1702.9640946409736
]
},
"984689ab9228f5d2": {
"id": "984689ab9228f5d2",
"name": "bitbybit.draw.drawAnyAsync",
"customName": "draw any async",
"async": true,
"drawable": true,
"data": {
"genericNodeData": {
"hide": false,
"oneOnOne": false,
"flatten": 0,
"forceExecution": false
}
},
"inputs": {
"options": {
"connections": [
{
"node": "0f77071b2ee7bae3",
"output": "result",
"data": {}
}
]
},
"entity": {
"connections": [
{
"node": "3cc3305e16a6d73a",
"output": "result",
"data": {}
}
]
}
},
"position": [
3436.051406615291,
3565.496580198114
]
},
"0f77071b2ee7bae3": {
"id": "0f77071b2ee7bae3",
"name": "bitbybit.draw.optionsOcctShapeSimple",
"customName": "options occt shape simple",
"async": false,
"drawable": false,
"data": {
"genericNodeData": {
"hide": false,
"oneOnOne": false,
"flatten": 0,
"forceExecution": false
},
"precision": 0.01,
"drawFaces": true,
"faceColour": "#001eff",
"drawEdges": true,
"edgeColour": "#ffffff",
"edgeWidth": 2,
"drawTwoSided": true,
"backFaceColour": "#0000ff",
"backFaceOpacity": 1
},
"inputs": {
"faceColour": {
"connections": [
{
"node": "a0d125bde4c99bae",
"output": "result",
"data": {}
}
]
}
},
"position": [
3016.676849378406,
3606.9498126918593
]
},
"a0d125bde4c99bae": {
"id": "a0d125bde4c99bae",
"name": "bitbybit.color.rgbObjToHex",
"customName": "rgb obj to hex",
"async": false,
"drawable": false,
"data": {
"genericNodeData": {
"hide": false,
"oneOnOne": false,
"flatten": 0,
"forceExecution": false
},
"rgb": {
"r": 0,
"g": 0,
"b": 1
},
"min": 0,
"max": 1
},
"inputs": {
"rgb": {
"connections": [
{
"node": "81814fe4f15a8285",
"output": "result",
"data": {}
}
]
}
},
"position": [
2641.5465861665057,
3686.8907699383594
]
},
"81814fe4f15a8285": {
"id": "81814fe4f15a8285",
"name": "bitbybit.color.rgba1Color",
"customName": "rgba 1 color",
"async": false,
"drawable": false,
"data": {
"genericNodeData": {
"hide": false,
"oneOnOne": false,
"flatten": 0,
"forceExecution": false
},
"colorRgba": {
"r": 0,
"g": 1,
"b": 0.01568627450980392,
"a": 1
}
},
"inputs": {},
"position": [
2075.309253613974,
3299.150864248012
]
},
"d7d867d4d2aa3bf7": {
"id": "d7d867d4d2aa3bf7",
"name": "bitbybit.lists.passThrough",
"customName": "pass through",
"data": {},
"inputs": {
"item": {
"connections": [
{
"node": "2e4c94de1681cf77",
"output": "result",
"data": {}
}
]
}
},
"position": [
4582.083263909205,
3218.3212895123734
]
},
"21319ce9881ffb81": {
"id": "21319ce9881ffb81",
"name": "bitbybit.babylon.scene.twoColorLinearGradientBackground",
"customName": "two color linear gradient background",
"async": false,
"drawable": false,
"data": {
"genericNodeData": {
"hide": false,
"oneOnOne": false,
"flatten": 0,
"forceExecution": false
},
"colorFrom": "#1a1c1f",
"colorTo": "#93aacd",
"direction": "to top",
"stopFrom": 0,
"stopTo": 100
},
"inputs": {},
"position": [
480.51796789296566,
3549.770333178538
]
},
"19d3bc1328a4d1dd": {
"id": "19d3bc1328a4d1dd",
"name": "bitbybit.occt.shapes.wire.createNGonWire",
"customName": "ngon wire",
"async": true,
"drawable": true,
"data": {
"genericNodeData": {
"hide": true,
"oneOnOne": false,
"flatten": 0,
"forceExecution": false
},
"center": [
0,
0,
0
],
"direction": [
0,
1,
0
],
"nrCorners": 6,
"radius": 4
},
"inputs": {},
"position": [
1639.6052854704194,
-150.09986787079708
]
},
"8b9f1863796ef844": {
"id": "8b9f1863796ef844",
"name": "bitbybit.vector.vectorXYZ",
"customName": "vector xyz",
"async": false,
"drawable": true,
"data": {
"genericNodeData": {
"hide": true,
"oneOnOne": false,
"flatten": 0,
"forceExecution": false
},
"x": -20,
"y": -20,
"z": -20
},
"inputs": {},
"position": [
59.97413526472212,
2681.210966919593
]
}
}
}
<xml xmlns="https://developers.google.com/blockly/xml"><variables><variable id="mainRadius">mainRadius</variable><variable id="fromOuterRadius">fromOuterRadius</variable><variable id="jm#sdZ7BQe8p!mx4[D0l">bg</variable><variable id="innerRadius">innerRadius</variable><variable id="plugRadius">plugRadius</variable><variable id="outerCircleWire">outerCircleWire</variable><variable id="innerCircleWire">innerCircleWire</variable><variable id="dividedPoints">dividedPoints</variable><variable id="pointsList">pointsList</variable><variable id="pt">pt</variable><variable id="smallCircleWire">smallCircleWire</variable><variable id="reversedWire">reversedWire</variable><variable id="translatedWires">translatedWires</variable><variable id="i">i</variable><variable id="ngonWire">ngonWire</variable><variable id="wiresList">wiresList</variable><variable id="baseFace">baseFace</variable><variable id="baseExtruded">baseExtruded</variable><variable id="baseChamfered">baseChamfered</variable><variable id="plugFace">plugFace</variable><variable id="plugExtruded">plugExtruded</variable><variable id="plugChamfered">plugChamfered</variable><variable id="translatedPlugs">translatedPlugs</variable><variable id="basePart">basePart</variable><variable id="plugPart">plugPart</variable><variable id="assemblyNode">assemblyNode</variable><variable id="baseInstanceNode">baseInstanceNode</variable><variable id="plugInstanceNodes">plugInstanceNodes</variable><variable id="partsList">partsList</variable><variable id="nodesList">nodesList</variable><variable id="structure">structure</variable><variable id="document">document</variable><variable id="Mb()}8/+y6g[2_r|@C/{">exportedDoc</variable></variables><block type="variables_set" id="setMainRadius" x="-355" y="-79"><field name="VAR" id="mainRadius">mainRadius</field><value name="VALUE"><block type="math_number" id="mainRadiusVal"><field name="NUM">13.3</field></block></value><next><block type="variables_set" id="setFromOuter"><field name="VAR" id="fromOuterRadius">fromOuterRadius</field><value name="VALUE"><block type="math_number" id="fromOuterVal"><field name="NUM">4</field></block></value><next><block type="variables_set" id="setInnerRadius"><field name="VAR" id="innerRadius">innerRadius</field><value name="VALUE"><block type="math_arithmetic" id="calcInner"><field name="OP">MINUS</field><value name="A"><block type="variables_get" id="getMain1"><field name="VAR" id="mainRadius">mainRadius</field></block></value><value name="B"><block type="variables_get" id="getFromOuter1"><field name="VAR" id="fromOuterRadius">fromOuterRadius</field></block></value></block></value><next><block type="variables_set" id="setPlugRadius"><field name="VAR" id="plugRadius">plugRadius</field><value name="VALUE"><block type="math_arithmetic" id="calcPlugRadius"><field name="OP">DIVIDE</field><value name="A"><block type="variables_get" id="getFromOuter2"><field name="VAR" id="fromOuterRadius">fromOuterRadius</field></block></value><value name="B"><block type="math_number" id="three"><field name="NUM">3</field></block></value></block></value><next><block type="variables_set" id="setOuterWire"><field name="VAR" id="outerCircleWire">outerCircleWire</field><value name="VALUE"><block type="base_time_await_return" id="awaitOuter"><value name="Promise"><block type="bitbybit.occt.shapes.wire.createCircleWire" id="createOuterWire"><value name="Radius"><block type="variables_get" id="getMainRadius"><field name="VAR" id="mainRadius">mainRadius</field></block></value><value name="Center"><block type="bitbybit.vector.vectorXYZ" id="outerCenter"><value name="X"><block type="math_number" id="ox"><field name="NUM">0</field></block></value><value name="Y"><block type="math_number" id="oy"><field name="NUM">0</field></block></value><value name="Z"><block type="math_number" id="oz"><field name="NUM">0</field></block></value></block></value><value name="Direction"><block type="bitbybit.vector.vectorXYZ" id="outerDir"><value name="X"><block type="math_number" id="odx"><field name="NUM">0</field></block></value><value name="Y"><block type="math_number" id="ody"><field name="NUM">1</field></block></value><value name="Z"><block type="math_number" id="odz"><field name="NUM">0</field></block></value></block></value></block></value></block></value><next><block type="variables_set" id="setInnerWire"><field name="VAR" id="innerCircleWire">innerCircleWire</field><value name="VALUE"><block type="base_time_await_return" id="awaitInner"><value name="Promise"><block type="bitbybit.occt.shapes.wire.createCircleWire" id="createInnerWire"><value name="Radius"><block type="variables_get" id="getInnerRadius"><field name="VAR" id="innerRadius">innerRadius</field></block></value><value name="Center"><block type="bitbybit.vector.vectorXYZ" id="innerCenter"><value name="X"><block type="math_number" id="ix"><field name="NUM">0</field></block></value><value name="Y"><block type="math_number" id="iy"><field name="NUM">0</field></block></value><value name="Z"><block type="math_number" id="iz"><field name="NUM">0</field></block></value></block></value><value name="Direction"><block type="bitbybit.vector.vectorXYZ" id="innerDir"><value name="X"><block type="math_number" id="idx"><field name="NUM">0</field></block></value><value name="Y"><block type="math_number" id="idy"><field name="NUM">1</field></block></value><value name="Z"><block type="math_number" id="idz"><field name="NUM">0</field></block></value></block></value></block></value></block></value><next><block type="variables_set" id="setDividedPoints"><field name="VAR" id="dividedPoints">dividedPoints</field><value name="VALUE"><block type="base_time_await_return" id="awaitDivide"><value name="Promise"><block type="bitbybit.occt.shapes.wire.divideWireByParamsToPoints" id="divideWire"><value name="Shape"><block type="variables_get" id="getInnerWireForDivide"><field name="VAR" id="innerCircleWire">innerCircleWire</field></block></value><value name="NrOfDivisions"><block type="math_number" id="nrDiv"><field name="NUM">14</field></block></value><value name="RemoveStartPoint"><block type="logic_boolean" id="removeStart"><field name="BOOL">FALSE</field></block></value><value name="RemoveEndPoint"><block type="logic_boolean" id="removeEnd"><field name="BOOL">TRUE</field></block></value></block></value></block></value><next><block type="variables_set" id="setPointsList"><field name="VAR" id="pointsList">pointsList</field><value name="VALUE"><block type="lists_create_with" id="createPointsList"><mutation items="0"></mutation></block></value><next><block type="controls_forEach" id="loopPoints"><field name="VAR" id="pt">pt</field><value name="LIST"><block type="variables_get" id="getDividedPoints"><field name="VAR" id="dividedPoints">dividedPoints</field></block></value><statement name="DO"><block type="lists_setIndex" id="addPoint"><mutation at="false"></mutation><field name="MODE">INSERT</field><field name="WHERE">LAST</field><value name="LIST"><block type="variables_get" id="getPointsList"><field name="VAR" id="pointsList">pointsList</field></block></value><value name="TO"><block type="variables_get" id="getPt"><field name="VAR" id="pt">pt</field></block></value></block></statement><next><block type="variables_set" id="setSmallWire"><field name="VAR" id="smallCircleWire">smallCircleWire</field><value name="VALUE"><block type="base_time_await_return" id="awaitSmall"><value name="Promise"><block type="bitbybit.occt.shapes.wire.createCircleWire" id="createSmallWire"><value name="Radius"><block type="variables_get" id="getPlugRadius"><field name="VAR" id="plugRadius">plugRadius</field></block></value><value name="Center"><block type="bitbybit.vector.vectorXYZ" id="smallCenter"><value name="X"><block type="math_number" id="sx"><field name="NUM">0</field></block></value><value name="Y"><block type="math_number" id="sy"><field name="NUM">0</field></block></value><value name="Z"><block type="math_number" id="sz"><field name="NUM">0</field></block></value></block></value><value name="Direction"><block type="bitbybit.vector.vectorXYZ" id="smallDir"><value name="X"><block type="math_number" id="sdx"><field name="NUM">0</field></block></value><value name="Y"><block type="math_number" id="sdy"><field name="NUM">1</field></block></value><value name="Z"><block type="math_number" id="sdz"><field name="NUM">0</field></block></value></block></value></block></value></block></value><next><block type="variables_set" id="setReversedWire"><field name="VAR" id="reversedWire">reversedWire</field><value name="VALUE"><block type="base_time_await_return" id="awaitReverse"><value name="Promise"><block type="bitbybit.occt.shapes.wire.reversedWire" id="reverseWire"><value name="Shape"><block type="variables_get" id="getSmallWire"><field name="VAR" id="smallCircleWire">smallCircleWire</field></block></value></block></value></block></value><next><block type="variables_set" id="setTranslatedWires"><field name="VAR" id="translatedWires">translatedWires</field><value name="VALUE"><block type="lists_create_with" id="createTranslatedList"><mutation items="0"></mutation></block></value><next><block type="controls_for" id="loopTranslate"><field name="VAR" id="i">i</field><value name="FROM"><block type="math_number" id="from1"><field name="NUM">1</field></block></value><value name="TO"><block type="lists_length" id="lenPoints"><value name="VALUE"><block type="variables_get" id="getPointsLen"><field name="VAR" id="pointsList">pointsList</field></block></value></block></value><value name="BY"><block type="math_number" id="by1"><field name="NUM">1</field></block></value><statement name="DO"><block type="lists_setIndex" id="addTranslated"><mutation at="false"></mutation><field name="MODE">INSERT</field><field name="WHERE">LAST</field><value name="LIST"><block type="variables_get" id="getTransWires"><field name="VAR" id="translatedWires">translatedWires</field></block></value><value name="TO"><block type="base_time_await_return" id="awaitTransWire"><value name="Promise"><block type="bitbybit.occt.transforms.translate" id="translateWire"><value name="Shape"><block type="variables_get" id="getRevWire"><field name="VAR" id="reversedWire">reversedWire</field></block></value><value name="Translation"><block type="lists_getIndex" id="getPointAtI"><mutation statement="false" at="true"></mutation><field name="MODE">GET</field><field name="WHERE">FROM_START</field><value name="VALUE"><block type="variables_get" id="getPtsForIdx"><field name="VAR" id="pointsList">pointsList</field></block></value><value name="AT"><block type="variables_get" id="getI"><field name="VAR" id="i">i</field></block></value></block></value></block></value></block></value></block></statement><next><block type="variables_set" id="setNgon"><field name="VAR" id="ngonWire">ngonWire</field><value name="VALUE"><block type="base_time_await_return" id="awaitNgon"><value name="Promise"><block type="bitbybit.occt.shapes.wire.createNGonWire" id="createNgon"><value name="Center"><block type="bitbybit.vector.vectorXYZ" id="ngonCenter"><value name="X"><block type="math_number" id="nx"><field name="NUM">0</field></block></value><value name="Y"><block type="math_number" id="ny"><field name="NUM">0</field></block></value><value name="Z"><block type="math_number" id="nz"><field name="NUM">0</field></block></value></block></value><value name="Direction"><block type="bitbybit.vector.vectorXYZ" id="ngonDir"><value name="X"><block type="math_number" id="ndx"><field name="NUM">0</field></block></value><value name="Y"><block type="math_number" id="ndy"><field name="NUM">1</field></block></value><value name="Z"><block type="math_number" id="ndz"><field name="NUM">0</field></block></value></block></value><value name="NrCorners"><block type="math_number" id="corners"><field name="NUM">6</field></block></value><value name="Radius"><block type="math_number" id="ngonRad"><field name="NUM">4</field></block></value></block></value></block></value><next><block type="variables_set" id="setWiresList"><field name="VAR" id="wiresList">wiresList</field><value name="VALUE"><block type="lists_create_with" id="createWiresList"><mutation items="2"></mutation><value name="ADD0"><block type="variables_get" id="getOuterWire"><field name="VAR" id="outerCircleWire">outerCircleWire</field></block></value><value name="ADD1"><block type="variables_get" id="getNgonWire"><field name="VAR" id="ngonWire">ngonWire</field></block></value></block></value><next><block type="controls_forEach" id="loopAddTransWires"><field name="VAR" id="pt">pt</field><value name="LIST"><block type="variables_get" id="getTransWiresForAdd"><field name="VAR" id="translatedWires">translatedWires</field></block></value><statement name="DO"><block type="lists_setIndex" id="addWireToList"><mutation at="false"></mutation><field name="MODE">INSERT</field><field name="WHERE">LAST</field><value name="LIST"><block type="variables_get" id="getWiresList"><field name="VAR" id="wiresList">wiresList</field></block></value><value name="TO"><block type="variables_get" id="getPtWire"><field name="VAR" id="pt">pt</field></block></value></block></statement><next><block type="variables_set" id="setBaseFace"><field name="VAR" id="baseFace">baseFace</field><value name="VALUE"><block type="base_time_await_return" id="awaitFace"><value name="Promise"><block type="bitbybit.occt.shapes.face.createFaceFromWires" id="createFace"><value name="Shapes"><block type="variables_get" id="getWiresListForFace"><field name="VAR" id="wiresList">wiresList</field></block></value><value name="Planar"><block type="logic_boolean" id="planarTrue"><field name="BOOL">TRUE</field></block></value></block></value></block></value><next><block type="variables_set" id="setBaseExtruded"><field name="VAR" id="baseExtruded">baseExtruded</field><value name="VALUE"><block type="base_time_await_return" id="awaitExtrude1"><value name="Promise"><block type="bitbybit.occt.operations.extrude" id="extrudeBase"><value name="Shape"><block type="variables_get" id="getBaseFace"><field name="VAR" id="baseFace">baseFace</field></block></value><value name="Direction"><block type="bitbybit.vector.vectorXYZ" id="extDir1"><value name="X"><block type="math_number" id="ex1"><field name="NUM">0</field></block></value><value name="Y"><block type="math_number" id="ey1"><field name="NUM">1</field></block></value><value name="Z"><block type="math_number" id="ez1"><field name="NUM">0</field></block></value></block></value></block></value></block></value><next><block type="variables_set" id="setBaseChamfered"><field name="VAR" id="baseChamfered">baseChamfered</field><value name="VALUE"><block type="base_time_await_return" id="awaitChamfer1"><value name="Promise"><block type="bitbybit.occt.fillets.chamferEdges" id="chamferBase"><value name="Shape"><block type="variables_get" id="getBaseExtruded"><field name="VAR" id="baseExtruded">baseExtruded</field></block></value><value name="Distance"><block type="math_number" id="chamferDist1"><field name="NUM">0.4</field></block></value></block></value></block></value><next><block type="variables_set" id="setPlugFace"><field name="VAR" id="plugFace">plugFace</field><value name="VALUE"><block type="base_time_await_return" id="awaitPlugFace"><value name="Promise"><block type="bitbybit.occt.shapes.face.createCircleFace" id="createPlugFace"><value name="Radius"><block type="variables_get" id="getPlugRadius2"><field name="VAR" id="plugRadius">plugRadius</field></block></value><value name="Center"><block type="bitbybit.vector.vectorXYZ" id="plugFaceCenter"><value name="X"><block type="math_number" id="pfx"><field name="NUM">0</field></block></value><value name="Y"><block type="math_number" id="pfy"><field name="NUM">-1.5</field></block></value><value name="Z"><block type="math_number" id="pfz"><field name="NUM">0</field></block></value></block></value><value name="Direction"><block type="bitbybit.vector.vectorXYZ" id="plugFaceDir"><value name="X"><block type="math_number" id="pfdx"><field name="NUM">0</field></block></value><value name="Y"><block type="math_number" id="pfdy"><field name="NUM">1</field></block></value><value name="Z"><block type="math_number" id="pfdz"><field name="NUM">0</field></block></value></block></value></block></value></block></value><next><block type="variables_set" id="setPlugExtruded"><field name="VAR" id="plugExtruded">plugExtruded</field><value name="VALUE"><block type="base_time_await_return" id="awaitPlugExtrude"><value name="Promise"><block type="bitbybit.occt.operations.extrude" id="extrudePlug"><value name="Shape"><block type="variables_get" id="getPlugFace"><field name="VAR" id="plugFace">plugFace</field></block></value><value name="Direction"><block type="bitbybit.vector.vectorXYZ" id="plugExtDir"><value name="X"><block type="math_number" id="pex"><field name="NUM">0</field></block></value><value name="Y"><block type="math_number" id="pey"><field name="NUM">4</field></block></value><value name="Z"><block type="math_number" id="pez"><field name="NUM">0</field></block></value></block></value></block></value></block></value><next><block type="variables_set" id="setPlugChamfered"><field name="VAR" id="plugChamfered">plugChamfered</field><value name="VALUE"><block type="base_time_await_return" id="awaitPlugChamfer"><value name="Promise"><block type="bitbybit.occt.fillets.chamferEdges" id="chamferPlug"><value name="Shape"><block type="variables_get" id="getPlugExtruded"><field name="VAR" id="plugExtruded">plugExtruded</field></block></value><value name="Distance"><block type="math_number" id="chamferDist2"><field name="NUM">0.4</field></block></value></block></value></block></value><next><block type="variables_set" id="setTranslatedPlugs"><field name="VAR" id="translatedPlugs">translatedPlugs</field><value name="VALUE"><block type="lists_create_with" id="createPlugsList"><mutation items="0"></mutation></block></value><next><block type="controls_for" id="loopTransPlugs"><field name="VAR" id="i">i</field><value name="FROM"><block type="math_number" id="from2"><field name="NUM">1</field></block></value><value name="TO"><block type="lists_length" id="lenPoints2"><value name="VALUE"><block type="variables_get" id="getPointsLen2"><field name="VAR" id="pointsList">pointsList</field></block></value></block></value><value name="BY"><block type="math_number" id="by2"><field name="NUM">1</field></block></value><statement name="DO"><block type="lists_setIndex" id="addTransPlug"><mutation at="false"></mutation><field name="MODE">INSERT</field><field name="WHERE">LAST</field><value name="LIST"><block type="variables_get" id="getTransPlugs"><field name="VAR" id="translatedPlugs">translatedPlugs</field></block></value><value name="TO"><block type="base_time_await_return" id="awaitTransPlug"><value name="Promise"><block type="bitbybit.occt.transforms.translate" id="translatePlug"><value name="Shape"><block type="variables_get" id="getPlugChamf"><field name="VAR" id="plugChamfered">plugChamfered</field></block></value><value name="Translation"><block type="lists_getIndex" id="getPointAtI2"><mutation statement="false" at="true"></mutation><field name="MODE">GET</field><field name="WHERE">FROM_START</field><value name="VALUE"><block type="variables_get" id="getPtsForIdx2"><field name="VAR" id="pointsList">pointsList</field></block></value><value name="AT"><block type="variables_get" id="getI2"><field name="VAR" id="i">i</field></block></value></block></value></block></value></block></value></block></statement><next><block type="bitbybit.draw.drawAnyAsyncNoReturn" id="drawBase"><value name="Entity"><block type="variables_get" id="getBaseChamf"><field name="VAR" id="baseChamfered">baseChamfered</field></block></value><value name="Options"><block type="bitbybit.draw.optionsOcctShapeSimple" id="baseDrawOpt"><value name="Precision"><block type="math_number" id="prec1"><field name="NUM">0.01</field></block></value><value name="DrawFaces"><block type="logic_boolean" id="df1"><field name="BOOL">TRUE</field></block></value><value name="FaceColour"><block type="colour_picker" id="%Cq(}.Tmx%rb5:=J[X+D"><field name="COLOUR">#3333ff</field></block></value><value name="DrawEdges"><block type="logic_boolean" id="de1"><field name="BOOL">TRUE</field></block></value><value name="EdgeColour"><block type="colour_picker" id="ec1"><field name="COLOUR">#ffffff</field></block></value><value name="EdgeWidth"><block type="math_number" id="ew1"><field name="NUM">2</field></block></value><value name="DrawTwoSided"><block type="logic_boolean" id="dts1"><field name="BOOL">FALSE</field></block></value><value name="BackFaceColour"><block type="colour_picker" id="bfc1"><field name="COLOUR">#0000ff</field></block></value><value name="BackFaceOpacity"><block type="math_number" id="bfo1"><field name="NUM">1</field></block></value></block></value><next><block type="bitbybit.draw.drawAnyAsyncNoReturn" id="drawPlugs"><value name="Entity"><block type="variables_get" id="getTransPlugsDraw"><field name="VAR" id="translatedPlugs">translatedPlugs</field></block></value><value name="Options"><block type="bitbybit.draw.optionsOcctShapeSimple" id="plugDrawOpt"><value name="Precision"><block type="math_number" id="prec2"><field name="NUM">0.01</field></block></value><value name="DrawFaces"><block type="logic_boolean" id="df2"><field name="BOOL">TRUE</field></block></value><value name="FaceColour"><block type="colour_picker" id="sLA?G~F*7oA6E4IJJ#6D"><field name="COLOUR">#33ff33</field></block></value><value name="DrawEdges"><block type="logic_boolean" id="de2"><field name="BOOL">TRUE</field></block></value><value name="EdgeColour"><block type="colour_picker" id="ec2"><field name="COLOUR">#ffffff</field></block></value><value name="EdgeWidth"><block type="math_number" id="ew2"><field name="NUM">2</field></block></value><value name="DrawTwoSided"><block type="logic_boolean" id="dts2"><field name="BOOL">TRUE</field></block></value><value name="BackFaceColour"><block type="colour_picker" id="bfc2"><field name="COLOUR">#0000ff</field></block></value><value name="BackFaceOpacity"><block type="math_number" id="bfo2"><field name="NUM">1</field></block></value></block></value><next><block type="variables_set" id="setBasePart"><field name="VAR" id="basePart">basePart</field><value name="VALUE"><block type="base_time_await_return" id="awaitBasePart"><value name="Promise"><block type="bitbybit.occt.assembly.manager.createPart" id="createBasePart"><value name="Id"><block type="text" id="basePartId"><field name="TEXT">base-with-holes</field></block></value><value name="Shape"><block type="variables_get" id="getBaseChamf2"><field name="VAR" id="baseChamfered">baseChamfered</field></block></value><value name="Name"><block type="text" id="basePartName"><field name="TEXT">Base With Holes</field></block></value></block></value></block></value><next><block type="variables_set" id="setPlugPart"><field name="VAR" id="plugPart">plugPart</field><value name="VALUE"><block type="base_time_await_return" id="awaitPlugPart"><value name="Promise"><block type="bitbybit.occt.assembly.manager.createPart" id="createPlugPart"><value name="Id"><block type="text" id="plugPartId"><field name="TEXT">plug</field></block></value><value name="Shape"><block type="variables_get" id="getPlugChamf2"><field name="VAR" id="plugChamfered">plugChamfered</field></block></value><value name="Name"><block type="text" id="plugPartName"><field name="TEXT">Plug</field></block></value></block></value></block></value><next><block type="variables_set" id="setAssemblyNode"><field name="VAR" id="assemblyNode">assemblyNode</field><value name="VALUE"><block type="base_time_await_return" id="awaitAssembly"><value name="Promise"><block type="bitbybit.occt.assembly.manager.createAssemblyNode" id="createAssemblyNode"><value name="Id"><block type="text" id="assemblyId"><field name="TEXT">assembly-node</field></block></value><value name="Name"><block type="text" id="assemblyName"><field name="TEXT">Bitbybit Assembly Example</field></block></value><value name="ParentId"><block type="text" id="assemblyParent"><field name="TEXT"></field></block></value></block></value></block></value><next><block type="variables_set" id="setBaseInstance"><field name="VAR" id="baseInstanceNode">baseInstanceNode</field><value name="VALUE"><block type="base_time_await_return" id="awaitBaseInst"><value name="Promise"><block type="bitbybit.occt.assembly.manager.createInstanceNode" id="createBaseInstance"><value name="Id"><block type="text" id="baseInstId"><field name="TEXT">base-with-holes-id</field></block></value><value name="PartId"><block type="text" id="baseInstPartId"><field name="TEXT">base-with-holes</field></block></value><value name="Name"><block type="text" id="baseInstName"><field name="TEXT">Base With Holes Instance</field></block></value><value name="ParentId"><block type="text" id="baseInstParent"><field name="TEXT"></field></block></value><value name="Translation"><block type="bitbybit.vector.vectorXYZ" id="baseInstTrans"><value name="X"><block type="math_number" id="bitx"><field name="NUM">0</field></block></value><value name="Y"><block type="math_number" id="bity"><field name="NUM">0</field></block></value><value name="Z"><block type="math_number" id="bitz"><field name="NUM">0</field></block></value></block></value><value name="Rotation"><block type="bitbybit.vector.vectorXYZ" id="baseInstRot"><value name="X"><block type="math_number" id="birx"><field name="NUM">0</field></block></value><value name="Y"><block type="math_number" id="biry"><field name="NUM">0</field></block></value><value name="Z"><block type="math_number" id="birz"><field name="NUM">0</field></block></value></block></value><value name="Scale"><block type="math_number" id="baseInstScale"><field name="NUM">1</field></block></value><value name="ColorRgba"><block type="bitbybit.color.hexToRgbMapped" id=".2H@--*3W})QQO4[6ABS"><value name="Color"><block type="colour_picker" id="^qZ{x,~9U0nK%maLyOm/"><field name="COLOUR">#0000ff</field></block></value><value name="From"><block type="math_number" id="H!Eau#~!F{OaDys;kWGS"><field name="NUM">0</field></block></value><value name="To"><block type="math_number" id="]BoZmA(sxO+k7q{ZScGz"><field name="NUM">1</field></block></value></block></value></block></value></block></value><next><block type="variables_set" id="setPlugInstNodes"><field name="VAR" id="plugInstanceNodes">plugInstanceNodes</field><value name="VALUE"><block type="lists_create_with" id="createPlugInstList"><mutation items="0"></mutation></block></value><next><block type="controls_for" id="loopPlugInst"><field name="VAR" id="i">i</field><value name="FROM"><block type="math_number" id="from3"><field name="NUM">1</field></block></value><value name="TO"><block type="lists_length" id="lenPoints3"><value name="VALUE"><block type="variables_get" id="getPointsLen3"><field name="VAR" id="pointsList">pointsList</field></block></value></block></value><value name="BY"><block type="math_number" id="by3"><field name="NUM">1</field></block></value><statement name="DO"><block type="lists_setIndex" id="addPlugInst"><mutation at="false"></mutation><field name="MODE">INSERT</field><field name="WHERE">LAST</field><value name="LIST"><block type="variables_get" id="getPlugInstNodes"><field name="VAR" id="plugInstanceNodes">plugInstanceNodes</field></block></value><value name="TO"><block type="base_time_await_return" id="awaitPlugInst"><value name="Promise"><block type="bitbybit.occt.assembly.manager.createInstanceNode" id="createPlugInstance"><value name="Id"><block type="text_join" id="plugInstIdJoin"><mutation items="2"></mutation><value name="ADD0"><block type="text" id="plugIdPrefix"><field name="TEXT">plug-id-</field></block></value><value name="ADD1"><block type="variables_get" id="getIForId"><field name="VAR" id="i">i</field></block></value></block></value><value name="PartId"><block type="text" id="plugInstPartId"><field name="TEXT">plug</field></block></value><value name="Name"><block type="text" id="plugInstName"><field name="TEXT">Plug</field></block></value><value name="ParentId"><block type="text" id="plugInstParent"><field name="TEXT"></field></block></value><value name="Translation"><block type="lists_getIndex" id="getPointAtI3"><mutation statement="false" at="true"></mutation><field name="MODE">GET</field><field name="WHERE">FROM_START</field><value name="VALUE"><block type="variables_get" id="getPtsForIdx3"><field name="VAR" id="pointsList">pointsList</field></block></value><value name="AT"><block type="variables_get" id="getI3"><field name="VAR" id="i">i</field></block></value></block></value><value name="Rotation"><block type="bitbybit.vector.vectorXYZ" id="plugInstRot"><value name="X"><block type="math_number" id="pirx"><field name="NUM">0</field></block></value><value name="Y"><block type="math_number" id="piry"><field name="NUM">0</field></block></value><value name="Z"><block type="math_number" id="pirz"><field name="NUM">0</field></block></value></block></value><value name="Scale"><block type="math_number" id="plugInstScale"><field name="NUM">1</field></block></value><value name="ColorRgba"><block type="bitbybit.color.hexToRgbMapped" id="z9eGnGsN#$o%OC6Z,|DG"><value name="Color"><block type="colour_picker" id="S9Q%(8MpOfBBsa+.q|{9"><field name="COLOUR">#33ff33</field></block></value><value name="From"><block type="math_number" id="JLp)bF^-6O[8LsJxjo~C"><field name="NUM">0</field></block></value><value name="To"><block type="math_number" id="]`*z`},Eq0R`=Hyz[},#"><field name="NUM">1</field></block></value></block></value></block></value></block></value></block></statement><next><block type="variables_set" id="setPartsList"><field name="VAR" id="partsList">partsList</field><value name="VALUE"><block type="lists_create_with" id="createPartsList"><mutation items="2"></mutation><value name="ADD0"><block type="variables_get" id="getBasePart"><field name="VAR" id="basePart">basePart</field></block></value><value name="ADD1"><block type="variables_get" id="getPlugPart"><field name="VAR" id="plugPart">plugPart</field></block></value></block></value><next><block type="variables_set" id="setNodesList"><field name="VAR" id="nodesList">nodesList</field><value name="VALUE"><block type="lists_create_with" id="createNodesList"><mutation items="2"></mutation><value name="ADD0"><block type="variables_get" id="getAssNode"><field name="VAR" id="assemblyNode">assemblyNode</field></block></value><value name="ADD1"><block type="variables_get" id="getBaseInst"><field name="VAR" id="baseInstanceNode">baseInstanceNode</field></block></value></block></value><next><block type="controls_forEach" id="loopAddPlugNodes"><field name="VAR" id="pt">pt</field><value name="LIST"><block type="variables_get" id="getPlugInstNodesAdd"><field name="VAR" id="plugInstanceNodes">plugInstanceNodes</field></block></value><statement name="DO"><block type="lists_setIndex" id="addPlugNodeToList"><mutation at="false"></mutation><field name="MODE">INSERT</field><field name="WHERE">LAST</field><value name="LIST"><block type="variables_get" id="getNodesListAdd"><field name="VAR" id="nodesList">nodesList</field></block></value><value name="TO"><block type="variables_get" id="getPtNode"><field name="VAR" id="pt">pt</field></block></value></block></statement><next><block type="variables_set" id="setStructure"><field name="VAR" id="structure">structure</field><value name="VALUE"><block type="base_time_await_return" id="awaitStructure"><value name="Promise"><block type="bitbybit.occt.assembly.manager.combineStructure" id="combineStructure"><value name="Parts"><block type="variables_get" id="getPartsList"><field name="VAR" id="partsList">partsList</field></block></value><value name="Nodes"><block type="variables_get" id="getNodesList"><field name="VAR" id="nodesList">nodesList</field></block></value><value name="Removals"><block type="lists_create_with" id="emptyRemovals"><mutation items="0"></mutation></block></value><value name="PartUpdates"><block type="lists_create_with" id="emptyUpdates"><mutation items="0"></mutation></block></value><value name="ClearDocument"><block type="logic_boolean" id="clearDoc"><field name="BOOL">FALSE</field></block></value></block></value></block></value><next><block type="variables_set" id="setDocument"><field name="VAR" id="document">document</field><value name="VALUE"><block type="base_time_await_return" id="awaitBuild"><value name="Promise"><block type="bitbybit.occt.assembly.manager.buildAssemblyDocument" id="buildDoc"><value name="Structure"><block type="variables_get" id="getStructure"><field name="VAR" id="structure">structure</field></block></value></block></value></block></value><next><block type="variables_set" id="mLTVF2C9Mf[r:$-l.-2z"><field name="VAR" id="Mb()}8/+y6g[2_r|@C/{">exportedDoc</field><value name="VALUE"><block type="bitbybit.occt.assembly.manager.exportDocumentToStep" id="DJ*T##qivTd]Mtz0/9g]"><value name="Document"><block type="variables_get" id="h!D^AP7D,:3/9[Bt+[LJ"><field name="VAR" id="document">document</field></block></value><value name="FileName"><block type="text" id="o@Yq58,e@paLqF1MJb:A"><field name="TEXT">Bitbybit Assembly.stpZ</field></block></value><value name="Author"><block type="text" id="]kcVOP5[pC.3yoz9PpK{"><field name="TEXT">Bitbybit user</field></block></value><value name="Organization"><block type="text" id=":[z!30_Ecj:B*j~^oRa["><field name="TEXT">Bitbybit</field></block></value><value name="Compress"><block type="logic_boolean" id="ZE!~XC0J!LP5UrF^T(Ad"><field name="BOOL">TRUE</field></block></value><value name="TryDownload"><block type="logic_boolean" id="VIaw$aFl8I|6jqqwd?2E"><field name="BOOL">TRUE</field></block></value></block></value></block></next></block></next></block></next></block></next></block></next></block></next></block></next></block></next></block></next></block></next></block></next></block></next></block></next></block></next></block></next></block></next></block></next></block></next></block></next></block></next></block></next></block></next></block></next></block></next></block></next></block></next></block></next></block></next></block></next></block></next></block></next></block></next></block></next></block></next></block></next></block></next></block></next></block><block type="bitbybit.babylon.scene.drawDirectionalLightNoReturn" id="^j!`~}:LY6o5k~)Gdq*b" x="1432" y="-70"><value name="Direction"><block type="bitbybit.vector.vectorXYZ" id="`NZ7z}e(!^uA(KiWs2sW"><value name="X"><block type="math_number" id="]?b`nhi-PL;MN(vm48fJ"><field name="NUM">-20</field></block></value><value name="Y"><block type="math_number" id="F~MgP,Gg`Aa^A@gG{JS!"><field name="NUM">-20</field></block></value><value name="Z"><block type="math_number" id="9PyfkZY2if-m~Z8SW]@i"><field name="NUM">-20</field></block></value></block></value><value name="Intensity"><block type="math_number" id="!rN)jJ%g|#x}.u1tXAF#"><field name="NUM">3</field></block></value><value name="Diffuse"><block type="colour_picker" id="b!r1wxFs/H|+zcq!AisO"><field name="COLOUR">#ffffff</field></block></value><value name="Specular"><block type="colour_picker" id="N=2TpSp;ybiZkpHXi$ks"><field name="COLOUR">#ffffff</field></block></value><value name="ShadowGeneratorMapSize"><block type="math_number" id="1Kxr8dWE9Eto1BV1!W9D"><field name="NUM">2056</field></block></value><value name="EnableShadows"><block type="logic_boolean" id="Dsd~[b|QC{#s](Yu[.cH"><field name="BOOL">TRUE</field></block></value><value name="ShadowDarkness"><block type="math_number" id=".lZEYr8/6~*1Y[`L?0eL"><field name="NUM">0</field></block></value><value name="ShadowUsePercentageCloserFiltering"><block type="logic_boolean" id="68tdsLlG+`fxXA/zvOH]"><field name="BOOL">TRUE</field></block></value><value name="TransparencyShadow"><block type="logic_boolean" id="fCX|c{avy[M,Xez2oPd:"><field name="BOOL">FALSE</field></block></value><value name="ShadowContactHardeningLightSizeUVRatio"><block type="math_number" id=":D`d.LKJdEhnOvqzJ5bS"><field name="NUM">0.2</field></block></value><value name="ShadowBias"><block type="math_number" id="4n@~G$hMPJ,!8rPmfekz"><field name="NUM">0.0001</field></block></value><value name="ShadowNormalBias"><block type="math_number" id="9Bn)xmdYrA7`t*#1!v:P"><field name="NUM">0.002</field></block></value><value name="ShadowMaxZ"><block type="math_number" id="xs36O7Uk7B:jQW`-jpyh"><field name="NUM">1000</field></block></value><value name="ShadowMinZ"><block type="math_number" id="x0ZB1O9SOE%u!cw:GjhG"><field name="NUM">0</field></block></value><value name="ShadowRefreshRate"><block type="math_number" id="FzbxjoJw};(Z~=h%F86y"><field name="NUM">23</field></block></value><next><block type="variables_set" id="9H6Uj}Z|yg0$2JSgx+io"><field name="VAR" id="jm#sdZ7BQe8p!mx4[D0l">bg</field><value name="VALUE"><block type="bitbybit.babylon.scene.twoColorLinearGradientBackground" id="N1a7-n/:pt.-DKo1%X;f"><value name="ColorFrom"><block type="colour_picker" id="NupzouZ$G0,nlO=+K#(S"><field name="COLOUR">#1a1c1f</field></block></value><value name="ColorTo"><block type="colour_picker" id="vY^eV9.A7B0r*WU31S|)"><field name="COLOUR">#93aacd</field></block></value><value name="Direction"><block type="bitbybit.babylon.enums.gradientDirectionEnum" id="3%I4Xvi6~1iABf07}.2,"><field name="bitbybit.babylon.enums.gradientDirectionEnum">'to top'</field></block></value><value name="StopFrom"><block type="math_number" id="HpqKi;ebRbk*3qJaS-GC"><field name="NUM">0</field></block></value><value name="StopTo"><block type="math_number" id="i~Hu]k?$ueuGK/ALMU%n"><field name="NUM">100</field></block></value></block></value></block></next></block></xml>
// Import required DTOs for scene setup and OCCT operations
const { SceneTwoColorLinearGradientDto, DirectionalLightDto } = Bit.Inputs.BabylonScene;
const { NGonWireDto, DivideDto, ShapeDto, FaceFromWiresDto,
ExtrudeDto, ChamferDto, CircleDto, TranslateDto,
CreateAssemblyPartDto, CreateAssemblyNodeDto, CreateInstanceNodeDto,
CombineAssemblyStructureDto, BuildAssemblyDocumentDto, ExportDocumentToStepDto } = Bit.Inputs.OCCT;
const { DrawOcctShapeSimpleOptions } = Bit.Inputs.Draw;
const { gradientDirectionEnum } = Bit.Inputs.Base;
// Type definitions
type Point3 = Bit.Inputs.Base.Point3;
type Vector3 = Bit.Inputs.Base.Vector3;
type TopoDSShapePointer = Bit.Inputs.OCCT.TopoDSShapePointer;
type TopoDSWirePointer = Bit.Inputs.OCCT.TopoDSWirePointer;
type TopoDSFacePointer = Bit.Inputs.OCCT.TopoDSFacePointer;
type TDocStdDocumentPointer = Bit.Inputs.OCCT.TDocStdDocumentPointer;
// Get access to OCCT modules
const { wire, face } = bitbybit.occt.shapes;
const { operations, transforms, fillets, assembly } = bitbybit.occt;
const { manager } = assembly;
const { scene } = bitbybit.babylon;
const start = async () => {
// Parameters
const mainRadius = 13.3;
const fromOuterRadius = 4;
const innerRadius = mainRadius - fromOuterRadius;
const plugRadius = fromOuterRadius / 3;
// Setup gradient background
const bgOpt = new SceneTwoColorLinearGradientDto();
bgOpt.direction = gradientDirectionEnum.toTop;
scene.twoColorLinearGradientBackground(bgOpt);
// Setup directional light
const dirLightOpt = new DirectionalLightDto();
dirLightOpt.direction = [-20, -20, -20] as Vector3;
dirLightOpt.intensity = 3;
scene.drawDirectionalLight(dirLightOpt);
// Create outer circle wire
const outerCircleOpt = new CircleDto();
outerCircleOpt.radius = mainRadius;
outerCircleOpt.center = [0, 0, 0];
outerCircleOpt.direction = [0, 1, 0];
const outerCircleWire = await wire.createCircleWire(outerCircleOpt);
// Create inner circle wire for dividing points
const innerCircleOpt = new CircleDto();
innerCircleOpt.radius = innerRadius;
innerCircleOpt.center = [0, 0, 0];
innerCircleOpt.direction = [0, 1, 0];
const innerCircleWire = await wire.createCircleWire(innerCircleOpt);
// Divide inner wire to get points for plug placement
const divideOpt = new DivideDto<TopoDSWirePointer>();
divideOpt.shape = innerCircleWire;
divideOpt.nrOfDivisions = 14;
divideOpt.removeStartPoint = false;
divideOpt.removeEndPoint = true;
const dividedPoints = await wire.divideWireByParamsToPoints(divideOpt);
// Flatten points list
const pointsList: Point3[] = [];
for (const pt of dividedPoints) {
pointsList.push(pt);
}
// Create small circle wire for holes
const smallCircleOpt = new CircleDto();
smallCircleOpt.radius = plugRadius;
smallCircleOpt.center = [0, 0, 0];
smallCircleOpt.direction = [0, 1, 0];
const smallCircleWire = await wire.createCircleWire(smallCircleOpt);
// Reverse the wire for creating holes
const reverseOpt = new ShapeDto<TopoDSWirePointer>();
reverseOpt.shape = smallCircleWire;
const reversedWire = await wire.reversedWire(reverseOpt);
// Translate reversed wire to each point position
const translatedWires: TopoDSWirePointer[] = [];
for (const pt of pointsList) {
const translateOpt = new TranslateDto<TopoDSWirePointer>();
translateOpt.shape = reversedWire;
translateOpt.translation = pt;
const translated = await transforms.translate(translateOpt);
translatedWires.push(translated as TopoDSWirePointer);
}
// Create hexagon wire in the center
const ngonOpt = new NGonWireDto();
ngonOpt.center = [0, 0, 0];
ngonOpt.direction = [0, 1, 0];
ngonOpt.nrCorners = 6;
ngonOpt.radius = 4;
const ngonWire = await wire.createNGonWire(ngonOpt);
// Create wires list for face creation
const wiresList: TopoDSWirePointer[] = [outerCircleWire, ngonWire, ...translatedWires];
// Create base face from wires
const faceFromWiresOpt = new FaceFromWiresDto<TopoDSWirePointer>();
faceFromWiresOpt.shapes = wiresList;
faceFromWiresOpt.planar = true;
const baseFace = await face.createFaceFromWires(faceFromWiresOpt);
// Extrude base face
const extrudeBaseOpt = new ExtrudeDto<TopoDSFacePointer>();
extrudeBaseOpt.shape = baseFace;
extrudeBaseOpt.direction = [0, 1, 0];
const baseExtruded = await operations.extrude(extrudeBaseOpt);
// Chamfer base edges
const chamferBaseOpt = new ChamferDto<TopoDSShapePointer>();
chamferBaseOpt.shape = baseExtruded;
chamferBaseOpt.distance = 0.4;
const baseChamfered = await fillets.chamferEdges(chamferBaseOpt);
// Create plug face
const plugFaceOpt = new CircleDto();
plugFaceOpt.radius = plugRadius;
plugFaceOpt.center = [0, -1.5, 0];
plugFaceOpt.direction = [0, 1, 0];
const plugFace = await face.createCircleFace(plugFaceOpt);
// Extrude plug
const extrudePlugOpt = new ExtrudeDto<TopoDSFacePointer>();
extrudePlugOpt.shape = plugFace;
extrudePlugOpt.direction = [0, 4, 0];
const plugExtruded = await operations.extrude(extrudePlugOpt);
// Chamfer plug edges
const chamferPlugOpt = new ChamferDto<TopoDSShapePointer>();
chamferPlugOpt.shape = plugExtruded;
chamferPlugOpt.distance = 0.4;
const plugChamfered = await fillets.chamferEdges(chamferPlugOpt);
// Translate plugs to each point position
const translatedPlugs: TopoDSShapePointer[] = [];
for (const pt of pointsList) {
const translatePlugOpt = new TranslateDto<TopoDSShapePointer>();
translatePlugOpt.shape = plugChamfered;
translatePlugOpt.translation = pt;
const translated = await transforms.translate(translatePlugOpt);
translatedPlugs.push(translated);
}
// Draw base with blue color
const baseDrawOpt = new DrawOcctShapeSimpleOptions();
baseDrawOpt.precision = 0.01;
baseDrawOpt.faceColour = "#3333ff";
baseDrawOpt.edgeColour = "#ffffff";
baseDrawOpt.edgeWidth = 2;
await bitbybit.draw.drawAnyAsync({ entity: baseChamfered, options: baseDrawOpt });
// Draw plugs with green color
const plugDrawOpt = new DrawOcctShapeSimpleOptions();
plugDrawOpt.precision = 0.01;
plugDrawOpt.faceColour = "#33ff33";
plugDrawOpt.edgeColour = "#ffffff";
plugDrawOpt.edgeWidth = 2;
plugDrawOpt.drawTwoSided = true;
await bitbybit.draw.drawAnyAsync({ entity: translatedPlugs, options: plugDrawOpt });
// Create base part
const basePartOpt = new CreateAssemblyPartDto<TopoDSShapePointer>();
basePartOpt.id = "base-with-holes";
basePartOpt.shape = baseChamfered;
basePartOpt.name = "Base With Holes";
const basePart = await manager.createPart(basePartOpt);
// Create plug part
const plugPartOpt = new CreateAssemblyPartDto<TopoDSShapePointer>();
plugPartOpt.id = "plug";
plugPartOpt.shape = plugChamfered;
plugPartOpt.name = "Plug";
const plugPart = await manager.createPart(plugPartOpt);
// Create assembly node
const assemblyNodeOpt = new CreateAssemblyNodeDto();
assemblyNodeOpt.id = "assembly-node";
assemblyNodeOpt.name = "Bitbybit Assembly Example";
assemblyNodeOpt.parentId = "";
const assemblyNode = await manager.createAssemblyNode(assemblyNodeOpt);
// Create base instance node
const baseInstanceOpt = new CreateInstanceNodeDto();
baseInstanceOpt.id = "base-with-holes-id";
baseInstanceOpt.partId = "base-with-holes";
baseInstanceOpt.name = "Base With Holes Instance";
baseInstanceOpt.parentId = "";
baseInstanceOpt.translation = [0, 0, 0];
baseInstanceOpt.rotation = [0, 0, 0];
baseInstanceOpt.scale = 1;
baseInstanceOpt.colorRgba = { r: 0, g: 0, b: 1, a: 1 };
const baseInstanceNode = await manager.createInstanceNode(baseInstanceOpt);
// Create plug instance nodes for each position
const plugInstanceNodes = [];
for (let i = 0; i < pointsList.length; i++) {
const plugInstanceOpt = new CreateInstanceNodeDto();
plugInstanceOpt.id = `plug-id-${i + 1}`;
plugInstanceOpt.partId = "plug";
plugInstanceOpt.name = "Plug";
plugInstanceOpt.parentId = "";
plugInstanceOpt.translation = pointsList[i];
plugInstanceOpt.rotation = [0, 0, 0];
plugInstanceOpt.scale = 1;
plugInstanceOpt.colorRgba = { r: 0, g: 1, b: 0, a: 1 };
const plugInstance = await manager.createInstanceNode(plugInstanceOpt);
plugInstanceNodes.push(plugInstance);
}
// Combine parts and nodes
const partsList = [basePart, plugPart];
const nodesList = [assemblyNode, baseInstanceNode, ...plugInstanceNodes];
// Create assembly structure
const combineOpt = new CombineAssemblyStructureDto();
combineOpt.parts = partsList;
combineOpt.nodes = nodesList;
combineOpt.removals = [];
combineOpt.partUpdates = [];
combineOpt.clearDocument = false;
const structure = await manager.combineStructure(combineOpt);
// Build assembly document
const buildDocOpt = new BuildAssemblyDocumentDto<TopoDSShapePointer, TDocStdDocumentPointer>();
buildDocOpt.structure = structure;
const document = await manager.buildAssemblyDocument(buildDocOpt);
// Export to STEP file
const exportOpt = new ExportDocumentToStepDto<TDocStdDocumentPointer>();
exportOpt.document = document;
exportOpt.fileName = "Bitbybit Assembly.stpZ";
exportOpt.author = "Bitbybit user";
exportOpt.organization = "Bitbybit";
exportOpt.compress = true;
exportOpt.tryDownload = true;
await manager.exportDocumentToStep(exportOpt);
}
start();



