SView Help Center
English (US)

Measurement

Author: sviewngts Last Updated: 2026-10-28 19:45

Interface List

Interface Name Description
Create Distance Measurement Create a distance measurement
Create Angle Measurement Create an angle measurement
Create Circle-Related Measurement Create a circle-related measurement
Update Measurement Position Update the position where the measurement result is displayed
Delete Measurement Delete a measurement
Align Camera Align the camera
Serialize Serialize a measurement into JSON format
Deserialize Deserialize JSON format data into a measurement object

Creating a Distance Measurement

let action = null;
//Point-to-point distance measurement Action, type is M3D.Shapes.MeasureType.PNT_PNT_DISTANCE
action = new SView.Actions.CreatePointPointDistanceAction();
//Point-to-line distance measurement Action, type is M3D.Shapes.MeasureType.PNT_LINE_DISTANCE
action = new SView.Actions.CreatePointLineDistanceAction();
//Point-to-face distance measurement Action, type is M3D.Shapes.MeasureType.PNT_FACE_DISTANCE
action = new SView.Actions.CreatePointFaceDistanceAction();
//Line-to-line distance measurement Action, type is M3D.Shapes.MeasureType.LINE_LINE_DISTANCE
action = new SView.Actions.CreateLineLineDistanceAction();
//Line-to-face distance measurement Action, type is M3D.Shapes.MeasureType.LINE_FACE_DISTANCE
action = new SView.Actions.CreateLineFaceDistanceAction();
//Face-to-face distance measurement Action, type is M3D.Shapes.MeasureType.FACE_FACE_DISTANCE
action = new SView.Actions.CreateFaceFaceDistanceAction();
//Thickness distance measurement Action, type is M3D.Shapes.MeasureType.THICKNESS_DISTANCE
action = new SView.Actions.CreateThicknessDistanceAction();
action.setScene(scene);
//Set the action parameters
//Parameter description:
//objID: The ID of the created measurement; pass null when creating a new measurement
//type: Measurement type; the value is the corresponding type used when creating the measurement Action.
//firstShape: The first measured object, e.g.: Point, Edge, SectionEdge, Face
//firstPosition: The corresponding position where the first object was picked
//secondShape: The second object for measurement, such as Point, Edge, SectionEdge, or Face; for thickness measurement, null may be passed.
//secondPosition: The corresponding position of the picked second object; for thickness measurement, null may be passed.
//titleTextColor: Measurement title text color
//resultTextColor: Measurement result text color
//fontName: Font name
//fontSize: Font size
//titleFormat: Title format; currently unused, just pass null
//titleBackgroundColor: Measurement result title background color
//resultBackgroundColor: Measurement result background color
//maxDistanceColor: Maximum value result title background color
//minDistanceColor: Minimum value result title background color
//measurementUnit: Measurement unit: 0 = none, 1 = millimeter, 2 = centimeter, 3 = meter, 4 = inch, 5 = foot.
//isShowMaxDistance: Whether to show the maximum value
//isShowMinDistance: Whether to show the minimum value
//model1: The assembly path of the model associated with the first point in point-to-point measurement; pass null if there is none.
//model2: The assembly path of the model associated with the second point in point-to-point measurement; pass null if there is none.
//normalDirection: The direction used to calculate thickness in thickness measurement.
//thirdPosition: The position where the measurement result is displayed; pass null to use the default position.
action.setParameter(objID: number, type: number, firstShape: M3D.Shapes.Shape, firstPosition: M3D.M3DMath.Vector3,
   secondShape: M3D.Shapes.Shape, secondPosition: M3D.M3DMath.Vector3,titleTextColor: M3D.M3DMath.Color,
   resultTextColor: M3D.M3DMath.Color, fontName: string, fontSize: number, titleFormat: string,
   titleBackgroundColor: M3D.M3DMath.Color,resultBackgroundColor:M3D.M3DMath.Color,maxDistanceColor: M3D.M3DMath.Color, minDistanceColor: M3D.M3DMath.Color,measurementUnit: string,isShowMaxDistance: boolean,
   isShowMinDistance: boolean, model1: string,model2: string, normalDirection: M3D.M3DMath.Vector3,
   thirdPosition: M3D.M3DMath.Vector3);
let sActionState = action.execute();
let measure = action.getShape();

Creating an Angle Measurement

let action = null;
// Line-line angle measurement Action; type: M3D.Shapes.MeasureType.LINE_LINE_ANGLE
action = new SView.Actions.CreateLineLineAngleAction();
// Line-face angle measurement Action; type: M3D.Shapes.MeasureType.LINE_FACE_ANGLE
action = new SView.Actions.CreateLineFaceAngleAction();
// Face-face angle measurement Action; type: M3D.Shapes.MeasureType.FACE_FACE_ANGLE
action = new SView.Actions.CreateFaceFaceAngleAction();
action.setScene(scene);
// Set the Action parameters
// Parameter descriptions:
// objID: ID of the measurement to create; pass null to create a new measurement
// type: measurement type; the value is the corresponding type used when creating the measurement Action
// firstShape: the first object to measure, such as Edge, SectionEdge, or Face
// firstPosition: the corresponding position of the picked first object
// secondShape: the second object to measure, such as Edge, SectionEdge, or Face
// secondPosition: the corresponding position of the picked second object
// titleColor: font color of the measurement title
// textColor: font color of the measurement result
// fontName: font name
// fontSize: font size
// titleFormat: title format; currently unused, pass null
// titleBackgroundColor: background color of the measurement result title
// resultBackgroundColor: background color of the measurement result
// measurementUnit: measurement unit, 0 = none, 1 = millimeter, 2 = centimeter, 3 = meter, 4 = inch, 5 = foot
// model1: assembly path of the first associated model in the measurement; angle measurement has no such parameter — pass null
// model2: assembly path of the second associated model in the measurement; angle measurement has no such parameter — pass null
// thirdPosition: display position of the measurement result; pass null to use the default position
action.setParameter(objID: number, type: number, firstShape: M3D.Shapes.Shape, firstPosition: M3D.M3DMath.Vector3,
   secondShape: M3D.Shapes.Shape, secondPosition: M3D.M3DMath.Vector3, titleColor: M3D.M3DMath.Color,
   textColor: M3D.M3DMath.Color, fontName: string, fontSize: number, titleFormat: string,
   titleBackgroundColor: M3D.M3DMath.Color, resultBackgroundColor: M3D.M3DMath.Color, measurementUnit: string,
   model1: string, model2: string, thirdPosition: M3D.M3DMath.Vector3);
let sActionState = action.execute();
let measure = action.getShape();

Creating a Circle-Related Measurement

let action = null;
// Diameter measurement Action; type: M3D.Shapes.MeasureType.DIAMETRE
action = new SView.Actions.CreateDiametreAction();
// Radius measurement Action; type: M3D.Shapes.MeasureType.RADIUS
action = new SView.Actions.CreateRadiusAction();
// Three-point circle center measurement Action; type: M3D.Shapes.MeasureType.POINT_CENTER
action = new SView.Actions.CreateThreePointsCircleCenterAction();
// Curve circle center measurement Action; type: M3D.Shapes.MeasureType.CURVE_CENTER
action = new SView.Actions.CreateArcCircleCenterAction();
// Center-to-center distance measurement Action; type: M3D.Shapes.MeasureType.CENTER_CENTER_DISTANCE
action = new SView.Actions.CreateCenterCenterAction();
// Shaft-to-shaft distance measurement Action; type: M3D.Shapes.MeasureType.SHAFT_SHAFT_DISTANCE
action = new SView.Actions.CreateShaftShaftAction();
action.setScene(scene);
// Set the Action parameters
// Parameter descriptions:
// objID: ID of the measurement to create; pass null to create a new measurement
// type: measurement type; the value is the corresponding type used when creating the measurement Action
// firstShape: the first object to measure, such as Point, Edge, SectionEdge, or Face
// firstPosition: the corresponding position of the picked first object
// secondShape: the second object to measure, such as Point, Edge, SectionEdge, or Face
// secondPosition: the corresponding position of the picked second object; pass null if none
// thirdShape: the third object to measure, of type Point; pass null except for three-point circle center measurement
// thirdPosition: the corresponding position of the picked third object; pass null except for three-point circle center measurement
// titleColor: font color of the measurement title
// textColor: font color of the measurement result
// fontName: font name
// fontSize: font size
// titleFormat: title format; currently unused, pass null
// titleBackgroundColor: background color of the measurement result title
// resultBackgroundColor: background color of the measurement result
// measurementUnit: measurement unit, 0 = none, 1 = millimeter, 2 = centimeter, 3 = meter, 4 = inch, 5 = foot
// model1: assembly path of the first associated model in the measurement; circle-related measurements currently have no such parameter — pass null
// model2: assembly path of the second associated model in the measurement; circle-related measurements currently have no such parameter — pass null
// model3: assembly path of the third associated model in the measurement; circle-related measurements currently have no such parameter — pass null
// fourthPosition: display position of the measurement result; pass null to use the default position
action.setParameter(objID: number, type: number, firstShape: M3D.Shapes.Shape, firstPosition: M3D.M3DMath.Vector3,
   secondShape: M3D.Shapes.Shape, secondPosition: M3D.M3DMath.Vector3, thirdShape: M3D.Shapes.Shape,
   thirdPosition: M3D.M3DMath.Vector3, titleColor: M3D.M3DMath.Color, textColor: M3D.M3DMath.Color,
   fontName: string, fontSize: number, titleFormat: string, titleBackgroundColor: M3D.M3DMath.Color,
   resultBackgroundColor: M3D.M3DMath.Color, measurementUnit: string, model1: string, model2: string,
   model3: string, fourthPosition: M3D.M3DMath.Vector3);
let sActionState = action.execute();
let measure = action.getShape();

Updating the Measurement Position

let action = new SView.Actions.UpdatePositionAction();
action.setScene(scene);
//measure is the measurement object; xy is the position in the visualization viewport.
action.setParameter(measure,x,y);
action.execute();

Deleting a Measurement

let ret = false;
if (M3D.Shapes.ShapeHelper.isCorrelationModelView(measure, scene)) {
	measure.setVisible(false);
	ret = true;
} else {
	ret = shapes.removeShape(measure.getId(), true);
}
if (ret) {
	selector.remove(measure);
}

Aligning the Camera

let action = new SView.Actions.AlignmentCameraAction();
action.setScene(scene);
//The vector2 type is the M3D.M3DMath.Vector2 type
//The constructor parameters are x and y, which correspond to the x and y coordinate values of the visualization area, respectively.
action.setSelectesPoint(vector2);
action.setOpen(true);
action.execute();

Serializing Measurements

let measureJsonStr = M3D.Reader.MeasureFactory.toJson(measure);

Deserializing Measurements

let measure = M3D.Reader.MeasureFactory.fromJson(measureJsonStr,scene);
//Add the measurement to Shapes
shapes.addShape(measure);
//Show the measurement
measure.setVisible(true);
//Update the scene display
scene.refresh();