From 77ee2543d9cfeed00d9d2f6bf77a998952e7d46e Mon Sep 17 00:00:00 2001 From: Matas Ubarevicius Date: Sat, 4 Oct 2025 13:26:23 +0300 Subject: [PATCH 1/5] some new tutorials on modelling hollow shapes --- .../code/common/occt/modeling/_category_.json | 10 ++ .../modeling/hollow-shapes/_category_.json | 10 ++ .../hollow-shapes/rectangle-holes-on-face.md | 116 +++++++++++++++ .../modeling/hollow-shapes/simple-hole.md | 136 ++++++++++++++++++ .../hollow-shapes/simple-hollow-grids.md | 105 ++++++++++++++ 5 files changed, 377 insertions(+) create mode 100644 docs/learn/code/common/occt/modeling/_category_.json create mode 100644 docs/learn/code/common/occt/modeling/hollow-shapes/_category_.json create mode 100644 docs/learn/code/common/occt/modeling/hollow-shapes/rectangle-holes-on-face.md create mode 100644 docs/learn/code/common/occt/modeling/hollow-shapes/simple-hole.md create mode 100644 docs/learn/code/common/occt/modeling/hollow-shapes/simple-hollow-grids.md diff --git a/docs/learn/code/common/occt/modeling/_category_.json b/docs/learn/code/common/occt/modeling/_category_.json new file mode 100644 index 00000000..ad8186b5 --- /dev/null +++ b/docs/learn/code/common/occt/modeling/_category_.json @@ -0,0 +1,10 @@ +{ + "label": "Modeling", + "position": 5, + "link": { + "type": "generated-index", + "title": "Common OCCT Modeling Techniques", + "description": "This category goes beyond basic operations and discusses some common challenges in parametric 3D modeling.", + "slug": "/code/common/occt/modeling" + } +} \ No newline at end of file diff --git a/docs/learn/code/common/occt/modeling/hollow-shapes/_category_.json b/docs/learn/code/common/occt/modeling/hollow-shapes/_category_.json new file mode 100644 index 00000000..e9fc43b7 --- /dev/null +++ b/docs/learn/code/common/occt/modeling/hollow-shapes/_category_.json @@ -0,0 +1,10 @@ +{ + "label": "Hollow Shapes", + "position": 5, + "link": { + "type": "generated-index", + "title": "Hollow Shapes", + "description": "While using boolean operations to cut out holes might be straightforward, there are several nuances to consider.", + "slug": "/code/common/occt/modeling/holes-in-faces" + } +} \ No newline at end of file diff --git a/docs/learn/code/common/occt/modeling/hollow-shapes/rectangle-holes-on-face.md b/docs/learn/code/common/occt/modeling/hollow-shapes/rectangle-holes-on-face.md new file mode 100644 index 00000000..09dd11c0 --- /dev/null +++ b/docs/learn/code/common/occt/modeling/hollow-shapes/rectangle-holes-on-face.md @@ -0,0 +1,116 @@ +--- +sidebar_position: 3 +title: Rectangle Holes On Face +sidebar_label: Rectangle Holes On Face +description: Bitbybit has many helper functions that could streamline some of the modeling tasks, such as subdividing given rectangle faces into multiple holes or wires. +tags: [code, occt, rete, blockly, typescript] +--- + +import Tabs from '@theme/Tabs'; +import TabItem from '@theme/TabItem'; +import BitByBitRenderCanvas from '@site/src/components/BitByBitRenderCanvas'; + +OCCT category icon with a stylized logo representation + +Creating regular patterns of holes manually can be time-consuming and error-prone. The `subdivideToRectangleHoles` function automates this process by intelligently subdividing rectangular faces into grids with customizable hole patterns. This powerful helper function is essential for creating perforated panels, ventilation grilles, and decorative screens with precise, parametric control. + + + + + + + recFacefacesrecFace2014000010facesrecFace1010[0.8,0.5,0.5][0.8,0.5,0.5]FALSE00GETFIRSTfaces010","version":"0.20.7","type":"blockly"}} + title="Rectangle holes on face" + /> + + + {\n // Create a rectangular face as the base shape\n const faceOptions = new RectangleDto();\n faceOptions.width = 20;\n faceOptions.length = 14;\n faceOptions.center = [0, 0, 0];\n faceOptions.direction = [0, 1, 0];\n const rectangleFace = await face.createRectangleFace(faceOptions);\n\n // Define scale patterns for U and V directions\n // These arrays control the size of holes in each row and column\n const scalePatternU = [0.8, 0.5, 0.5]; // Varying hole sizes in U direction\n const scalePatternV = [0.8, 0.5, 0.5]; // Varying hole sizes in V direction\n\n // Subdivide the face into rectangular holes\n const subdivideOptions = new FaceSubdivideToRectangleHolesDto();\n subdivideOptions.shape = rectangleFace;\n subdivideOptions.nrRectanglesU = 10; // Number of divisions in U direction\n subdivideOptions.nrRectanglesV = 10; // Number of divisions in V direction\n subdivideOptions.holesToFaces = false; // Return wires instead of faces\n subdivideOptions.offsetFromBorderU = 0.05; // Border offset in U direction\n subdivideOptions.offsetFromBorderV = 0.05; // Border offset in V direction\n subdivideOptions.scalePatternU = scalePatternU;\n subdivideOptions.scalePatternV = scalePatternV;\n\n const holes = await face.subdivideToRectangleHoles(subdivideOptions);\n\n // Get the first hole (the outer boundary with holes)\n const firstHole = lists.getItem({ list: holes, index: 0, clone: true });\n\n // Extrude the face with holes to create a 3D solid\n const extrudeOptions = new ExtrudeDto();\n extrudeOptions.shape = firstHole;\n extrudeOptions.direction = [0, 1, 0];\n const extrudedSolid = await operations.extrude(extrudeOptions);\n\n // Draw the resulting 3D solid with rectangular holes\n bitbybit.draw.drawAnyAsync({\n entity: extrudedSolid\n });\n}\n\n// Execute the function\nstart();","version":"0.20.7","type":"typescript"}} + title="Rectangle holes on face" + /> + + + +## Understanding Rectangle Hole Subdivision + +The `subdivideToRectangleHoles` function is a powerful helper that automates the creation of regular grid patterns with holes. Instead of manually creating and positioning individual holes, this function intelligently subdivides a rectangular face into a grid and creates holes or wires at each grid position. + +This approach is particularly valuable for applications requiring precise, regular patterns such as: +- Perforated metal sheets +- Ventilation grilles +- Acoustic panels +- Decorative architectural screens +- Industrial filtration elements + +## Key Parameters and Their Effects + +### Grid Division Controls + +**nrRectanglesU** and **nrRectanglesV**: These parameters control how many divisions are created in each direction. Higher values create more, smaller holes, while lower values create fewer, larger holes. + +**offsetFromBorderU** and **offsetFromBorderV**: These control the spacing between the holes and the edge of the face. Values between 0.05 and 0.2 typically provide good results, with smaller values creating holes closer to the edge. + +### Scale Pattern Arrays + +The scale pattern arrays are where this function becomes truly powerful. These arrays allow you to create non-uniform hole sizes across the grid: + +- **Single value**: `[1.0]` creates uniform holes across the entire grid +- **Multiple values**: `[0.8, 0.5, 0.5]` creates varying hole sizes that repeat in a pattern +- **Gradient effect**: `[1.0, 0.8, 0.6, 0.4, 0.2]` creates a gradual size transition + +The pattern repeats across the grid, so if you have 10 divisions and a 3-element pattern, the pattern will cycle: 1st uses pattern[0], 2nd uses pattern[1], 3rd uses pattern[2], 4th uses pattern[0] again, and so on. + +### Output Type Control + +**holesToFaces**: This boolean parameter determines the output format: +- `false`: Returns wire boundaries (useful for creating faces with holes) +- `true`: Returns individual face elements (useful for separate processing of each hole) + +## Advanced Pattern Creation Techniques + +### Creating Gradient Effects + +You can create sophisticated visual effects by carefully designing your scale patterns: + +```javascript +// Fade from center to edges +const fadePattern = [0.2, 0.4, 0.6, 0.8, 1.0, 0.8, 0.6, 0.4, 0.2]; + +// Alternating large and small +const alternatingPattern = [1.0, 0.3, 1.0, 0.3]; + +// Exponential growth +const exponentialPattern = [0.1, 0.2, 0.4, 0.8, 1.0]; +``` + +### Combining with Other Operations + +The subdivided patterns work excellently with other OCCT operations: + +**Fillets**: Apply 2D fillets to the wires before creating faces for rounded hole corners +**Boolean Operations**: Use the holes as cutting tools for more complex geometries +**Array Operations**: Combine multiple subdivided faces to create larger patterns +**Transformations**: Rotate or scale the entire pattern for dynamic effects + +## Applications and Next Steps + +The `subdivideToRectangleHoles` function excels in numerous applications: + +- **Architecture**: Facade panels, privacy screens, and decorative elements +- **Manufacturing**: Sheet metal fabrication, injection molding, and 3D printing +- **Engineering**: Filtration systems, heat exchangers, and acoustic panels + +For optimal results, start with simple uniform patterns before experimenting with complex scale arrays. The function transforms hundreds of individual operations into a single, parametric call, making it invaluable for creating sophisticated perforated designs. + +Combine this technique with fillets, boolean operations, and transformations to create even more complex geometric patterns. The parametric nature ensures your designs remain flexible and easily adjustable for different manufacturing requirements. diff --git a/docs/learn/code/common/occt/modeling/hollow-shapes/simple-hole.md b/docs/learn/code/common/occt/modeling/hollow-shapes/simple-hole.md new file mode 100644 index 00000000..dd2cbc01 --- /dev/null +++ b/docs/learn/code/common/occt/modeling/hollow-shapes/simple-hole.md @@ -0,0 +1,136 @@ +--- +sidebar_position: 1 +title: Simple Holes +sidebar_label: Simple Holes +description: Learn how to use outer and inner wire to create a face that has a hole. +tags: [code, occt, rete, blockly, typescript] +--- + +import Tabs from '@theme/Tabs'; +import TabItem from '@theme/TabItem'; +import BitByBitRenderCanvas from '@site/src/components/BitByBitRenderCanvas'; + +OCCT category icon with a stylized logo representation + +Hollow shapes are everywhere around us - from simple picture frames and washers to complex architectural elements like windows, decorative panels, and mechanical components. In 3D modeling, creating holes in faces and solids is a fundamental technique that opens up countless design possibilities. + +Whether you're designing a mounting bracket with bolt holes, creating decorative lattice work, or modeling architectural elements with openings, understanding how to properly create hollow shapes is essential. This tutorial will guide you through the process step by step. + +## Most Simple Case - Hollow Face From 2 Wires + +Creating hollow shapes starts with understanding how to make a face with a hole. The key insight is that you need two wire shapes: an outer boundary that defines the overall shape, and an inner boundary that defines the hole. The crucial step is reversing the inner wire to ensure proper orientation, then combining both wires to create a single face. + +This technique is fundamental because it establishes the basic principle that applies to more complex scenarios. Once you master creating a simple hollow face, you can extend this to create 3D solids and even shapes with multiple holes. + + + + + + + 200000107000010TRUE","version":"0.20.7","type":"blockly"}} + title="Simple hole from two wires" + /> + + + {\n // Create the outer square wire (boundary of the shape)\n const outerWireOptions = new SquareDto();\n outerWireOptions.size = 20;\n outerWireOptions.center = [0, 0, 0];\n outerWireOptions.direction = [0, 1, 0];\n const outerWire = await wire.createSquareWire(outerWireOptions);\n\n // Create the inner square wire (defines the hole)\n const innerWireOptions = new SquareDto();\n innerWireOptions.size = 7;\n innerWireOptions.center = [0, 0, 0];\n innerWireOptions.direction = [0, 1, 0];\n const innerWire = await wire.createSquareWire(innerWireOptions);\n\n // Reverse the inner wire - this is crucial for proper hole creation\n const reversedInnerWire = await wire.reversedWire({ shape: innerWire });\n\n // Create a face from both wires - outer boundary and inner hole\n const faceOptions = new FaceFromWiresDto();\n faceOptions.shapes = [outerWire, reversedInnerWire];\n faceOptions.planar = true;\n const faceWithHole = await face.createFaceFromWires(faceOptions);\n\n // Draw the resulting face with hole\n bitbybit.draw.drawAnyAsync({\n entity: faceWithHole\n });\n}\n\n// Execute the function\nstart();","version":"0.20.7","type":"typescript"}} + title="Simple hole from two wires" + /> + + + +## Hollow Solid From Hollow Face + +A flat face with a hole is just the beginning. In real-world applications, you typically need 3D solid objects - think of structural components like mounting plates, decorative panels with cutouts, or mechanical parts with through-holes for bolts and pins. + +The transition from a 2D hollow face to a 3D hollow solid is achieved through extrusion. This operation takes your flat face and extends it in a specific direction, creating volume while maintaining the hole structure. This technique is widely used in manufacturing and architectural design where you need consistent cross-sections along a length. + + + + + + + 2014000010177000010101045TRUE020","version":"0.20.7","type":"blockly"}} + title="More complex solid with the hole" + /> + + + {\n // Create the outer rectangular wire\n const outerWireOptions = new RectangleDto();\n outerWireOptions.width = 20;\n outerWireOptions.length = 14;\n outerWireOptions.center = [0, 0, 0];\n outerWireOptions.direction = [0, 1, 0];\n const outerWire = await wire.createRectangleWire(outerWireOptions);\n\n // Apply fillet to the outer wire for rounded corners\n const outerFilletOptions = new FilletDto();\n outerFilletOptions.radius = 1;\n outerFilletOptions.shape = outerWire;\n const filletedOuterWire = await fillets.fillet2d(outerFilletOptions);\n\n // Create the inner rectangular wire (hole)\n const innerWireOptions = new RectangleDto();\n innerWireOptions.width = 7;\n innerWireOptions.length = 7;\n innerWireOptions.center = [0, 0, 0];\n innerWireOptions.direction = [0, 1, 0];\n const innerWire = await wire.createRectangleWire(innerWireOptions);\n\n // Apply fillet to the inner wire\n const innerFilletOptions = new FilletDto();\n innerFilletOptions.radius = 1;\n innerFilletOptions.shape = innerWire;\n const filletedInnerWire = await fillets.fillet2d(innerFilletOptions);\n\n // Rotate the inner wire by 45 degrees for visual interest\n const rotatedInnerWire = await transforms.rotate({\n shape: filletedInnerWire,\n axis: [0, 1, 0],\n angle: 45\n });\n\n // Reverse the rotated inner wire for proper hole creation\n const reversedInnerWire = await wire.reversedWire({ shape: rotatedInnerWire });\n\n // Create a face from both wires\n const faceOptions = new FaceFromWiresDto();\n faceOptions.shapes = [filletedOuterWire, reversedInnerWire];\n faceOptions.planar = true;\n const faceWithHole = await face.createFaceFromWires(faceOptions);\n\n // Extrude the face to create a 3D solid\n const extrudeOptions = new ExtrudeDto();\n extrudeOptions.shape = faceWithHole;\n extrudeOptions.direction = [0, 2, 0]; // Extrude 2 units in Y direction\n const solidWithHole = await operations.extrude(extrudeOptions);\n\n // Draw the resulting 3D solid with hole\n bitbybit.draw.drawAnyAsync({\n entity: solidWithHole\n });\n}\n\n// Execute the function\nstart();","version":"0.20.7","type":"typescript"}} + title="More complex solid with the hole" + /> + + + +## Hollow Solid With Multiple Holes + +Once you understand the basic principle, creating shapes with multiple holes becomes straightforward. This technique is particularly valuable in manufacturing scenarios where you need multiple mounting points, ventilation openings, or weight reduction features in a single component. + +The process simply involves creating additional inner wires and including them all in the wire list when creating your face. Notice in this example that we reversed the outer wire instead of each inner wire - this is purely an optimization to reduce computations and doesn't affect the final result. + + + + + + + 231400001017700001010104550077000010101045-500TRUE020","version":"0.20.7","type":"blockly"}} + title="Solid with 2 holes" + /> + + + {\n // Create the outer rectangular wire (larger this time)\n const outerWireOptions = new RectangleDto();\n outerWireOptions.width = 23;\n outerWireOptions.length = 14;\n outerWireOptions.center = [0, 0, 0];\n outerWireOptions.direction = [0, 1, 0];\n const outerWire = await wire.createRectangleWire(outerWireOptions);\n\n // Apply fillet to the outer wire\n const outerFilletOptions = new FilletDto();\n outerFilletOptions.radius = 1;\n outerFilletOptions.shape = outerWire;\n const filletedOuterWire = await fillets.fillet2d(outerFilletOptions);\n\n // Reverse the outer wire (optimization - reverse once instead of multiple inner wires)\n const reversedOuterWire = await wire.reversedWire({ shape: filletedOuterWire });\n\n // Create the base inner rectangular wire\n const innerWireOptions = new RectangleDto();\n innerWireOptions.width = 7;\n innerWireOptions.length = 7;\n innerWireOptions.center = [0, 0, 0];\n innerWireOptions.direction = [0, 1, 0];\n const innerWire = await wire.createRectangleWire(innerWireOptions);\n\n // Apply fillet to the inner wire\n const innerFilletOptions = new FilletDto();\n innerFilletOptions.radius = 1;\n innerFilletOptions.shape = innerWire;\n const filletedInnerWire = await fillets.fillet2d(innerFilletOptions);\n\n // Rotate the inner wire for visual interest\n const rotatedInnerWire = await transforms.rotate({\n shape: filletedInnerWire,\n axis: [0, 1, 0],\n angle: 45\n });\n\n // Create first hole by translating the rotated wire to the right\n const firstHole = await transforms.translate({\n shape: rotatedInnerWire,\n translation: [5, 0, 0]\n });\n\n // Create second hole by translating the rotated wire to the left\n const secondHole = await transforms.translate({\n shape: rotatedInnerWire,\n translation: [-5, 0, 0]\n });\n\n // Create a face from the outer boundary and multiple holes\n const faceOptions = new FaceFromWiresDto();\n faceOptions.shapes = [reversedOuterWire, firstHole, secondHole];\n faceOptions.planar = true;\n const faceWithHoles = await face.createFaceFromWires(faceOptions);\n\n // Extrude the face to create a 3D solid with multiple holes\n const extrudeOptions = new ExtrudeDto();\n extrudeOptions.shape = faceWithHoles;\n extrudeOptions.direction = [0, 2, 0];\n const solidWithHoles = await operations.extrude(extrudeOptions);\n\n // Draw the resulting 3D solid with multiple holes\n bitbybit.draw.drawAnyAsync({\n entity: solidWithHoles\n });\n}\n\n// Execute the function\nstart();","version":"0.20.7","type":"typescript"}} + title="Solid with 2 holes" + /> + + + + +## Practical Applications + +The techniques you've learned in this tutorial have wide-ranging applications across many industries and design disciplines: + +**Manufacturing and Engineering** +Creating hollow shapes is essential for designing mechanical components like mounting brackets, flanges, and structural elements. The ability to add precise holes for bolts, pins, and fasteners is fundamental to mechanical design. + +**Architecture and Construction** +From decorative screens and facade elements to structural components with service openings, hollow shapes are everywhere in architecture. These techniques can help you design ventilation grilles, decorative panels, and complex structural elements. + +**Product Design** +Whether designing consumer electronics with cooling vents, furniture with weight-reducing cutouts, or decorative objects with intricate patterns, hollow shapes add both functionality and aesthetic appeal. + +**Prototyping and 3D Printing** +Creating hollow shapes is crucial for 3D printing applications where you need to reduce material usage, create internal channels, or design parts that require post-processing access through holes. + +## Key Principles to Remember + +The fundamental principle behind all hollow shape creation is proper wire orientation. When combining multiple wires to create a face, the system needs to understand which areas should be solid and which should be empty. This is achieved through wire direction and the reversal operation. + +Remember that you can extend these basic techniques to create more complex geometries. The same principles apply whether you're creating simple through-holes or complex multi-level hollow structures. The key is understanding how to properly orient and combine your wire boundaries. + +As you become more comfortable with these techniques, you'll find that creating hollow shapes becomes an intuitive part of your 3D modeling workflow, opening up new possibilities for both functional and artistic designs. diff --git a/docs/learn/code/common/occt/modeling/hollow-shapes/simple-hollow-grids.md b/docs/learn/code/common/occt/modeling/hollow-shapes/simple-hollow-grids.md new file mode 100644 index 00000000..84c722a5 --- /dev/null +++ b/docs/learn/code/common/occt/modeling/hollow-shapes/simple-hollow-grids.md @@ -0,0 +1,105 @@ +--- +sidebar_position: 2 +title: Simple Hollow Grids +sidebar_label: Simple Hollow Grids +description: Learn how to create parametric hollow grids with multiple holes arranged in regular patterns for applications like ventilation panels, perforated sheets, and decorative screens. +tags: [code, occt, rete, blockly, typescript] +--- + +import Tabs from '@theme/Tabs'; +import TabItem from '@theme/TabItem'; +import BitByBitRenderCanvas from '@site/src/components/BitByBitRenderCanvas'; + +OCCT category icon with a stylized logo representation + +Hollow grids represent one of the most practical applications of multiple hole creation techniques. These perforated patterns are essential in countless real-world applications - from ventilation panels and acoustic screens to decorative architectural elements and industrial filtration systems. + +Creating parametric hollow grids allows you to quickly generate complex perforated patterns that can be easily adjusted for different requirements. Whether you need more holes for better airflow, larger holes for specific filtration needs, or custom spacing for aesthetic purposes, understanding grid-based hole creation opens up tremendous design flexibility. + +## Creating a Parametric Hollow Grid + +The key to creating effective hollow grids lies in understanding how to generate regular patterns of holes programmatically. Instead of manually placing each hole, we use mathematical functions to create systematic arrays of positions, then populate those positions with identical hole shapes. + +This approach not only saves time but also ensures perfect regularity and makes it easy to modify the entire grid by changing just a few parameters. The technique scales efficiently from simple 3x3 grids to complex patterns with hundreds of holes. + + + + + + + gridSizeholeRadiusholeSpacingextrudeHeighthalfGridboundarySizesquarexPositionsyPositionswiresxzhollowFacehollowGridSolidgridSize14holeRadius0.8holeSpacing2extrudeHeight0.5halfGridDIVIDEgridSize2boundarySizeADDgridSize4squareboundarySize000010xPositionsholeSpacingNEGhalfGridhalfGridyPositionsholeSpacingNEGhalfGridhalfGridwiressquarex1xPositions1z1xPositions1INSERTLASTwiresholeRadiusGETFROM_STARTxPositionsx0GETFROM_STARTyPositionsz010hollowFacewiresTRUEhollowGridSolidhollowFace0extrudeHeight0hollowGridSolid","version":"0.20.7","type":"blockly"}} + title="Simple hollow grid" + /> + + + {\n // Grid parameters - easily adjustable for different requirements\n const gridSize = 14; // Overall grid dimension\n const holeRadius = 0.8; // Radius of each circular hole\n const holeSpacing = 2; // Distance between hole centers\n const extrudeHeight = 0.5; // Thickness of the final solid\n \n // Calculate grid boundaries\n const halfGrid = gridSize / 2;\n const boundarySize = gridSize + 4; // Add padding around holes\n \n // Create the outer boundary wire (square frame)\n const boundaryOptions = new SquareDto();\n boundaryOptions.size = boundarySize;\n boundaryOptions.center = [0, 0, 0];\n boundaryOptions.direction = [0, 1, 0];\n const boundaryWire = await wire.createSquareWire(boundaryOptions);\n \n // Generate grid positions using span functions\n const xPositions = vector.span({\n min: -halfGrid,\n max: halfGrid,\n step: holeSpacing\n });\n \n const zPositions = vector.span({\n min: -halfGrid,\n max: halfGrid,\n step: holeSpacing\n });\n \n // Create grid points by combining X and Z coordinates\n const gridPoints: Point3[] = [];\n for (const xPos of xPositions) {\n for (const zPos of zPositions) {\n gridPoints.push([xPos, 0, zPos]);\n }\n }\n \n // Create the hole template (circular wire)\n const holeOptions = new CircleDto();\n holeOptions.radius = holeRadius;\n holeOptions.center = [0, 0, 0];\n holeOptions.direction = [0, 1, 0];\n const holeTemplate = await wire.createCircleWire(holeOptions);\n \n // Create holes at each grid position\n const holes: TopoDSWirePointer[] = [];\n for (const position of gridPoints) {\n const translatedHole = await transforms.translate({\n shape: holeTemplate,\n translation: position\n });\n \n // Reverse each hole wire for proper orientation\n const reversedHole = await wire.reversedWire({ shape: translatedHole });\n holes.push(reversedHole);\n }\n \n // Combine boundary and all holes into a single wire list\n const allWires = [boundaryWire, ...holes];\n \n // Create a face from the boundary and all holes\n const faceOptions = new FaceFromWiresDto();\n faceOptions.shapes = allWires;\n faceOptions.planar = true;\n const gridFace = await face.createFaceFromWires(faceOptions);\n \n // Extrude the face to create a 3D hollow grid\n const extrudeOptions = new ExtrudeDto();\n extrudeOptions.shape = gridFace;\n extrudeOptions.direction = [0, extrudeHeight, 0];\n const hollowGrid = await operations.extrude(extrudeOptions);\n \n // Draw the resulting hollow grid\n bitbybit.draw.drawAnyAsync({\n entity: hollowGrid\n });\n}\n\n// Execute the function\nstart();","version":"0.20.7","type":"typescript"}} + title="Simple hollow grid" + /> + + + +## Understanding Grid Generation Logic + +The power of parametric grid creation lies in understanding how to systematically generate positions. The example above demonstrates several key concepts: + +**Span Functions**: These create evenly spaced arrays of numbers that define our grid coordinates. By using `vector.span()` with minimum, maximum, and step values, we can quickly generate regular spacing patterns. + +**Coordinate Combination**: Grid positions are created by combining X and Z coordinates while keeping Y constant (since we're working in a horizontal plane). This creates a Cartesian product of positions. + +**Template Replication**: Instead of creating each hole individually, we create one template hole and translate copies to each grid position. This ensures perfect consistency and reduces computational overhead. + +**Wire Orientation**: Each hole is reversed to ensure proper orientation when combined with the outer boundary. This maintains the hollow structure throughout the grid. + +## Customization and Variations + +The parametric approach makes it easy to create variations: + +- **Hole Shape**: Change from circles to squares, hexagons, or custom shapes +- **Grid Pattern**: Modify spacing, create rectangular instead of square grids, or implement offset patterns +- **Boundary Shape**: Use different outer boundaries like rectangles, circles, or complex custom shapes +- **Scale Control**: Adjust overall size, hole density, or individual hole sizes independently + +## Practical Applications + +Hollow grids have numerous real-world applications across multiple industries: + +**HVAC and Ventilation** +Perforated panels for air intake and exhaust systems require precise hole patterns to achieve specific airflow characteristics. The parametric approach allows engineers to quickly test different configurations and optimize for performance. + +**Architectural Design** +Decorative screens, facade elements, and privacy panels often use regular perforation patterns. These grids can create interesting light and shadow effects while maintaining structural integrity. + +**Industrial Filtration** +Filter elements, strainers, and separation screens require carefully designed hole patterns. The ability to easily adjust hole size and spacing makes it simple to meet specific filtration requirements. + +**Acoustic Engineering** +Perforated panels for sound absorption and control use precise hole patterns to achieve desired acoustic properties. Different grid configurations can target specific frequency ranges. + +**Electronics and Technology** +Speaker grilles, ventilation panels for electronics enclosures, and heat dissipation elements all benefit from optimized perforation patterns that balance functionality with aesthetics. + +## Advanced Considerations + +When working with hollow grids, consider these important factors: + +**Material Efficiency**: The ratio of open area to solid material affects both performance and structural strength. Grid parameters should balance functional requirements with material usage. + +**Manufacturing Constraints**: Different production methods (laser cutting, punching, machining) have specific limitations on minimum hole sizes, spacing, and edge distances that should inform your design parameters. + +**Structural Analysis**: Regular perforation patterns create stress concentrations that may require analysis for load-bearing applications. The parametric approach makes it easy to test different configurations. + +**Performance Optimization**: For functional applications like ventilation or filtration, the grid pattern directly affects performance metrics like pressure drop, flow rate, and efficiency. + +The parametric hollow grid technique demonstrated here provides a foundation for creating sophisticated perforated designs that can be easily adapted to meet specific requirements while maintaining design consistency and manufacturability. From b20255c93e0b6ecbad7d60614c372bbe4f43bb39 Mon Sep 17 00:00:00 2001 From: Matas Ubarevicius Date: Sat, 4 Oct 2025 13:39:59 +0300 Subject: [PATCH 2/5] hexagon holes docs --- .../hollow-shapes/hexagon-holes-on-face.md | 134 ++++++++++++++++++ 1 file changed, 134 insertions(+) create mode 100644 docs/learn/code/common/occt/modeling/hollow-shapes/hexagon-holes-on-face.md diff --git a/docs/learn/code/common/occt/modeling/hollow-shapes/hexagon-holes-on-face.md b/docs/learn/code/common/occt/modeling/hollow-shapes/hexagon-holes-on-face.md new file mode 100644 index 00000000..ceb5bf0c --- /dev/null +++ b/docs/learn/code/common/occt/modeling/hollow-shapes/hexagon-holes-on-face.md @@ -0,0 +1,134 @@ +--- +sidebar_position: 4 +title: Hexagon Holes On Face +sidebar_label: Hexagon Holes On Face +description: Create stunning honeycomb patterns and hexagonal perforations using BitByBit's subdivideToHexagonHoles function for architectural panels, biomimetic designs, and structural applications. +tags: [code, occt, rete, blockly, typescript] +--- + +import Tabs from '@theme/Tabs'; +import TabItem from '@theme/TabItem'; +import BitByBitRenderCanvas from '@site/src/components/BitByBitRenderCanvas'; + +OCCT category icon with a stylized logo representation + +Hexagonal patterns are found throughout nature - from honeycomb structures to crystal formations. The `subdivideToHexagonHoles` function brings this efficiency to your designs, creating optimal packing patterns with superior strength-to-weight ratios. This function is ideal for biomimetic designs, structural panels, and advanced filtration systems where hexagonal geometry provides maximum efficiency. + + + + + + + recFacefacesrecFace2014000010facesrecFace1010[0.9][0.9]FALSEFALSE0.010.01GETFIRSTfaces010","version":"0.20.7","type":"blockly"}} + title="Hexagon holes on face" + /> + + + {\n // Create a rectangular face as the base shape\n const faceOptions = new RectangleDto();\n faceOptions.width = 20;\n faceOptions.length = 14;\n faceOptions.center = [0, 0, 0];\n faceOptions.direction = [0, 1, 0];\n const rectangleFace = await face.createRectangleFace(faceOptions);\n\n // Define scale patterns for U and V directions\n // For hexagons, uniform scaling often works best due to natural packing\n const scalePatternU = [0.9]; // Uniform hexagon size in U direction\n const scalePatternV = [0.9]; // Uniform hexagon size in V direction\n\n // Subdivide the face into hexagonal holes\n const subdivideOptions = new FaceSubdivideToHexagonHolesDto();\n subdivideOptions.shape = rectangleFace;\n subdivideOptions.nrHexagonsU = 10; // Number of hexagon divisions in U direction\n subdivideOptions.nrHexagonsV = 10; // Number of hexagon divisions in V direction\n subdivideOptions.flatU = false; // Pointy-top orientation (false) vs flat-top (true)\n subdivideOptions.holesToFaces = false; // Return wires instead of faces\n subdivideOptions.offsetFromBorderU = 0.01; // Small border offset in U direction\n subdivideOptions.offsetFromBorderV = 0.01; // Small border offset in V direction\n subdivideOptions.scalePatternU = scalePatternU;\n subdivideOptions.scalePatternV = scalePatternV;\n\n const holes = await face.subdivideToHexagonHoles(subdivideOptions);\n\n // Get the first hole (the outer boundary with hexagonal holes)\n const firstHole = lists.getItem({ list: holes, index: 0, clone: true });\n\n // Extrude the face with holes to create a 3D honeycomb structure\n const extrudeOptions = new ExtrudeDto();\n extrudeOptions.shape = firstHole;\n extrudeOptions.direction = [0, 1, 0];\n const extrudedSolid = await operations.extrude(extrudeOptions);\n\n // Draw the resulting 3D solid with hexagonal holes\n bitbybit.draw.drawAnyAsync({\n entity: extrudedSolid\n });\n}\n\n// Execute the function\nstart();","version":"0.20.7","type":"typescript"}} + title="Hexagon holes on face" + /> + + + +## Understanding Hexagonal Hole Subdivision + +The `subdivideToHexagonHoles` function creates honeycomb-like patterns by intelligently arranging hexagonal holes in an optimal packing configuration. Unlike rectangular grids, hexagonal patterns provide the most efficient use of space while maintaining structural integrity - a principle observed throughout nature from beehives to crystal structures. + +This approach is particularly valuable for applications requiring: +- Maximum strength-to-weight ratio +- Optimal material efficiency +- Natural aesthetic appeal +- Superior structural properties +- Biomimetic design principles + +## Key Parameters and Hexagonal Properties + +### Grid Division Controls + +**nrHexagonsU** and **nrHexagonsV**: These parameters control the number of hexagonal divisions in each direction. The function automatically handles the complex geometry of hexagonal packing, including the offset pattern that creates the characteristic honeycomb structure. + +**offsetFromBorderU** and **offsetFromBorderV**: Due to the efficient packing of hexagons, smaller offset values (0.01-0.05) typically work well, as hexagons naturally create more uniform edge spacing than rectangular patterns. + +### Hexagonal Orientation Control + +**flatU**: This unique parameter controls hexagon orientation: +- `false`: Creates "pointy-top" hexagons (⬢) - optimal for structural applications +- `true`: Creates "flat-top" hexagons (⬣) - often preferred for visual applications + +The orientation affects both aesthetics and structural properties, with pointy-top configurations typically providing better load distribution. + +### Scale Pattern Optimization + +For hexagonal patterns, scale patterns work differently than rectangular grids: + +- **Uniform scaling**: `[1.0]` or `[0.9]` often produces the most visually pleasing results +- **Gentle variations**: `[0.9, 0.95, 0.9]` create subtle size variations without disrupting the natural flow +- **Gradient effects**: `[1.0, 0.8, 0.6, 0.8, 1.0]` can create interesting radial or linear transitions + +## Advanced Hexagonal Design Techniques + +### Creating Natural Flow Patterns + +Hexagonal patterns excel at creating organic, flowing designs: + +```javascript +// Gentle size variation mimicking natural growth +const organicPattern = [0.95, 0.9, 0.85, 0.9, 0.95]; + +// Breathing pattern for dynamic facades +const breathingPattern = [0.7, 0.85, 1.0, 0.85, 0.7]; + +// Honeycomb density variation +const densityPattern = [1.0, 0.8, 0.6, 0.4, 0.6, 0.8, 1.0]; +``` + +### Structural Optimization + +Hexagonal patterns provide superior structural properties: + +**Load Distribution**: The six-sided geometry distributes forces more evenly than rectangular patterns +**Material Efficiency**: Hexagons provide maximum area coverage with minimum perimeter +**Buckling Resistance**: The geometry naturally resists deformation under load +**Torsional Strength**: Multiple load paths provide excellent resistance to twisting forces + +## Biomimetic Applications + +### Nature-Inspired Design + +**Honeycomb Structures**: Direct biomimicry of bee honeycomb for lightweight panels and cores +**Crystal Patterns**: Mimicking natural crystal formations for architectural facades +**Cellular Structures**: Replicating biological cell arrangements for medical applications +**Efficiency Patterns**: Following natural optimization principles for maximum performance + +### Structural Biomimicry + +**Lightweight Cores**: Honeycomb cores for composite panels in aerospace and automotive +**Energy Absorption**: Hexagonal patterns for crash structures and impact protection +**Heat Dissipation**: Natural convection patterns for thermal management +**Acoustic Control**: Bio-inspired sound absorption and diffusion patterns + +## Applications and Next Steps + +The `subdivideToHexagonHoles` function excels in numerous cutting-edge applications: + +- **Aerospace**: Lightweight structural panels with optimal strength-to-weight ratios +- **Architecture**: Biomimetic facades that combine aesthetics with structural efficiency +- **Automotive**: Impact-absorbing structures and lightweight body panels +- **Medical Devices**: Biocompatible implants that mimic natural bone structure +- **Electronics**: Heat dissipation panels and electromagnetic shielding + +Hexagonal patterns represent the pinnacle of natural efficiency. Start with uniform patterns to understand the basic behavior, then experiment with orientation (flatU parameter) and gentle scale variations. The inherent efficiency of hexagonal packing means that even simple patterns often produce sophisticated results. + +Combine hexagonal subdivision with fillets for rounded corners, boolean operations for complex cutouts, and material analysis tools to optimize your designs for specific performance requirements. The mathematical perfection of hexagonal geometry ensures your designs will have both natural beauty and superior functional properties. From 0425c9c0804b03f86c5782a0085209516957594e Mon Sep 17 00:00:00 2001 From: Matas Ubarevicius Date: Sat, 4 Oct 2025 18:23:41 +0300 Subject: [PATCH 3/5] some new tutorials on hollow shapes --- .../code/common/occt/modeling/_category_.json | 2 +- .../modeling/hollow-shapes/_category_.json | 4 +- .../hollow-shapes/hexagon-hive-flat.md | 67 +++++++++ .../modeling/hollow-shapes/hexagon-hive.md | 128 ++++++++++++++++++ .../hollow-shapes/hexagon-holes-on-face.md | 56 +------- .../hollow-shapes/rectangle-holes-on-face.md | 38 +----- .../hollow-shapes/simple-hollow-grids.md | 42 +----- .../dev/occt/lib/api/inputs/occ-inputs.ts | 2 +- 8 files changed, 211 insertions(+), 128 deletions(-) create mode 100644 docs/learn/code/common/occt/modeling/hollow-shapes/hexagon-hive-flat.md create mode 100644 docs/learn/code/common/occt/modeling/hollow-shapes/hexagon-hive.md diff --git a/docs/learn/code/common/occt/modeling/_category_.json b/docs/learn/code/common/occt/modeling/_category_.json index ad8186b5..ed8e8f94 100644 --- a/docs/learn/code/common/occt/modeling/_category_.json +++ b/docs/learn/code/common/occt/modeling/_category_.json @@ -1,6 +1,6 @@ { "label": "Modeling", - "position": 5, + "position": 6, "link": { "type": "generated-index", "title": "Common OCCT Modeling Techniques", diff --git a/docs/learn/code/common/occt/modeling/hollow-shapes/_category_.json b/docs/learn/code/common/occt/modeling/hollow-shapes/_category_.json index e9fc43b7..9a1f9f54 100644 --- a/docs/learn/code/common/occt/modeling/hollow-shapes/_category_.json +++ b/docs/learn/code/common/occt/modeling/hollow-shapes/_category_.json @@ -1,10 +1,10 @@ { "label": "Hollow Shapes", - "position": 5, + "position": 1, "link": { "type": "generated-index", "title": "Hollow Shapes", "description": "While using boolean operations to cut out holes might be straightforward, there are several nuances to consider.", - "slug": "/code/common/occt/modeling/holes-in-faces" + "slug": "/code/common/occt/modeling/hollow-shapes" } } \ No newline at end of file diff --git a/docs/learn/code/common/occt/modeling/hollow-shapes/hexagon-hive-flat.md b/docs/learn/code/common/occt/modeling/hollow-shapes/hexagon-hive-flat.md new file mode 100644 index 00000000..b6682b97 --- /dev/null +++ b/docs/learn/code/common/occt/modeling/hollow-shapes/hexagon-hive-flat.md @@ -0,0 +1,67 @@ +--- +sidebar_position: 6 +title: Hexagon Hive Flat +sidebar_label: Hexagon Hive Flat +description: Create flat honeycomb panels by sewing hexagonal faces together into unified structures, ideal for architectural panels, laser cutting templates, and manufacturing-optimized designs. +tags: [code, occt, rete, blockly, typescript] +--- + +import Tabs from '@theme/Tabs'; +import TabItem from '@theme/TabItem'; +import BitByBitRenderCanvas from '@site/src/components/BitByBitRenderCanvas'; + +OCCT category icon with a stylized logo representation + +Flat hexagon hive construction creates optimized honeycomb panels by treating the entire pattern as a unified surface rather than individual cells. This approach generates continuous surfaces with integrated holes, making it ideal for manufacturing processes like laser cutting, CNC machining, or large-scale 3D printing where single-piece construction is preferred over assembled components. + + + + + + + widthheightnrHexWidthnrHexHeightwiresHexLargewiresHexSmallrandomHeightshexagonFacesiwidth10height20nrHexWidth10nrHexHeight20wiresHexLargewidthheightnrHexWidthnrHexHeightFALSEFALSEFALSEFALSEFALSEwiresHexSmallwidthheightnrHexWidthnrHexHeightFALSEFALSEFALSEFALSEFALSE0.70.7randomHeights12wiresHexLargehexagonFacesi1wiresHexLarge1INSERTLASThexagonFacesGETFROM_STARTwiresHexLargeiGETFROM_STARTwiresHexSmalliTRUEhexagonFaces1e-7TRUETRUETRUE010","version":"0.20.7","type":"blockly"}} + title="Hexagon hive" + /> + + + {\n // Create hexagonal grid parameters\n const gridWidth = 10;\n const gridHeight = 20;\n const hexagonsInWidth = 10;\n const hexagonsInHeight = 20;\n\n // Generate large hexagonal wire grid (outer walls)\n const hexGridLargeOptions = new HexagonsInGridDto();\n hexGridLargeOptions.width = gridWidth;\n hexGridLargeOptions.height = gridHeight;\n hexGridLargeOptions.nrHexagonsInWidth = hexagonsInWidth;\n hexGridLargeOptions.nrHexagonsInHeight = hexagonsInHeight;\n hexGridLargeOptions.flatTop = false;\n hexGridLargeOptions.extendTop = false;\n hexGridLargeOptions.extendBottom = false;\n hexGridLargeOptions.extendLeft = false;\n hexGridLargeOptions.extendRight = false;\n\n const wiresHexLarge = await wire.hexagonsInGrid(hexGridLargeOptions);\n\n // Generate small hexagonal wire grid (inner holes)\n const hexGridSmallOptions = new HexagonsInGridDto();\n hexGridSmallOptions.width = gridWidth;\n hexGridSmallOptions.height = gridHeight;\n hexGridSmallOptions.nrHexagonsInWidth = hexagonsInWidth;\n hexGridSmallOptions.nrHexagonsInHeight = hexagonsInHeight;\n hexGridSmallOptions.flatTop = false;\n hexGridSmallOptions.extendTop = false;\n hexGridSmallOptions.extendBottom = false;\n hexGridSmallOptions.extendLeft = false;\n hexGridSmallOptions.extendRight = false;\n hexGridSmallOptions.scalePatternWidth = [0.7];\n hexGridSmallOptions.scalePatternHeight = [0.7];\n\n const wiresHexSmall = await wire.hexagonsInGrid(hexGridSmallOptions);\n\n // Generate random heights for creating individual faces\n const randomHeights = math.randomNumbers({\n low: 1,\n high: 2,\n count: wiresHexLarge.length\n });\n\n // Create faces with holes for each hexagon cell\n const hexagonFaces: TopoDSFacePointer[] = [];\n for (let i = 0; i < wiresHexLarge.length; i++) {\n // Get the outer and inner wires for this cell\n const outerWire = wiresHexLarge[i];\n const innerWire = wiresHexSmall[i];\n\n // Reverse the inner wire to create a hole\n const reverseOptions = new ShapeDto();\n reverseOptions.shape = innerWire;\n const reversedInnerWire = await wire.reversedWire(reverseOptions);\n\n // Create face with hole\n const faceOptions = new FaceFromWiresDto();\n faceOptions.shapes = [outerWire, reversedInnerWire];\n faceOptions.planar = true;\n const hexFaceWithHole = await face.createFaceFromWires(faceOptions);\n\n hexagonFaces.push(hexFaceWithHole);\n }\n\n // Sew faces together\n const sewOptions = new SewDto(hexagonFaces);\n sewOptions.tolerance = 1e-7;\n const sewedFaces = await shell.sewFaces(sewOptions);\n\n // Unify same domain for cleaner geometry\n const unifyOptions = new UnifySameDomainDto();\n unifyOptions.shape = sewedFaces;\n unifyOptions.unifyEdges = true;\n unifyOptions.unifyFaces = true;\n unifyOptions.concatBSplines = true;\n const unifiedShape = await shape.unifySameDomain(unifyOptions);\n\n // Extrude the unified shape\n const extrudeOptions = new ExtrudeDto();\n extrudeOptions.shape = unifiedShape;\n extrudeOptions.direction = [0, 1, 0];\n const extrudedHive = await operations.extrude(extrudeOptions);\n\n // Draw the resulting flat hive structure\n bitbybit.draw.drawAnyAsync({\n entity: extrudedHive\n });\n}\n\n// Execute the function\nstart();","version":"0.20.7","type":"typescript"}} + title="Hexagon hive" + /> + + + +## Flat Hive Construction + +Unlike individual cell approaches, flat hive construction treats the entire honeycomb pattern as a single, continuous surface. This method combines all hexagonal wires at once, sews the resulting faces together, and extrudes the unified structure as one piece. + +### Key Advantages + +- **Manufacturing Efficiency**: Single continuous surface ideal for CNC machining and laser cutting +- **Structural Integrity**: No joints between cells, creating stronger unified panels +- **Processing Speed**: Reduces computational overhead by avoiding individual cell operations +- **Clean Geometry**: Face sewing and domain unification eliminate edge artifacts + +### Process Overview + +1. **Dual Wire Generation**: Create outer boundary and inner hole wire patterns +2. **Wire Reversal**: Reverse inner wires to ensure proper hole orientation +3. **Unified Face Creation**: Combine all wires into faces simultaneously +4. **Face Sewing**: Join faces into a continuous shell structure +5. **Domain Unification**: Clean up geometry by merging adjacent surfaces +6. **Single Extrusion**: Extrude the entire unified surface at once + +## Conclusion + +Flat hexagon hive construction optimizes honeycomb creation for manufacturing and structural applications. By treating the pattern as a unified surface rather than assembled components, this approach produces cleaner geometry, stronger structures, and more efficient manufacturing workflows. The method is particularly valuable for architectural panels, industrial components, and any application where single-piece construction is preferred over multi-part assembly. diff --git a/docs/learn/code/common/occt/modeling/hollow-shapes/hexagon-hive.md b/docs/learn/code/common/occt/modeling/hollow-shapes/hexagon-hive.md new file mode 100644 index 00000000..9c91197f --- /dev/null +++ b/docs/learn/code/common/occt/modeling/hollow-shapes/hexagon-hive.md @@ -0,0 +1,128 @@ +--- +sidebar_position: 5 +title: Hexagon Hive +sidebar_label: Hexagon Hive +description: Create intricate three-dimensional honeycomb structures by generating individual hexagon cells with controlled random heights, perfect for biomimetic architecture, structural optimization, and artistic installations. +tags: [code, occt, rete, blockly, typescript] +--- + +import Tabs from '@theme/Tabs'; +import TabItem from '@theme/TabItem'; +import BitByBitRenderCanvas from '@site/src/components/BitByBitRenderCanvas'; + +OCCT category icon with a stylized logo representation + +Moving beyond simple perforated patterns, three-dimensional hive structures create authentic honeycomb architectures where each hexagonal cell has both outer walls and inner cavities with varying heights. This technique generates true hive geometries with hollow chambers, combining the structural efficiency of hexagonal tessellation with the material optimization of cellular construction, perfect for lightweight yet strong architectural elements. + + + + + + + widthheightnrHexWidthnrHexHeightwiresHexLargewiresHexSmallrandomHeightshexagons3DicompoundShapeForFastRenderingwidth10height20nrHexWidth10nrHexHeight20wiresHexLargewidthheightnrHexWidthnrHexHeightFALSEFALSEFALSEFALSEFALSEwiresHexSmallwidthheightnrHexWidthnrHexHeightFALSEFALSEFALSEFALSEFALSE0.80.8randomHeights12wiresHexLargehexagons3Di1wiresHexLarge1INSERTLASThexagons3DGETFROM_STARTwiresHexLargeiGETFROM_STARTwiresHexSmalliTRUE0GETFROM_STARTrandomHeightsi0compoundShapeForFastRenderinghexagons3DcompoundShapeForFastRendering","version":"0.20.7","type":"blockly"}} + title="Hexagon hive" + /> + + + {\n // Create hexagonal grid parameters\n const gridWidth = 10;\n const gridHeight = 20;\n const hexagonsInWidth = 10;\n const hexagonsInHeight = 20;\n\n // Generate large hexagonal wire grid (outer walls)\n const hexGridLargeOptions = new HexagonsInGridDto();\n hexGridLargeOptions.width = gridWidth;\n hexGridLargeOptions.height = gridHeight;\n hexGridLargeOptions.nrHexagonsInWidth = hexagonsInWidth;\n hexGridLargeOptions.nrHexagonsInHeight = hexagonsInHeight;\n\n const wiresHexLarge = await wire.hexagonsInGrid(hexGridLargeOptions);\n\n // Generate small hexagonal wire grid (inner holes)\n const hexGridSmallOptions = new HexagonsInGridDto();\n hexGridSmallOptions.width = gridWidth;\n hexGridSmallOptions.height = gridHeight;\n hexGridSmallOptions.nrHexagonsInWidth = hexagonsInWidth;\n hexGridSmallOptions.nrHexagonsInHeight = hexagonsInHeight;\n hexGridSmallOptions.scalePatternWidth = [0.8];\n hexGridSmallOptions.scalePatternHeight = [0.8];\n\n const wiresHexSmall = await wire.hexagonsInGrid(hexGridSmallOptions);\n\n // Generate random heights for each hexagon cell\n const randomHeights = math.randomNumbers({\n low: 1,\n high: 2,\n count: wiresHexLarge.length\n });\n\n // Process each hexagon to create 3D cells with holes\n const hexagons3D: TopoDSSolidPointer[] = [];\n\n for (let i = 0; i < wiresHexLarge.length; i++) {\n // Get the outer and inner wires for this cell\n const outerWire = wiresHexLarge[i];\n const innerWire = wiresHexSmall[i];\n\n // Reverse the inner wire to create a hole\n const reverseOptions = new ShapeDto();\n reverseOptions.shape = innerWire;\n const reversedInnerWire = await wire.reversedWire(reverseOptions);\n\n // Create face with hole\n const faceOptions = new FaceFromWiresDto();\n faceOptions.shapes = [outerWire, reversedInnerWire];\n faceOptions.planar = true;\n const hexFaceWithHole = await face.createFaceFromWires(faceOptions);\n\n // Extrude the face with random height\n const extrudeOptions = new ExtrudeDto();\n extrudeOptions.shape = hexFaceWithHole;\n extrudeOptions.direction = [0, randomHeights[i], 0];\n\n const extrudedCell = await operations.extrude(extrudeOptions);\n hexagons3D.push(extrudedCell);\n }\n\n // Combine all extruded cells into a compound shape for fast rendering\n const compoundOptions = new CompoundShapesDto();\n compoundOptions.shapes = hexagons3D;\n const compoundShapeForFastRendering = await compound.makeCompound(compoundOptions);\n\n // Draw the resulting three-dimensional hive structure\n bitbybit.draw.drawAnyAsync({\n entity: compoundShapeForFastRendering\n });\n}\n\n// Execute the function\nstart();","version":"0.20.7","type":"typescript"}} + title="Hexagon hive" + /> + + + +## Understanding Three-Dimensional Hive Construction + +The hexagon hive technique represents a sophisticated evolution of flat honeycomb patterns. Instead of creating simple perforations, this approach generates individual hexagonal cells that can be independently manipulated in three dimensions. Each cell becomes a discrete element with its own height, creating complex topographical landscapes that maintain the structural efficiency of hexagonal geometry. + +This hollow hive method is particularly powerful for: +- Lightweight structural elements with maximum strength-to-weight ratios +- Architectural facades with natural ventilation and thermal regulation +- Acoustic panels with controlled sound absorption through hollow chambers +- Biomimetic designs that authentically replicate natural honeycomb structures +- Material-efficient construction reducing weight while maintaining structural integrity +- Artistic installations exploring the interplay of solid and void + +## Key Components of Hive Generation + +### Hexagonal Grid Foundation + +The process begins with `hexagonsInGrid`, which creates a structured array of hexagonal wire elements: + +- **Grid Dimensions**: `width` and `height` define the overall area +- **Cell Density**: `nrHexagonsInWidth` and `nrHexagonsInHeight` control subdivision +- **Orientation**: `flatTop` parameter affects the hexagon orientation and packing +- **Edge Behavior**: Extension parameters control how the pattern handles boundaries + +### Individual Cell Processing + +Unlike simple perforated patterns, authentic hive construction creates hollow chambers with walls: + +1. **Dual Grid Generation**: Large hexagons form outer walls, smaller scaled hexagons create inner cavities +2. **Face with Hole Creation**: Each cell combines outer and reversed inner wires to form faces with holes +3. **Height Assignment**: Random or controlled heights are assigned to each hollow cell +4. **Independent Extrusion**: Each face with hole is extruded to create hollow chambers +5. **Compound Assembly**: All hollow cells are combined into a unified hive structure + +### Controlled Randomization + +The random height generation is a critical aspect that creates organic complexity: + +```javascript +// Note: These are pseudo code examples for illustration +// Controlled random variation +const subtleVariation = math.randomNumbers({ low: 0.8, high: 1.2, count: cellCount }); + +// Dramatic height differences +const dramaticVariation = math.randomNumbers({ low: 0.2, high: 4.0, count: cellCount }); + +// Biased toward specific ranges +const biasedHeights = math.randomNumbers({ low: 1.5, high: 2.5, count: cellCount }); +``` + +## Advanced Hive Design Strategies + +### Gradient-Based Height Control + +Instead of pure randomization, you can create sophisticated gradient effects: + +```javascript +// Note: These are pseudo code examples for conceptual illustration +// Radial gradient from center +const createRadialGradient = (faces, minHeight, maxHeight) => { + const center = [gridWidth/2, 0, gridHeight/2]; + return faces.map((face, index) => { + const distance = calculateDistanceFromCenter(face, center); + const normalizedDistance = distance / maxRadius; + return minHeight + (maxHeight - minHeight) * normalizedDistance; + }); +}; + +// Wave-like patterns +const createWavePattern = (faces, amplitude, frequency) => { + return faces.map((face, index) => { + const position = getFacePosition(face); + const wave = Math.sin(position.x * frequency) * Math.cos(position.z * frequency); + return baseHeight + amplitude * wave; + }); +}; +``` + +## Conclusion + +The hexagon hive technique demonstrates how parametric design can create sophisticated three-dimensional structures that balance geometric order with organic variation. By generating hollow chambers with controlled random heights, this method produces authentic honeycomb architectures that are both structurally efficient and visually compelling. + +The dual-grid approach—combining outer walls with inner cavities—enables the creation of lightweight yet strong elements suitable for architectural facades, acoustic panels, and biomimetic installations. The parametric nature of the system ensures adaptability across different scales and applications while maintaining the fundamental efficiency of hexagonal tessellation. + +This technique bridges computational design with natural patterns, offering architects and designers a powerful tool for creating structures that are simultaneously systematic and organic, efficient and expressive. diff --git a/docs/learn/code/common/occt/modeling/hollow-shapes/hexagon-holes-on-face.md b/docs/learn/code/common/occt/modeling/hollow-shapes/hexagon-holes-on-face.md index ceb5bf0c..82190242 100644 --- a/docs/learn/code/common/occt/modeling/hollow-shapes/hexagon-holes-on-face.md +++ b/docs/learn/code/common/occt/modeling/hollow-shapes/hexagon-holes-on-face.md @@ -77,58 +77,10 @@ For hexagonal patterns, scale patterns work differently than rectangular grids: - **Gentle variations**: `[0.9, 0.95, 0.9]` create subtle size variations without disrupting the natural flow - **Gradient effects**: `[1.0, 0.8, 0.6, 0.8, 1.0]` can create interesting radial or linear transitions -## Advanced Hexagonal Design Techniques +## Design Considerations and Applications -### Creating Natural Flow Patterns +Hexagonal patterns offer unique advantages through their natural efficiency. You can create organic flow patterns using gentle scale variations like `[0.95, 0.9, 0.85, 0.9, 0.95]` or breathing effects with `[0.7, 0.85, 1.0, 0.85, 0.7]`. The six-sided geometry naturally distributes loads more evenly than rectangular patterns while providing maximum area coverage with minimum material usage. -Hexagonal patterns excel at creating organic, flowing designs: +These patterns excel in aerospace applications for lightweight structural panels, architectural facades that combine aesthetics with efficiency, and biomedical devices that mimic natural cellular structures. The `flatU` parameter controls orientation - use `false` for pointy-top hexagons in structural applications or `true` for flat-top configurations when visual appeal is the priority. -```javascript -// Gentle size variation mimicking natural growth -const organicPattern = [0.95, 0.9, 0.85, 0.9, 0.95]; - -// Breathing pattern for dynamic facades -const breathingPattern = [0.7, 0.85, 1.0, 0.85, 0.7]; - -// Honeycomb density variation -const densityPattern = [1.0, 0.8, 0.6, 0.4, 0.6, 0.8, 1.0]; -``` - -### Structural Optimization - -Hexagonal patterns provide superior structural properties: - -**Load Distribution**: The six-sided geometry distributes forces more evenly than rectangular patterns -**Material Efficiency**: Hexagons provide maximum area coverage with minimum perimeter -**Buckling Resistance**: The geometry naturally resists deformation under load -**Torsional Strength**: Multiple load paths provide excellent resistance to twisting forces - -## Biomimetic Applications - -### Nature-Inspired Design - -**Honeycomb Structures**: Direct biomimicry of bee honeycomb for lightweight panels and cores -**Crystal Patterns**: Mimicking natural crystal formations for architectural facades -**Cellular Structures**: Replicating biological cell arrangements for medical applications -**Efficiency Patterns**: Following natural optimization principles for maximum performance - -### Structural Biomimicry - -**Lightweight Cores**: Honeycomb cores for composite panels in aerospace and automotive -**Energy Absorption**: Hexagonal patterns for crash structures and impact protection -**Heat Dissipation**: Natural convection patterns for thermal management -**Acoustic Control**: Bio-inspired sound absorption and diffusion patterns - -## Applications and Next Steps - -The `subdivideToHexagonHoles` function excels in numerous cutting-edge applications: - -- **Aerospace**: Lightweight structural panels with optimal strength-to-weight ratios -- **Architecture**: Biomimetic facades that combine aesthetics with structural efficiency -- **Automotive**: Impact-absorbing structures and lightweight body panels -- **Medical Devices**: Biocompatible implants that mimic natural bone structure -- **Electronics**: Heat dissipation panels and electromagnetic shielding - -Hexagonal patterns represent the pinnacle of natural efficiency. Start with uniform patterns to understand the basic behavior, then experiment with orientation (flatU parameter) and gentle scale variations. The inherent efficiency of hexagonal packing means that even simple patterns often produce sophisticated results. - -Combine hexagonal subdivision with fillets for rounded corners, boolean operations for complex cutouts, and material analysis tools to optimize your designs for specific performance requirements. The mathematical perfection of hexagonal geometry ensures your designs will have both natural beauty and superior functional properties. +Start with uniform scaling patterns to understand the basic behavior, then experiment with gentle variations. The mathematical perfection of hexagonal geometry means even simple patterns often produce sophisticated results that balance natural beauty with superior functional performance. diff --git a/docs/learn/code/common/occt/modeling/hollow-shapes/rectangle-holes-on-face.md b/docs/learn/code/common/occt/modeling/hollow-shapes/rectangle-holes-on-face.md index 09dd11c0..30c52bbf 100644 --- a/docs/learn/code/common/occt/modeling/hollow-shapes/rectangle-holes-on-face.md +++ b/docs/learn/code/common/occt/modeling/hollow-shapes/rectangle-holes-on-face.md @@ -77,40 +77,10 @@ The pattern repeats across the grid, so if you have 10 divisions and a 3-element - `false`: Returns wire boundaries (useful for creating faces with holes) - `true`: Returns individual face elements (useful for separate processing of each hole) -## Advanced Pattern Creation Techniques +## Pattern Creation and Applications -### Creating Gradient Effects +You can create sophisticated visual effects using carefully designed scale patterns. Try fade effects with `[0.2, 0.4, 0.6, 0.8, 1.0, 0.8, 0.6, 0.4, 0.2]`, alternating patterns like `[1.0, 0.3, 1.0, 0.3]`, or exponential growth with `[0.1, 0.2, 0.4, 0.8, 1.0]`. The patterns repeat across the grid, so a 3-element pattern on 10 divisions will cycle through the values continuously. -You can create sophisticated visual effects by carefully designing your scale patterns: +This function excels in architectural applications for facade panels and decorative screens, manufacturing contexts like sheet metal fabrication, and engineering applications including filtration systems and acoustic panels. The `holesToFaces` parameter controls whether you get wire boundaries for creating faces with holes or individual face elements for separate processing. -```javascript -// Fade from center to edges -const fadePattern = [0.2, 0.4, 0.6, 0.8, 1.0, 0.8, 0.6, 0.4, 0.2]; - -// Alternating large and small -const alternatingPattern = [1.0, 0.3, 1.0, 0.3]; - -// Exponential growth -const exponentialPattern = [0.1, 0.2, 0.4, 0.8, 1.0]; -``` - -### Combining with Other Operations - -The subdivided patterns work excellently with other OCCT operations: - -**Fillets**: Apply 2D fillets to the wires before creating faces for rounded hole corners -**Boolean Operations**: Use the holes as cutting tools for more complex geometries -**Array Operations**: Combine multiple subdivided faces to create larger patterns -**Transformations**: Rotate or scale the entire pattern for dynamic effects - -## Applications and Next Steps - -The `subdivideToRectangleHoles` function excels in numerous applications: - -- **Architecture**: Facade panels, privacy screens, and decorative elements -- **Manufacturing**: Sheet metal fabrication, injection molding, and 3D printing -- **Engineering**: Filtration systems, heat exchangers, and acoustic panels - -For optimal results, start with simple uniform patterns before experimenting with complex scale arrays. The function transforms hundreds of individual operations into a single, parametric call, making it invaluable for creating sophisticated perforated designs. - -Combine this technique with fillets, boolean operations, and transformations to create even more complex geometric patterns. The parametric nature ensures your designs remain flexible and easily adjustable for different manufacturing requirements. +Start with simple uniform patterns before experimenting with complex scale arrays. The parametric nature transforms hundreds of individual operations into a single call, making it invaluable for creating sophisticated perforated designs that remain flexible and easily adjustable for different requirements. diff --git a/docs/learn/code/common/occt/modeling/hollow-shapes/simple-hollow-grids.md b/docs/learn/code/common/occt/modeling/hollow-shapes/simple-hollow-grids.md index 84c722a5..131f376e 100644 --- a/docs/learn/code/common/occt/modeling/hollow-shapes/simple-hollow-grids.md +++ b/docs/learn/code/common/occt/modeling/hollow-shapes/simple-hollow-grids.md @@ -62,44 +62,10 @@ The power of parametric grid creation lies in understanding how to systematicall **Wire Orientation**: Each hole is reversed to ensure proper orientation when combined with the outer boundary. This maintains the hollow structure throughout the grid. -## Customization and Variations +## Applications and Design Considerations -The parametric approach makes it easy to create variations: +The parametric approach demonstrated here makes hollow grids incredibly versatile. You can easily customize hole shapes from circles to squares or hexagons, adjust grid patterns for rectangular layouts, or modify boundary shapes to fit specific requirements. -- **Hole Shape**: Change from circles to squares, hexagons, or custom shapes -- **Grid Pattern**: Modify spacing, create rectangular instead of square grids, or implement offset patterns -- **Boundary Shape**: Use different outer boundaries like rectangles, circles, or complex custom shapes -- **Scale Control**: Adjust overall size, hole density, or individual hole sizes independently +These techniques are particularly valuable in HVAC systems where precise airflow patterns are critical, architectural projects requiring decorative perforated screens, and industrial applications like filtration systems or acoustic panels. The ability to quickly adjust parameters means you can optimize designs for different performance requirements while maintaining consistency. -## Practical Applications - -Hollow grids have numerous real-world applications across multiple industries: - -**HVAC and Ventilation** -Perforated panels for air intake and exhaust systems require precise hole patterns to achieve specific airflow characteristics. The parametric approach allows engineers to quickly test different configurations and optimize for performance. - -**Architectural Design** -Decorative screens, facade elements, and privacy panels often use regular perforation patterns. These grids can create interesting light and shadow effects while maintaining structural integrity. - -**Industrial Filtration** -Filter elements, strainers, and separation screens require carefully designed hole patterns. The ability to easily adjust hole size and spacing makes it simple to meet specific filtration requirements. - -**Acoustic Engineering** -Perforated panels for sound absorption and control use precise hole patterns to achieve desired acoustic properties. Different grid configurations can target specific frequency ranges. - -**Electronics and Technology** -Speaker grilles, ventilation panels for electronics enclosures, and heat dissipation elements all benefit from optimized perforation patterns that balance functionality with aesthetics. - -## Advanced Considerations - -When working with hollow grids, consider these important factors: - -**Material Efficiency**: The ratio of open area to solid material affects both performance and structural strength. Grid parameters should balance functional requirements with material usage. - -**Manufacturing Constraints**: Different production methods (laser cutting, punching, machining) have specific limitations on minimum hole sizes, spacing, and edge distances that should inform your design parameters. - -**Structural Analysis**: Regular perforation patterns create stress concentrations that may require analysis for load-bearing applications. The parametric approach makes it easy to test different configurations. - -**Performance Optimization**: For functional applications like ventilation or filtration, the grid pattern directly affects performance metrics like pressure drop, flow rate, and efficiency. - -The parametric hollow grid technique demonstrated here provides a foundation for creating sophisticated perforated designs that can be easily adapted to meet specific requirements while maintaining design consistency and manufacturability. +When implementing these patterns in real projects, consider the balance between open area and structural strength, manufacturing constraints of your chosen production method, and how the perforation pattern affects the functional performance of your design. The parametric foundation provided here scales effectively from simple prototypes to complex industrial applications. diff --git a/packages/dev/occt/lib/api/inputs/occ-inputs.ts b/packages/dev/occt/lib/api/inputs/occ-inputs.ts index e2090e2d..4222b0a3 100644 --- a/packages/dev/occt/lib/api/inputs/occ-inputs.ts +++ b/packages/dev/occt/lib/api/inputs/occ-inputs.ts @@ -5789,7 +5789,7 @@ export namespace OCCT { inside = true; } export class SewDto { - constructor(shapes: T[], tolerance?: number) { + constructor(shapes?: T[], tolerance?: number) { if (shapes !== undefined) { this.shapes = shapes; } if (tolerance !== undefined) { this.tolerance = tolerance; } } From df648b2cad675724a5a8f886cb580df5d1fe34fd Mon Sep 17 00:00:00 2001 From: Matas Ubarevicius Date: Sat, 4 Oct 2025 20:29:53 +0300 Subject: [PATCH 4/5] linear dimensions documented --- .../common/occt/dimensions/_category_.json | 10 ++ .../occt/dimensions/linear-dimension.md | 110 ++++++++++++++++++ 2 files changed, 120 insertions(+) create mode 100644 docs/learn/code/common/occt/dimensions/_category_.json create mode 100644 docs/learn/code/common/occt/dimensions/linear-dimension.md diff --git a/docs/learn/code/common/occt/dimensions/_category_.json b/docs/learn/code/common/occt/dimensions/_category_.json new file mode 100644 index 00000000..602cbd0d --- /dev/null +++ b/docs/learn/code/common/occt/dimensions/_category_.json @@ -0,0 +1,10 @@ +{ + "label": "Dimensions", + "position": 7, + "link": { + "type": "generated-index", + "title": "Dimensions", + "description": "Learn how to create and manage dimensions in 3D models using the OCCT library.", + "slug": "/code/common/occt/dimensions" + } +} \ No newline at end of file diff --git a/docs/learn/code/common/occt/dimensions/linear-dimension.md b/docs/learn/code/common/occt/dimensions/linear-dimension.md new file mode 100644 index 00000000..d304283a --- /dev/null +++ b/docs/learn/code/common/occt/dimensions/linear-dimension.md @@ -0,0 +1,110 @@ +--- +sidebar_position: 1 +title: Linear Dimension +sidebar_label: Linear Dimension +description: Learn how to create and display linear dimensions for measuring distances in your 3D models with clear, professional annotations. +tags: [code, occt, rete, blockly, typescript] +--- + +import Tabs from '@theme/Tabs'; +import TabItem from '@theme/TabItem'; +import BitByBitRenderCanvas from '@site/src/components/BitByBitRenderCanvas'; + +OCCT category icon with a stylized logo representation + +Linear dimensions measure and display the distance between two points in your 3D models. They're essential for technical drawings, manufacturing documentation, and design verification. Bitbybit's linear dimension tools help you create professional dimensional annotations that automatically update when your geometry changes. + +## Understanding Linear Dimensions + +Linear dimensions measure straight-line distances between two points and display them with dimension lines, extension lines, and text labels. The system automatically calculates distances and formats the display. Key components include start and end points that define what's being measured, a direction vector that controls dimension line orientation, offset distance that sets how far the dimension appears from geometry, and label customization for text formatting, units, and positioning. + + + + + + + point1point2point1-500point2500point1point2point1point20100.30.21cm0.40.80","version":"0.20.7","type":"blockly"}} + title="Simple linear dimension between two points" + /> + + + {\n // Define two points to measure between\n const startPoint: Point3 = [-5, 0, 0];\n const endPoint: Point3 = [5, 0, 0];\n\n // Draw the points for reference\n bitbybit.draw.drawAnyAsync({ entity: startPoint });\n bitbybit.draw.drawAnyAsync({ entity: endPoint });\n\n // Create a linear dimension between the points\n const dimensionOptions = new SimpleLinearLengthDimensionDto();\n dimensionOptions.start = startPoint;\n dimensionOptions.end = endPoint;\n dimensionOptions.direction = [0, 1, 0]; // Offset in Y direction\n dimensionOptions.offsetFromPoints = 0.3;\n dimensionOptions.crossingSize = 0.2;\n dimensionOptions.decimalPlaces = 1;\n dimensionOptions.labelSuffix = \"cm\";\n dimensionOptions.labelSize = 0.4;\n dimensionOptions.labelOffset = 0.8;\n dimensionOptions.labelRotation = 0;\n\n // Create and draw the dimension\n const dimension = await bitbybit.occt.dimensions.simpleLinearLengthDimension(dimensionOptions);\n bitbybit.draw.drawAnyAsync({ entity: dimension });\n}\n\n// Execute the function\nstart();","version":"0.20.7","type":"typescript"}} + title="Simple linear dimension between two points" + /> + + +Linear dimensions update automatically when geometry changes, keeping your documentation accurate throughout the design process. + + + + + + + widthlengthheightboxfirstEdgesecondEdgethirdEdgewidth13.2length9.1height5.3boxwidthlengthheight000TRUEfirstEdgebox1secondEdgebox8thirdEdgebox11firstEdgefirstEdge-2000.20.22(cm)0.51180secondEdgesecondEdge2000.20.22(cm)0.51180thirdEdgethirdEdge00-20.20.22(cm)0.51180box","version":"0.20.7","type":"blockly"}} + title="Linear dimensions applied on box" + /> + + + {\n // Create a box with specific dimensions\n const boxOptions = new BoxDto();\n boxOptions.width = 13.2;\n boxOptions.length = 9.1;\n boxOptions.height = 5.3;\n boxOptions.center = [0, 0, 0];\n boxOptions.originOnCenter = true;\n const box = await solid.createBox(boxOptions);\n\n // Draw the box first\n bitbybit.draw.drawAnyAsync({ entity: box });\n\n // Get all edges from the box for dimension measurements\n const edges = await edge.getEdges({ shape: box });\n\n // Create width dimension (measuring edge 0)\n const widthEdge = edges[0];\n const widthStartPoint = await edge.startPointOnEdge({ shape: widthEdge });\n const widthEndPoint = await edge.endPointOnEdge({ shape: widthEdge });\n\n const widthDimensionOptions = new SimpleLinearLengthDimensionDto();\n widthDimensionOptions.start = widthStartPoint;\n widthDimensionOptions.end = widthEndPoint;\n widthDimensionOptions.direction = [-2, 0, 0]; // Offset to the left\n widthDimensionOptions.offsetFromPoints = 0.2;\n widthDimensionOptions.crossingSize = 0.2;\n widthDimensionOptions.decimalPlaces = 2;\n widthDimensionOptions.labelSuffix = \"(cm)\";\n widthDimensionOptions.labelSize = 0.5;\n widthDimensionOptions.labelOffset = 1;\n widthDimensionOptions.labelRotation = 180;\n \n const widthDimension = await dimensions.simpleLinearLengthDimension(widthDimensionOptions);\n bitbybit.draw.drawAnyAsync({ entity: widthDimension });\n\n // Create height dimension (measuring edge 10)\n const heightEdge = edges[10];\n const heightStartPoint = await edge.startPointOnEdge({ shape: heightEdge });\n const heightEndPoint = await edge.endPointOnEdge({ shape: heightEdge });\n\n const heightDimensionOptions = new SimpleLinearLengthDimensionDto();\n heightDimensionOptions.start = heightStartPoint;\n heightDimensionOptions.end = heightEndPoint;\n heightDimensionOptions.direction = [0, 0, -2]; // Offset toward the back\n heightDimensionOptions.offsetFromPoints = 0.2;\n heightDimensionOptions.crossingSize = 0.2;\n heightDimensionOptions.decimalPlaces = 2;\n heightDimensionOptions.labelSuffix = \"(cm)\";\n heightDimensionOptions.labelSize = 0.5;\n heightDimensionOptions.labelOffset = 1;\n heightDimensionOptions.labelRotation = 180;\n \n const heightDimension = await dimensions.simpleLinearLengthDimension(heightDimensionOptions);\n bitbybit.draw.drawAnyAsync({ entity: heightDimension });\n\n // Create depth dimension (measuring edge 7)\n const depthEdge = edges[7];\n const depthStartPoint = await edge.endPointOnEdge({ shape: depthEdge });\n const depthEndPoint = await edge.startPointOnEdge({ shape: depthEdge });\n\n const depthDimensionOptions = new SimpleLinearLengthDimensionDto();\n depthDimensionOptions.start = depthStartPoint;\n depthDimensionOptions.end = depthEndPoint;\n depthDimensionOptions.direction = [2, 0, 0]; // Offset to the right\n depthDimensionOptions.offsetFromPoints = 0.2;\n depthDimensionOptions.crossingSize = 0.2;\n depthDimensionOptions.decimalPlaces = 2;\n depthDimensionOptions.labelSuffix = \"(cm)\";\n depthDimensionOptions.labelSize = 0.5;\n depthDimensionOptions.labelOffset = 1;\n depthDimensionOptions.labelRotation = 180;\n \n const depthDimension = await dimensions.simpleLinearLengthDimension(depthDimensionOptions);\n bitbybit.draw.drawAnyAsync({ entity: depthDimension });\n}\n\n// Execute the function\nstart();","version":"0.20.7","type":"typescript"}} + title="Linear dimensions applied on box" + /> + + + +## Dimension Properties and Customization + +Linear dimensions offer extensive customization options to match your documentation standards. + +### Essential Parameters + +**Start and End Points** define the geometry being measured. You can use points directly or extract them from edges and vertices. + +**Direction Vector** controls where the dimension line appears relative to the measured geometry. Positive vectors move the dimension in that direction, negative values move it opposite. + +**Offset Distance** controls how far the dimension line appears from the measured points. This helps stack multiple dimensions without overlap. + +**Crossing Size** determines the length of extension lines connecting measured points to the dimension line. + +### Label Formatting + +**Decimal Places** controls measurement precision. Engineering drawings typically use 1-3 decimal places. + +**Label Suffix** adds units or context like "(mm)", "(cm)", "(in)", or "(TYP)" for typical dimensions. + +**Label Size** controls text size, scaled for your model and viewing distance. + +**Label Offset** positions text relative to the dimension line. Positive values move text away from geometry. + +**Label Rotation** rotates dimension text for better readability on angled or vertical dimensions. + +## Best Practices + +Linear dimensions serve critical functions in design and manufacturing workflows. They provide precise measurements for manufacturing and quality control, help verify designs meet specifications, guide manufacturing processes, and communicate assembly requirements. + +### Placement Guidelines + +Place dimensions to avoid interfering with geometry or other annotations. Group related dimensions together and organize them hierarchically with primary dimensions most prominent. Maintain consistent formatting throughout your documentation. Choose direction vectors that place dimensions where viewers naturally expect to find them. + +## Why Linear Dimensions Matter + +Linear dimensions bridge the gap between design intent and manufacturing reality. They provide a common language in collaborative environments, eliminate manual measurements, and reduce errors in downstream processes. Parametric dimensions that update automatically save time and prevent outdated documentation. Mastering these tools improves design documentation quality and clarity, leading to reduced errors, faster manufacturing, and clearer communication. From 7ccfb6f7ac6d5870297c204bffdf64d3c62dd7fd Mon Sep 17 00:00:00 2001 From: Matas Ubarevicius Date: Sat, 4 Oct 2025 22:10:31 +0300 Subject: [PATCH 5/5] angular dimension tutorials --- .../occt/dimensions/angular-dimension.md | 146 ++++++++++++++++++ 1 file changed, 146 insertions(+) create mode 100644 docs/learn/code/common/occt/dimensions/angular-dimension.md diff --git a/docs/learn/code/common/occt/dimensions/angular-dimension.md b/docs/learn/code/common/occt/dimensions/angular-dimension.md new file mode 100644 index 00000000..9d97133b --- /dev/null +++ b/docs/learn/code/common/occt/dimensions/angular-dimension.md @@ -0,0 +1,146 @@ +--- +sidebar_position: 2 +title: Angular Dimension +sidebar_label: Angular Dimension +description: Learn how to create and display angular dimensions for measuring angles in your 3D models with clear, professional annotations. +tags: [code, occt, rete, blockly, typescript] +--- + +import Tabs from '@theme/Tabs'; +import TabItem from '@theme/TabItem'; +import BitByBitRenderCanvas from '@site/src/components/BitByBitRenderCanvas'; + +OCCT category icon with a stylized logo representation + +Angular dimensions measure and display angles between two directions in your 3D models. They're essential for technical drawings, engineering documentation, and design verification where angular relationships matter. Bitbybit's angular dimension tools help you create professional angular annotations that automatically update when your geometry changes. + +## Understanding Angular Dimensions + +Angular dimensions measure the angle between two direction vectors and display them with arc lines, extension lines, and text labels. The system automatically calculates angles and formats the display. Key components include: + +- **Direction Vectors**: Two direction vectors that define the angle being measured +- **Center Point**: The origin point from which the angle is measured +- **Arc Radius**: Controls the size of the dimensional arc +- **Arc Offset**: Positions the dimension arc relative to the center point +- **Label Customization**: For text formatting, units (degrees/radians), and positioning + + + + + + + direction1direction2centerdirection1100direction2011center000direction1direction2center20.30.11deg0.30.4FALSE","version":"0.20.7","type":"blockly"}} + title="Simple angular dimension between two directions" + /> + + + {\n // Define two direction vectors to measure angle between\n const direction1: Vector3 = [1, 0, 0]; // X-axis direction\n const direction2: Vector3 = [0, 1, 1]; // Direction at 45deg from Y and Z\n const center: Point3 = [0, 0, 0]; // Origin point\n\n // Create an angular dimension between the directions\n const dimensionOptions = new SimpleAngularDimensionDto();\n dimensionOptions.direction1 = direction1;\n dimensionOptions.direction2 = direction2;\n dimensionOptions.center = center;\n dimensionOptions.radius = 2;\n dimensionOptions.offsetFromCenter = 0.3;\n dimensionOptions.extraSize = 0.1;\n dimensionOptions.decimalPlaces = 1;\n dimensionOptions.labelSuffix = \"deg\";\n dimensionOptions.labelSize = 0.3;\n dimensionOptions.labelOffset = 0.4;\n dimensionOptions.radians = false;\n\n // Create and draw the dimension\n const dimension = await bitbybit.occt.dimensions.simpleAngularDimension(dimensionOptions);\n bitbybit.draw.drawAnyAsync({ entity: dimension });\n}\n\n// Execute the function\nstart();","version":"0.20.7","type":"typescript"}} + title="Simple angular dimension between two directions" + /> + + + +Angular dimensions update automatically when direction vectors change, keeping your documentation accurate throughout the design process. + +## Advanced Application: Cone Apex Angle + +Angular dimensions are particularly useful for complex 3D geometry like cones, where measuring the apex angle is crucial for manufacturing and design verification. Here's an advanced example that creates a cone and measures its apex angle using angular dimensions. + + + + + + + conerotatedConeconeEdgetranslatedEdgestartPointendPointdirection1cone52.75360000010rotatedConecone010-90coneEdgerotatedCone2translatedEdgeconeEdge-100startPointtranslatedEdgeendPointtranslatedEdgedirection1endPointstartPointrotatedConedirection1-100startPoint7202(deg)0.40.6FALSE","version":"0.20.7","type":"blockly"}} + title="Cone with apex angle measurement" + /> + + + {\n // Create a cone with specific dimensions\n const coneOptions = new ConeDto();\n coneOptions.radius1 = 5;\n coneOptions.radius2 = 2.7; // Variable radius for apex angle\n coneOptions.height = 5;\n coneOptions.angle = 360;\n coneOptions.center = [0, 0, 0];\n coneOptions.direction = [0, 1, 0];\n const cone = await solid.createCone(coneOptions);\n\n // Rotate the cone -90 degrees around Y axis for better visualization\n const rotatedCone = await transforms.rotate({\n shape: cone,\n axis: [0, 1, 0],\n angle: -90\n });\n\n // Draw the rotated cone\n bitbybit.draw.drawAnyAsync({ entity: rotatedCone });\n\n // Get edge 2 from the cone (this is a generatrix line)\n const coneEdge = await edge.getEdge({ shape: rotatedCone, index: 2 });\n\n // Translate the edge to position it for measurement\n const translatedEdge = await transforms.translate({\n shape: coneEdge,\n translation: [-1, 0, 0]\n });\n\n // Get start and end points from the translated edge\n const startPoint = await edge.startPointOnEdge({ shape: translatedEdge });\n const endPoint = await edge.endPointOnEdge({ shape: translatedEdge });\n\n // Calculate direction vector from start to end point\n const direction1 = bitbybit.vector.sub({ first: endPoint, second: startPoint }) as Vector3;\n\n // Create angular dimension to measure apex angle\n const dimensionOptions = new SimpleAngularDimensionDto();\n dimensionOptions.direction1 = direction1;\n dimensionOptions.direction2 = [-1, 0, 0]; // Reference direction\n dimensionOptions.center = startPoint; // Apex point\n dimensionOptions.radius = 7;\n dimensionOptions.offsetFromCenter = 2;\n dimensionOptions.extraSize = 0;\n dimensionOptions.decimalPlaces = 2;\n dimensionOptions.labelSuffix = \"(deg)\";\n dimensionOptions.labelSize = 0.4;\n dimensionOptions.labelOffset = 0.6;\n dimensionOptions.radians = false;\n\n // Create and draw the angular dimension\n const dimension = await dimensions.simpleAngularDimension(dimensionOptions);\n bitbybit.draw.drawAnyAsync({ entity: dimension });\n}\n\n// Execute the function\nstart();","version":"0.20.7","type":"typescript"}} + title="Cone with apex angle measurement" + /> + + + +This example demonstrates how angular dimensions can be applied to complex 3D geometry. The cone's apex angle is measured between two direction vectors from the apex to opposite points on the base circumference. As you adjust the cone's radius or height, the apex angle automatically updates, making this perfect for manufacturing documentation and design verification. + +## Dimension Properties and Customization + +Angular dimensions offer extensive customization options to match your documentation standards and specific use cases. + +### Essential Parameters + +**Direction Vectors** define the two directions between which the angle is measured. These can be: +- Fixed direction vectors like `[1, 0, 0]` and `[0, 1, 0]` +- Calculated vectors from geometry using `vectorXYZ` +- Dynamic vectors that change based on parameters + +**Center Point** is the origin from which the angle is measured. This should typically be: +- The vertex where the two directions meet +- A significant geometric point in your design +- Positioned for optimal dimension visibility + +**Radius** controls the size of the dimensional arc. Larger radii provide: +- Better visibility in complex drawings +- More space for dimension text +- Clearer separation from geometry + +**Offset from Center** moves the dimension arc away from the center point: +- Positive values move the arc outward +- Negative values move it inward +- Use this to avoid overlapping with geometry + +### Label Formatting + +**Decimal Places** controls measurement precision: +- Use 0-1 decimals for rough angles +- Use 2-3 decimals for precision machining +- Consider the manufacturing tolerance requirements + +**Label Suffix** adds context to measurements: +- `"deg"` for simple degree notation +- `"deg apex"` for specific angle types +- `"(deg)"` for formal documentation +- `"rad"` when using radians + +**Radians vs Degrees** can be controlled with the `radians` property: +- `false` (default) displays angles in degrees (0-360 deg) +- `true` displays angles in radians (0-2π) + +**Label Size and Offset** control text appearance: +- Scale label size for viewing distance and drawing scale +- Use label offset to position text optimally +- Consider text readability at different zoom levels + +**Extra Size** controls the length of extension lines: +- Helps connect the dimension to referenced geometry +- Useful when the center point is far from the measured elements +- Improves dimension clarity in complex drawings + +## Best Practices + +Angular dimensions serve critical functions in engineering and manufacturing workflows, communicating design intent for machined angles, verifying angular tolerances, and ensuring proper fit between angled components. Position dimensions near the vertex where angles originate, use appropriate radius values to avoid crowding, and maintain consistent formatting throughout your documentation. + +These dimensions excel in machining operations for documenting drill and chamfer angles, structural design for measuring beam and joint angles, and quality control for checking manufactured parts against specifications. When integrated with parametric design workflows, they become especially powerful by automatically updating as design parameters change, validating constraints, and creating interactive documentation. + +Angular dimensions bridge the critical gap between design intent and manufacturing reality. They provide a common language for communicating angular relationships in collaborative environments, eliminate manual calculations, and reduce downstream errors. Whether you're working with simple geometric relationships or complex 3D assemblies like the cone apex angle example, mastering angular dimensions improves documentation quality and clarity, leading to reduced errors, faster manufacturing, and clearer communication across your entire design and production workflow.