Language: JavaScript
As part of the default Web Viewer UI panel, it’s possible to easily invert the direction of a cutting plane. This short article provides the JavaScript to do it outside the UI for those HC developers implementing their own custom UI.
More information on cutting planes can be found in the docs.
//Create cutting plane
const bounding = await hwv.model.getModelBounding(true, true);
const axis = Communicator.Axis.X;
const position = bounding.min;
const referenceGeometry = hwv.cuttingManager.createReferenceGeometryFromAxis(axis, bounding);
const plane = Communicator.Plane.createFromPointAndNormal(position, new Communicator.Point3(1, 0, 0));
const cuttingSection = hwv.cuttingManager.getCuttingSection(0);
cuttingSection.addPlane(plane, referenceGeometry);
await cuttingSection.activate();
//Invert normal and d values of plane
var myPlane = cuttingSection.getPlane(0);
myPlane.normal.negate();
myPlane.d *= -1;
//Update plane
cuttingSection.updatePlane(0, myPlane);