Cutting Plane

Below we will consider how to add a cutting plane to a scene.

Note

For now, it’s allowed to add only four cutting planes.

You can add a plane via the following command.

Example command to add a cutting plane (TypeScript):

view.runCommand({
    name: "GetParametersCommand",
    planes: [{
        placement: {
            a: 0,
            b: 1,
            c: 0
        },
        options: {
            direction: 'back'
        }
    }]
})

The parameter planes defines an array of new cutting planes.

Important

All existing cutting planes will be removed after running SetCuttingPlanesCommand and replaced by the new value passed in the parameter planes.

Each plane is an instance of the following type:

type C3DCuttingPlane = {
    placement: {
        a: number,
        b: number,
        c: number
    },
    options?: {
        id?: number
        direction?: "front"|"back"
    }
}

The parameter placement defines a cutting plane in 3D which contains:

  • a: an angle (in radians)

  • b: an angle (in radians)

  • c: an offset along the X-axis.

Also there is an optional parameter options which can contain:

  • id: a custom user id used to identify a cutting plane in an external user system.

  • direction: a visible area direction after cutting (the default value is "front")

Adding Plane Interactively

In addition to section plane process, this allows to create a cutting plane by three points on a model interactively.

After starting the process, a cutting plane is passed to the callback onInitPlacement where it’s added to a scene.

Example of adding a cutting plane via the plane process (TypeScript):

view.runCommand({
    name: "RunProcessCommand",
    process: {
        name: "SetPlaneProcess",
        events: {
            onInitPlacement: (a: number, b: number, c: number) => {
                const plane = {
                    id: 1,
                    placement: {a, b, c},
                    name: 'Cutting plane 1'
                }

                view.runCommand({
                    name: "SetCuttingPlanesCommand",
                    planes: [plane]
                })
            }
        }
    }
})