Script TS TypeScript Free

Slicing With Steps Pattern

Slicing With Steps Pattern picture
Author
matas
Created
Nov 16, 2023, 12:23:15 PM
Last edit
Oct 2, 2025, 4:56:51 PM

Edit scriptPreview

Project

Slicing Solids Example

Slicing various solids is very useful feature that you can now use in our platform. This can be beneficial to robotic 3D printing and other tasks.

View full project
const start = async () => {
    const sphere1 = await createGeometry(0.5, 3.7, 2, 0.6);

    const steps = [];
    for (let i = 0.001; i < 10; i += 0.001) {
        steps.push(i)
    }

    const slices = await bitbybit.occt.operations.sliceInStepPattern({
        shape: sphere1,
        direction: [0, 0, 1],
        steps
    });

    const drawOptions = new Bit.Inputs.Draw.DrawOcctShapeOptions();
    drawOptions.edgeColour = "#ffffff";
    drawOptions.edgeWidth = 0.5;
    drawOptions.precision = 0.005;
    drawOptions.drawFaces = false;

    await bitbybit.draw.drawAnyAsync({
        entity: slices,
        options: drawOptions
    });
}

start();

async function createGeometry(starInnerRadius: number, starOuterRadius: number, sphereRadius: number, thickness: number) {
    const star1 = await bitbybit.occt.shapes.wire.createStarWire({
        direction: [1, 0, 0],
        center: [5, 0, 0],
        innerRadius: starInnerRadius,
        outerRadius: starOuterRadius,
        numRays: 8,
        half: false
    });

    const sphere1 = await bitbybit.occt.shapes.solid.createSphere({
        radius: sphereRadius,
        center: [0, 0, 0]
    });

    const fillet1 = await bitbybit.occt.fillets.fillet2d({
        shape: star1,
        radius: 0.1
    });

    const projection1 = await bitbybit.occt.shapes.wire.project({
        wire: fillet1,
        shape: sphere1,
        direction: [1, 0, 0]
    });

    const projectionWires = await bitbybit.occt.shapes.wire.getWires({ shape: projection1 });

    const split1 = await bitbybit.occt.operations.splitShapeWithShapes({
        shape: sphere1,
        shapes: projectionWires,
        nonDestructive: true,
        localFuzzyTolerance: 0.00001,
    });

    const faces = await bitbybit.occt.shapes.face.getFaces({ shape: split1[8] });
    const face = faces.shift();

    const thicken = await bitbybit.occt.operations.makeThickSolidSimple({
        shape: face,
        offset: -thickness,
    })

    return thicken;
}

Plans and pricing

Choose your plan

Editor plans for 3D development, API keys for server-side CAD algorithms

EnterpriseB2BCustompricing

Custom software development, dedicated servers and CAD automation at scale.

Learn moreContact us

CAD automation and software
  • Custom software development
  • Cloud CAD automation pipelines
  • 3D configurators (STEP & GLTF)
  • Batch export jobs
  • Custom algorithms & deployment
Infrastructure and support
  • Custom compute allocation
  • Dedicated / VPS server tenants
  • Long-running computation jobs
  • Custom upload limits & overage
  • SLA & premium support

All prices exclude applicable taxesView all plan details

Contact

Talk to us

Tell us what you are building or what is blocking you, through whichever channel suits you.