SView Help Center
English (US)

测量

Author: sviewngts Last Updated: 2026-09-08 10:03

接口列表

接口名称 说明
创建距离测量 创建距离测量
创建角度测量 创建角度测量
创建圆相关测量 创建圆相关测量
更新测量位置 更新测量结果显示位置
删除测量 删除测量
对齐相机 对齐相机
序列化 将测量序列化为Json格式
反序列化 将Json格式数据反序列化为测量对象

创建距离测量

let action = null;
//点点距离测量Action,类型为M3D.Shapes.MeasureType.PNT_PNT_DISTANCE
action = new SView.Actions.CreatePointPointDistanceAction();
//点线距离测量Action,类型为M3D.Shapes.MeasureType.PNT_LINE_DISTANCE
action = new SView.Actions.CreatePointLineDistanceAction();
//点面距离测量Action,类型为M3D.Shapes.MeasureType.PNT_FACE_DISTANCE
action = new SView.Actions.CreatePointFaceDistanceAction();
//线线距离测量Action,类型为M3D.Shapes.MeasureType.LINE_LINE_DISTANCE
action = new SView.Actions.CreateLineLineDistanceAction();
//线面距离测量Action,类型为M3D.Shapes.MeasureType.LINE_FACE_DISTANCE
action = new SView.Actions.CreateLineFaceDistanceAction();
//面面距离测量Action,类型为M3D.Shapes.MeasureType.FACE_FACE_DISTANCE
action = new SView.Actions.CreateFaceFaceDistanceAction();
//厚度距离测量Action,类型为M3D.Shapes.MeasureType.THICKNESS_DISTANCE
action = new SView.Actions.CreateThicknessDistanceAction();
action.setScene(scene);
//设置action的参数
//参数说明:
//objID:创建的测量Id,新建测量则传null
//type:测量类型,值为创建测量Action时的对应类型
//firstShape:测量第一个对象,如:Point、Edge、SectionEdge、Face
//firstPosition:拾取第一个对象的对应的位置
//secondShape:测量第二个对象,如:Point、Edge、SectionEdge、Face,厚度测量可以传null
//secondPosition:拾取第二个对象的对应的位置,厚度测量可以传null
//titleTextColor:测量标题字体颜色
//resultTextColor:测量结果字体颜色
//fontName:字体名称
//fontSize:字体大小
//titleFormat:标题格式,暂时无用,传null即可
//titleBackgroundColor:测量结果标题背景颜色
//resultBackgroundColor:测量结果背景颜色
//maxDistanceColor:最大值结果标题背景颜色
//minDistanceColor:最小值结果标题背景颜色
//measurementUnit:测量单位,0:无单位,1:毫米,2:厘米,3:米,4:英寸,5:英尺
//isShowMaxDistance:是否显示最大值
//isShowMinDistance:是否显示最小值
//model1:点点测量中第一个点的关联模型装配路径,无则传null
//model2:点点测量中第二个点的关联模型装配路径,无则传null
//normalDirection:厚度测量中计算厚度的方向
//thirdPosition:测量结果显示位置,使用默认位置传null
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();

创建角度测量

let action = null;
//线线角度测量Action,类型为M3D.Shapes.MeasureType.LINE_LINE_ANGLE
action = new SView.Actions.CreateLineLineAngleAction();
//线面角度测量Action,类型为M3D.Shapes.MeasureType.LINE_FACE_ANGLE
action = new SView.Actions.CreateLineFaceAngleAction();
//面面角度测量Action,类型为M3D.Shapes.MeasureType.FACE_FACE_ANGLE
action = new SView.Actions.CreateFaceFaceAngleAction();
action.setScene(scene);
//设置action的参数
//参数说明:
//objID:创建的测量Id,新建测量则传null
//type:测量类型,值为创建测量Action时的对应类型
//firstShape:测量第一个对象,如:Edge、SectionEdge、Face
//firstPosition:拾取第一个对象的对应的位置
//secondShape:测量第二个对象,如:Edge、SectionEdge、Face
//secondPosition:拾取第二个对象的对应的位置
//titleColor:测量标题字体颜色
//textColor:测量结果字体颜色
//fontName:字体名称
//fontSize:字体大小
//titleFormat:标题格式,暂时无用,传null即可
//titleBackgroundColor:测量结果标题背景颜色
//resultBackgroundColor:测量结果背景颜色
//measurementUnit:测量单位,0:无单位,1:毫米,2:厘米,3:米,4:英寸,5:英尺
//model1:测量中第一个关联模型的装配路径,角度测量无此参数传null
//model2:测量中第二个关联模型的装配路径,角度测量无此参数传null
//thirdPosition:测量结果显示位置,使用默认位置传null
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();

创建圆相关测量

let action = null;
//直径测量Action,类型为M3D.Shapes.MeasureType.DIAMETRE
action = new SView.Actions.CreateDiametreAction();
//半径测量Action,类型为M3D.Shapes.MeasureType.RADIUS
action = new SView.Actions.CreateRadiusAction();
//三点创建圆心测量Action,类型为M3D.Shapes.MeasureType.POINT_CENTER
action = new SView.Actions.CreateThreePointsCircleCenterAction();
//曲线创建圆心测量Action,类型为M3D.Shapes.MeasureType.CURVE_CENTER
action = new SView.Actions.CreateArcCircleCenterAction();
//圆心距测量Action,类型为M3D.Shapes.MeasureType.CENTER_CENTER_DISTANCE
action = new SView.Actions.CreateCenterCenterAction();
//轴距测量Action,类型为M3D.Shapes.MeasureType.SHAFT_SHAFT_DISTANCE
action = new SView.Actions.CreateShaftShaftAction();
action.setScene(scene);
//设置action的参数
//参数说明:
//objID:创建的测量Id,新建测量则传null
//type:测量类型,值为创建测量Action时的对应类型
//firstShape:测量第一个对象,如:Point、Edge、SectionEdge、Face
//firstPosition:拾取第一个对象的对应的位置
//secondShape:测量第二个对象,如:Point、Edge、SectionEdge、Face
//secondPosition:拾取第二个对象的对应的位置,无则传null
//thirdShape:测量第三个对象,Point类型,除三点创建圆心外传null
//thirdPosition:拾取第三个对象的对应的位置,除三点创建圆心外传null
//titleColor:测量标题字体颜色
//textColor:测量结果字体颜色
//fontName:字体名称
//fontSize:字体大小
//titleFormat:标题格式,暂时无用,传null即可
//titleBackgroundColor:测量结果标题背景颜色
//resultBackgroundColor:测量结果背景颜色
//measurementUnit:测量单位,0:无单位,1:毫米,2:厘米,3:米,4:英寸,5:英尺
//model1:测量中第一个关联模型的装配路径,圆相关测量暂无此参数传null
//model2:测量中第二个关联模型的装配路径,圆相关测量暂无此参数传null
//model3:测量中第三个关联模型的装配路径,圆相关测量暂无此参数传null
//fourthPosition:测量结果显示位置,使用默认位置传null
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();

更新测量位置

let action = new SView.Actions.UpdatePositionAction();
action.setScene(scene);
//measure为测量对象,xy为可视化视口中的位置
action.setParameter(measure,x,y);
action.execute();

删除测量

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);
}

对齐相机

let action = new SView.Actions.AlignmentCameraAction();
action.setScene(scene);
//vector2类型为M3D.M3DMath.Vector2类型
//构造参数为x,y分别对应可视化区域的x,y坐标值
action.setSelectesPoint(vector2);
action.setOpen(true);
action.execute();

序列化

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

反序列化

let measure = M3D.Reader.MeasureFactory.fromJson(measureJsonStr,scene);
//将测量添加到Shapes中
shapes.addShape(measure);
//将剖切面显示
measure.setVisible(true);
//更新场景显示
scene.refresh();