Script: Fillet 3D Wire TypeScript

Fillet 3D Wire TypeScript picture
Type
Typescript logo indicatortypescript
Date Created
Mar 1, 2024, 9:18:39 AM
Last Edit Date
May 27, 2025, 8:29:45 PM

Project Information

In the latest v0.15.0 release we fixed and improved this algorithm. In this project we deomstrate how it works.

View Full Project

Script Code

const nrRays = 7;
const outerStarRadius = 10;
const innerStarRadius = 4;
const outerFillet = 0.6;
const innerFillet = 1.7;

const start = async () => {

    const repeatOpt = new Bit.Inputs.Lists.MultiplyItemDto<number[]>([innerFillet, outerFillet], nrRays);
    const radiusList = bitbybit.lists.repeat(repeatOpt).flat();
    const spanOptions = new Bit.Inputs.Vector.SpanDto(1, 1, nrRays * 2);
    const indexes = bitbybit.vector.span(spanOptions);

    const starOptions = new Bit.Inputs.OCCT.StarDto(outerStarRadius, innerStarRadius, nrRays, [0, 0, 0], [0, 1, 0], 4, false);
    const star = await bitbybit.occt.shapes.wire.createStarWire(starOptions);

    const filletOptions = new Bit.Inputs.OCCT.Fillet3DWireDto<Bit.Inputs.OCCT.TopoDSShapePointer>(star, undefined, [0, 1, 0], radiusList, indexes);
    const starFillet = await bitbybit.occt.fillets.fillet3DWire(filletOptions);

    const startFilletTranslated1 = await bitbybit.occt.transforms.translate({ shape: starFillet, translation: [0, 5, 0] })
    const startFilletTranslated2 = await bitbybit.occt.transforms.translate({ shape: starFillet, translation: [0, 10, 0] })


    const starFace = await bitbybit.occt.shapes.face.createFaceFromWire({ shape: startFilletTranslated2, planar: false });
    const starThick = await bitbybit.occt.operations.makeThickSolidSimple({ shape: starFace, offset: -1 });
    const starThickFillet = await bitbybit.occt.fillets.filletEdges({ shape: starThick, radius: 0.3 });

    const drawOptions = new Bit.Inputs.Draw.DrawOcctShapeOptions();
    drawOptions.edgeWidth = 15;
    bitbybit.draw.drawAnyAsync({ entity: star, options: drawOptions });
    bitbybit.draw.drawAnyAsync({ entity: startFilletTranslated1, options: drawOptions });
    drawOptions.faceColour = "#5555ff";
    drawOptions.edgeColour = "#000000";
    drawOptions.edgeWidth = 2;
    drawOptions.precision = 0.005;
    bitbybit.draw.drawAnyAsync({ entity: starThickFillet, options: drawOptions });

    const gridOptions = new Bit.Inputs.Draw.SceneDrawGridMeshDto();
    bitbybit.draw.drawGridMesh(gridOptions);
    const skyboxOptions = new Bit.Inputs.BabylonScene.SkyboxDto();
    skyboxOptions.skybox = Bit.Inputs.Base.skyboxEnum.clearSky;
    bitbybit.babylon.scene.enableSkybox(skyboxOptions);
}

start();