{"script":"// Import required DTOs for hexagon grid creation and operations\nconst { HexagonsInGridDto, FaceFromWiresDto, ExtrudeDto, CompoundShapesDto, ShapeDto } = Bit.Inputs.OCCT;\n// Import type definitions for type safety\ntype TopoDSWirePointer = Bit.Inputs.OCCT.TopoDSWirePointer;\ntype TopoDSFacePointer = Bit.Inputs.OCCT.TopoDSFacePointer;\ntype TopoDSSolidPointer = Bit.Inputs.OCCT.TopoDSSolidPointer;\n\n// Get access to OCCT modules and utilities\nconst { wire, face, compound } = bitbybit.occt.shapes;\nconst { operations } = bitbybit.occt;\nconst { math } = bitbybit;\n\n// Create a three-dimensional hexagon hive\n// Create hexagonal grid parameters\nconst gridWidth = 10;\nconst gridHeight = 20;\nconst hexagonsInWidth = 10;\nconst hexagonsInHeight = 20;\n\n// Generate large hexagonal wire grid (outer walls)\nconst hexGridLargeOptions = new HexagonsInGridDto();\nhexGridLargeOptions.width = gridWidth;\nhexGridLargeOptions.height = gridHeight;\nhexGridLargeOptions.nrHexagonsInWidth = hexagonsInWidth;\nhexGridLargeOptions.nrHexagonsInHeight = hexagonsInHeight;\n\nconst wiresHexLarge = await wire.hexagonsInGrid(hexGridLargeOptions);\n\n// Generate small hexagonal wire grid (inner holes)\nconst hexGridSmallOptions = new HexagonsInGridDto();\nhexGridSmallOptions.width = gridWidth;\nhexGridSmallOptions.height = gridHeight;\nhexGridSmallOptions.nrHexagonsInWidth = hexagonsInWidth;\nhexGridSmallOptions.nrHexagonsInHeight = hexagonsInHeight;\nhexGridSmallOptions.scalePatternWidth = [0.8];\nhexGridSmallOptions.scalePatternHeight = [0.8];\n\nconst wiresHexSmall = await wire.hexagonsInGrid(hexGridSmallOptions);\n\n// Generate random heights for each hexagon cell\nconst 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\nconst hexagons3D: TopoDSSolidPointer[] = [];\n\nfor (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<TopoDSWirePointer>();\n    reverseOptions.shape = innerWire;\n    const reversedInnerWire = await wire.reversedWire(reverseOptions);\n\n    // Create face with hole\n    const faceOptions = new FaceFromWiresDto<TopoDSWirePointer>();\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<TopoDSFacePointer>();\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\nconst compoundOptions = new CompoundShapesDto<TopoDSSolidPointer>();\ncompoundOptions.shapes = hexagons3D;\nconst compoundShapeForFastRendering = await compound.makeCompound(compoundOptions);\n\n// Draw the resulting three-dimensional hive structure\nbitbybit.draw.drawAnyAsync({\n    entity: compoundShapeForFastRendering\n});","version":"1.6.0","type":"typescript"}