Introduction to OCCT Wire Basic Primitives
Wires are one-dimensional geometric entities that represent connected sequences of edges forming open or closed curves. OCCT provides several primitive wire types that serve as building blocks for more complex 2D and 3D modeling operations. These wire primitives are commonly used to create profiles for extrusion, sweeping, and other advanced geometric operations.
This example demonstrates the creation of the most common primitive wire types:
- Circle Wire: A circular wire with specified radius and center
- Square Wire: A square-shaped wire with specified size and center
- NGon Wire: A regular polygon wire with specified number of corners
- Parallelogram Wire: A parallelogram-shaped wire with width, height, and angle
- Rectangle Wire: A rectangular wire with specified width and length
- Ellipse Wire: An elliptical wire with major and minor radii
- Rete
- Blockly
- TypeScript
{
"id": "rete-v2-json",
"nodes": {
"69db19884a370f7c": {
"id": "69db19884a370f7c",
"name": "bitbybit.occt.shapes.wire.createCircleWire",
"customName": "circle wire",
"async": true,
"drawable": true,
"data": {
"genericNodeData": {
"hide": false,
"oneOnOne": false,
"flatten": 0,
"forceExecution": false
},
"radius": 3,
"center": [
0,
0,
0
],
"direction": [
0,
1,
0
]
},
"inputs": {},
"position": [
796.38671875,
208.7109375
]
},
"5298db5d0bf5b70d": {
"id": "5298db5d0bf5b70d",
"name": "bitbybit.occt.shapes.wire.createSquareWire",
"customName": "square wire",
"async": true,
"drawable": true,
"data": {
"genericNodeData": {
"hide": false,
"oneOnOne": false,
"flatten": 0,
"forceExecution": false
},
"size": 3,
"center": [
0,
0,
0
],
"direction": [
0,
1,
0
]
},
"inputs": {
"center": {
"connections": [
{
"node": "3a1b9cf45d7c8560",
"output": "result",
"data": {}
}
]
}
},
"position": [
797.1167812876299,
567.3003348022221
]
},
"3a1b9cf45d7c8560": {
"id": "3a1b9cf45d7c8560",
"name": "bitbybit.vector.vectorXYZ",
"customName": "vector xyz",
"async": false,
"drawable": true,
"data": {
"genericNodeData": {
"hide": true,
"oneOnOne": false,
"flatten": 0,
"forceExecution": false
},
"x": 5,
"y": 0,
"z": 0
},
"inputs": {},
"position": [
391.8397443858421,
609.2541923921959
]
},
"b03165e52f48ff1b": {
"id": "b03165e52f48ff1b",
"name": "bitbybit.vector.vectorXYZ",
"customName": "vector xyz",
"async": false,
"drawable": true,
"data": {
"genericNodeData": {
"hide": true,
"oneOnOne": false,
"flatten": 0,
"forceExecution": false
},
"x": -6,
"y": 0,
"z": 0
},
"inputs": {},
"position": [
381.4252369164033,
1026.2331834569381
]
},
"ced8e0357556b800": {
"id": "ced8e0357556b800",
"name": "bitbybit.occt.shapes.wire.createNGonWire",
"customName": "ngon wire",
"async": true,
"drawable": true,
"data": {
"genericNodeData": {
"hide": false,
"oneOnOne": false,
"flatten": 0,
"forceExecution": false
},
"center": [
0,
0,
0
],
"direction": [
0,
1,
0
],
"nrCorners": 6,
"radius": 2
},
"inputs": {
"center": {
"connections": [
{
"node": "b03165e52f48ff1b",
"output": "result",
"data": {}
}
]
}
},
"position": [
794.3963462853789,
1024.3436962815244
]
},
"e76c6df127a9d31c": {
"id": "e76c6df127a9d31c",
"name": "bitbybit.occt.shapes.wire.createParallelogramWire",
"customName": "parallelogram wire",
"async": true,
"drawable": true,
"data": {
"genericNodeData": {
"hide": false,
"oneOnOne": false,
"flatten": 0,
"forceExecution": false
},
"center": [
0,
0,
0
],
"direction": [
0,
1,
0
],
"aroundCenter": true,
"width": 3,
"height": 2,
"angle": 30
},
"inputs": {
"center": {
"connections": [
{
"node": "adeb74f805b239b8",
"output": "result",
"data": {}
}
]
}
},
"position": [
797.4442178044769,
1434.5793419960353
]
},
"adeb74f805b239b8": {
"id": "adeb74f805b239b8",
"name": "bitbybit.vector.vectorXYZ",
"customName": "vector xyz",
"async": false,
"drawable": true,
"data": {
"genericNodeData": {
"hide": true,
"oneOnOne": false,
"flatten": 0,
"forceExecution": false
},
"x": -11,
"y": 0,
"z": 0
},
"inputs": {},
"position": [
388.5087965238256,
1437.9832918677564
]
},
"d41ad1f158b794f3": {
"id": "d41ad1f158b794f3",
"name": "bitbybit.occt.shapes.wire.createRectangleWire",
"customName": "rectangle wire",
"async": true,
"drawable": true,
"data": {
"genericNodeData": {
"hide": false,
"oneOnOne": false,
"flatten": 0,
"forceExecution": false
},
"width": 2,
"length": 6,
"center": [
0,
0,
0
],
"direction": [
0,
1,
0
]
},
"inputs": {
"center": {
"connections": [
{
"node": "eb0d53b47065ba27",
"output": "result",
"data": {}
}
]
}
},
"position": [
807.0660770213016,
1932.65310264216
]
},
"eb0d53b47065ba27": {
"id": "eb0d53b47065ba27",
"name": "bitbybit.vector.vectorXYZ",
"customName": "vector xyz",
"async": false,
"drawable": true,
"data": {
"genericNodeData": {
"hide": true,
"oneOnOne": false,
"flatten": 0,
"forceExecution": false
},
"x": 9,
"y": 0,
"z": 0
},
"inputs": {},
"position": [
401.21471645298226,
2012.097226478838
]
},
"da4450234db2a464": {
"id": "da4450234db2a464",
"name": "bitbybit.vector.vectorXYZ",
"customName": "vector xyz",
"async": false,
"drawable": true,
"data": {
"genericNodeData": {
"hide": true,
"oneOnOne": false,
"flatten": 0,
"forceExecution": false
},
"x": 12,
"y": 0,
"z": 0
},
"inputs": {},
"position": [
392.26401312452316,
2447.940719665186
]
},
"c34d4412cbfb1af7": {
"id": "c34d4412cbfb1af7",
"name": "bitbybit.occt.shapes.wire.createEllipseWire",
"customName": "ellipse wire",
"async": true,
"drawable": true,
"data": {
"genericNodeData": {
"hide": false,
"oneOnOne": false,
"flatten": 0,
"forceExecution": false
},
"center": [
0,
0,
0
],
"direction": [
0,
1,
0
],
"radiusMinor": 1,
"radiusMajor": 4
},
"inputs": {
"center": {
"connections": [
{
"node": "da4450234db2a464",
"output": "result",
"data": {}
}
]
}
},
"position": [
806.3772296257235,
2442.4598150758247
]
}
}
}
<xml xmlns="https://developers.google.com/blockly/xml"><variables><variable id="circleWire">circleWire</variable><variable id="squareWire">squareWire</variable><variable id="ngonWire">ngonWire</variable><variable id="parallelogramWire">parallelogramWire</variable><variable id="rectangleWire">rectangleWire</variable><variable id="ellipseWire">ellipseWire</variable></variables><block type="variables_set" id="create_circle_wire" x="50" y="50"><field name="VAR" id="circleWire">circleWire</field><value name="VALUE"><block type="bitbybit.occt.shapes.wire.createCircleWire" id="circle_wire"><value name="Radius"><block type="math_number" id="circle_radius"><field name="NUM">3</field></block></value><value name="Center"><block type="bitbybit.point.pointXYZ" id="circle_center"><value name="X"><block type="math_number" id="circle_center_x"><field name="NUM">0</field></block></value><value name="Y"><block type="math_number" id="circle_center_y"><field name="NUM">0</field></block></value><value name="Z"><block type="math_number" id="circle_center_z"><field name="NUM">0</field></block></value></block></value><value name="Direction"><block type="bitbybit.vector.vectorXYZ" id="circle_direction"><value name="X"><block type="math_number" id="circle_dir_x"><field name="NUM">0</field></block></value><value name="Y"><block type="math_number" id="circle_dir_y"><field name="NUM">1</field></block></value><value name="Z"><block type="math_number" id="circle_dir_z"><field name="NUM">0</field></block></value></block></value></block></value><next><block type="variables_set" id="create_square_wire" x="50" y="150"><field name="VAR" id="squareWire">squareWire</field><value name="VALUE"><block type="bitbybit.occt.shapes.wire.createSquareWire" id="square_wire"><value name="Size"><block type="math_number" id="square_size"><field name="NUM">3</field></block></value><value name="Center"><block type="bitbybit.point.pointXYZ" id="square_center"><value name="X"><block type="math_number" id="square_center_x"><field name="NUM">5</field></block></value><value name="Y"><block type="math_number" id="square_center_y"><field name="NUM">0</field></block></value><value name="Z"><block type="math_number" id="square_center_z"><field name="NUM">0</field></block></value></block></value><value name="Direction"><block type="bitbybit.vector.vectorXYZ" id="square_direction"><value name="X"><block type="math_number" id="square_dir_x"><field name="NUM">0</field></block></value><value name="Y"><block type="math_number" id="square_dir_y"><field name="NUM">1</field></block></value><value name="Z"><block type="math_number" id="square_dir_z"><field name="NUM">0</field></block></value></block></value></block></value><next><block type="variables_set" id="create_ngon_wire" x="50" y="250"><field name="VAR" id="ngonWire">ngonWire</field><value name="VALUE"><block type="bitbybit.occt.shapes.wire.createNGonWire" id="ngon_wire"><value name="Center"><block type="bitbybit.point.pointXYZ" id="ngon_center"><value name="X"><block type="math_number" id="ngon_center_x"><field name="NUM">-6</field></block></value><value name="Y"><block type="math_number" id="ngon_center_y"><field name="NUM">0</field></block></value><value name="Z"><block type="math_number" id="ngon_center_z"><field name="NUM">0</field></block></value></block></value><value name="Direction"><block type="bitbybit.vector.vectorXYZ" id="ngon_direction"><value name="X"><block type="math_number" id="ngon_dir_x"><field name="NUM">0</field></block></value><value name="Y"><block type="math_number" id="ngon_dir_y"><field name="NUM">1</field></block></value><value name="Z"><block type="math_number" id="ngon_dir_z"><field name="NUM">0</field></block></value></block></value><value name="NrCorners"><block type="math_number" id="ngon_corners"><field name="NUM">6</field></block></value><value name="Radius"><block type="math_number" id="ngon_radius"><field name="NUM">2</field></block></value></block></value><next><block type="variables_set" id="create_parallelogram_wire" x="50" y="350"><field name="VAR" id="parallelogramWire">parallelogramWire</field><value name="VALUE"><block type="bitbybit.occt.shapes.wire.createParallelogramWire" id="parallelogram_wire"><value name="Center"><block type="bitbybit.point.pointXYZ" id="parallelogram_center"><value name="X"><block type="math_number" id="parallelogram_center_x"><field name="NUM">-11</field></block></value><value name="Y"><block type="math_number" id="parallelogram_center_y"><field name="NUM">0</field></block></value><value name="Z"><block type="math_number" id="parallelogram_center_z"><field name="NUM">0</field></block></value></block></value><value name="Direction"><block type="bitbybit.vector.vectorXYZ" id="parallelogram_direction"><value name="X"><block type="math_number" id="parallelogram_dir_x"><field name="NUM">0</field></block></value><value name="Y"><block type="math_number" id="parallelogram_dir_y"><field name="NUM">1</field></block></value><value name="Z"><block type="math_number" id="parallelogram_dir_z"><field name="NUM">0</field></block></value></block></value><value name="AroundCenter"><block type="logic_boolean" id="parallelogram_around_center"><field name="BOOL">TRUE</field></block></value><value name="Width"><block type="math_number" id="parallelogram_width"><field name="NUM">3</field></block></value><value name="Height"><block type="math_number" id="parallelogram_height"><field name="NUM">2</field></block></value><value name="Angle"><block type="math_number" id="parallelogram_angle"><field name="NUM">30</field></block></value></block></value><next><block type="variables_set" id="create_rectangle_wire" x="50" y="450"><field name="VAR" id="rectangleWire">rectangleWire</field><value name="VALUE"><block type="bitbybit.occt.shapes.wire.createRectangleWire" id="rectangle_wire"><value name="Width"><block type="math_number" id="rectangle_width"><field name="NUM">2</field></block></value><value name="Length"><block type="math_number" id="rectangle_length"><field name="NUM">6</field></block></value><value name="Center"><block type="bitbybit.point.pointXYZ" id="rectangle_center"><value name="X"><block type="math_number" id="rectangle_center_x"><field name="NUM">9</field></block></value><value name="Y"><block type="math_number" id="rectangle_center_y"><field name="NUM">0</field></block></value><value name="Z"><block type="math_number" id="rectangle_center_z"><field name="NUM">0</field></block></value></block></value><value name="Direction"><block type="bitbybit.vector.vectorXYZ" id="rectangle_direction"><value name="X"><block type="math_number" id="rectangle_dir_x"><field name="NUM">0</field></block></value><value name="Y"><block type="math_number" id="rectangle_dir_y"><field name="NUM">1</field></block></value><value name="Z"><block type="math_number" id="rectangle_dir_z"><field name="NUM">0</field></block></value></block></value></block></value><next><block type="variables_set" id="create_ellipse_wire" x="50" y="550"><field name="VAR" id="ellipseWire">ellipseWire</field><value name="VALUE"><block type="bitbybit.occt.shapes.wire.createEllipseWire" id="ellipse_wire"><value name="Center"><block type="bitbybit.point.pointXYZ" id="ellipse_center"><value name="X"><block type="math_number" id="ellipse_center_x"><field name="NUM">12</field></block></value><value name="Y"><block type="math_number" id="ellipse_center_y"><field name="NUM">0</field></block></value><value name="Z"><block type="math_number" id="ellipse_center_z"><field name="NUM">0</field></block></value></block></value><value name="Direction"><block type="bitbybit.vector.vectorXYZ" id="ellipse_direction"><value name="X"><block type="math_number" id="ellipse_dir_x"><field name="NUM">0</field></block></value><value name="Y"><block type="math_number" id="ellipse_dir_y"><field name="NUM">1</field></block></value><value name="Z"><block type="math_number" id="ellipse_dir_z"><field name="NUM">0</field></block></value></block></value><value name="RadiusMinor"><block type="math_number" id="ellipse_radius_minor"><field name="NUM">1</field></block></value><value name="RadiusMajor"><block type="math_number" id="ellipse_radius_major"><field name="NUM">4</field></block></value></block></value><next><block type="bitbybit.draw.drawAnyAsyncNoReturn" id="draw_circle_wire" x="50" y="650"><value name="Entity"><block type="variables_get" id="get_circle_wire"><field name="VAR" id="circleWire">circleWire</field></block></value><next><block type="bitbybit.draw.drawAnyAsyncNoReturn" id="draw_square_wire" x="50" y="750"><value name="Entity"><block type="variables_get" id="get_square_wire"><field name="VAR" id="squareWire">squareWire</field></block></value><next><block type="bitbybit.draw.drawAnyAsyncNoReturn" id="draw_ngon_wire" x="50" y="850"><value name="Entity"><block type="variables_get" id="get_ngon_wire"><field name="VAR" id="ngonWire">ngonWire</field></block></value><next><block type="bitbybit.draw.drawAnyAsyncNoReturn" id="draw_parallelogram_wire" x="50" y="950"><value name="Entity"><block type="variables_get" id="get_parallelogram_wire"><field name="VAR" id="parallelogramWire">parallelogramWire</field></block></value><next><block type="bitbybit.draw.drawAnyAsyncNoReturn" id="draw_rectangle_wire" x="50" y="1050"><value name="Entity"><block type="variables_get" id="get_rectangle_wire"><field name="VAR" id="rectangleWire">rectangleWire</field></block></value><next><block type="bitbybit.draw.drawAnyAsyncNoReturn" id="draw_ellipse_wire" x="50" y="1150"><value name="Entity"><block type="variables_get" id="get_ellipse_wire"><field name="VAR" id="ellipseWire">ellipseWire</field></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></xml>
// Import required DTOs and types for wire creation
const { CircleDto, SquareDto, NGonWireDto, ParallelogramDto, RectangleDto, EllipseDto } = Bit.Inputs.OCCT;
type Point3 = Bit.Inputs.Base.Point3;
type Vector3 = Bit.Inputs.Base.Vector3;
// Get access to OCCT wire creation functions
const { wire } = bitbybit.occt.shapes;
// Define the main function to create various primitive wires
const start = async () => {
// Create a circle wire
const circleOptions = new CircleDto();
circleOptions.radius = 3;
circleOptions.center = [0, 0, 0] as Point3;
circleOptions.direction = [0, 1, 0] as Vector3;
const circleWire = await wire.createCircleWire(circleOptions);
// Create a square wire at a different position
const squareOptions = new SquareDto();
squareOptions.size = 3;
squareOptions.center = [5, 0, 0] as Point3;
squareOptions.direction = [0, 1, 0] as Vector3;
const squareWire = await wire.createSquareWire(squareOptions);
// Create an NGon wire (hexagon)
const ngonOptions = new NGonWireDto();
ngonOptions.center = [-6, 0, 0] as Point3;
ngonOptions.direction = [0, 1, 0] as Vector3;
ngonOptions.nrCorners = 6;
ngonOptions.radius = 2;
const ngonWire = await wire.createNGonWire(ngonOptions);
// Create a parallelogram wire
const parallelogramOptions = new ParallelogramDto();
parallelogramOptions.center = [-11, 0, 0] as Point3;
parallelogramOptions.direction = [0, 1, 0] as Vector3;
parallelogramOptions.aroundCenter = true;
parallelogramOptions.width = 3;
parallelogramOptions.height = 2;
parallelogramOptions.angle = 30;
const parallelogramWire = await wire.createParallelogramWire(parallelogramOptions);
// Create a rectangle wire
const rectangleOptions = new RectangleDto();
rectangleOptions.width = 2;
rectangleOptions.length = 6;
rectangleOptions.center = [9, 0, 0] as Point3;
rectangleOptions.direction = [0, 1, 0] as Vector3;
const rectangleWire = await wire.createRectangleWire(rectangleOptions);
// Create an ellipse wire
const ellipseOptions = new EllipseDto();
ellipseOptions.center = [12, 0, 0] as Point3;
ellipseOptions.direction = [0, 1, 0] as Vector3;
ellipseOptions.radiusMinor = 1;
ellipseOptions.radiusMajor = 4;
const ellipseWire = await wire.createEllipseWire(ellipseOptions);
// Draw all the created wires
bitbybit.draw.drawAnyAsync({ entity: circleWire });
bitbybit.draw.drawAnyAsync({ entity: squareWire });
bitbybit.draw.drawAnyAsync({ entity: ngonWire });
bitbybit.draw.drawAnyAsync({ entity: parallelogramWire });
bitbybit.draw.drawAnyAsync({ entity: rectangleWire });
bitbybit.draw.drawAnyAsync({ entity: ellipseWire });
}
// Execute the function
start();
These primitive wires serve as the foundation for more complex 2D and 3D modeling operations. They can be used to create faces through surface generation, extruded into solids, used as profiles for sweeping operations, or combined and modified to create sophisticated wireframe geometries for engineering and design applications.



