Skip to main content

Parametric measure

Novorender measure API can be used to fetch parametric data based on real world position, and calculate measurements between 2 objects

Measure entity​

A measure entity refers to a part of a parametric object, for example the inner or outer cylinder of a pipe. A measure entity can also be a single point, this is usually used if no parametric object exists at a clicked location.

The normal way of getting measure entities is to used the pickMeasureEntity() function on the measure scene object. This will use world coordinates and objectId to find the closest edge surface or point. It will return the picked point if no parametric data is found near the input point. objectId and position can be used from the novorender webgl-api pick function on render renderOutput

const output = await view.render();
const result = output.pick(x, y);
if (result) {
const entity = await measureScene.pickMeasureEntity(result.objectId, result.position);
}

Parametric values on entity​

To get the parametric values such as the the radius, and centerline of a cylinder the measure() function can be used. This function be be used to get values from a single object by leaving the second argument as undefined.

const measureValues = measurescene.measure(entity);
if (measureValues.kind === "cylinder") {
console.log(`Radius of cylinder is: ${measureValues.radius}`);
}

Measure against another entity​

A measure between two entities is done by using the measure() function on scene with 2 arguments. What property the resulting object has will depend on the input arguments. There is also an option parameter to support additional options such as where a cylinder should measure from

const output = await view.render();
const result1 = output.pick(x1, y1);

const result2 = output.pick(x2, y2);
if (result1 && result2) {
const entity1 = await measureScene.pickMeasureEntity(result1.objectId, result1.position);

const entity2 = await measureScene.pickMeasureEntity(result2.objectId, result2.position);

const measureValues = (await measurescene.measure(entity1, entity2)) as DuoMeasurementValues | undefined;
if (measureValues && measureValues.distance) {
console.log(`Distance between objects is: ${measureValues.distance}`);
}
}

Demo​

Click to select parametric object, parametric data will be shown in an alert dialog. Select another object and the measurement data between the objects will be shown in the alert dialog. Clicking further objects will alternate between first and second selected and show measure values within an alert dialog.

Loading...

note

Currently, there are a maximum of 256 highlight groups, the last one (#255) being reserved for objects that should not be rendered.