获取实体、组件的中心点,这里有2种方法供参考:
1、通过UF_MODL_ask_bounding_box获取边界,然后间接获取对象的中心点

//通过ufun函数获取boundbox的边界
double[] bounding_box = new double[6] { 0, 0, 0, 0, 0, 0 };
theUFSession.Modl.AskBoundingBox(txtBodyList[0].Tag, bounding_box);
//零件的中心点
double[] pointCenter = new double[3] { 0, 0, 0 };
pointCenter[0] = (bounding_box[3] + bounding_box[0]) / 2;
pointCenter[1] = (bounding_box[4] + bounding_box[1]) / 2;
pointCenter[2] = (bounding_box[5] + bounding_box[2]) / 2;
double boundHeight = Math.Abs(bounding_box[1] - bounding_box[4]);
double boundLen = Math.Abs(bounding_box[0] - bounding_box[3]);
double[] pointCenter1 = new double[3] { 0, 0, 0 };
//创建坐标系
Tag matrix_id = Tag.Null;
Tag temp_scys = Tag.Null;
theUFSession.Csys.CreateMatrix(csys_matrix, out matrix_id);
theUFSession.Csys.CreateCsys(

文章介绍了两种方法来获取实体和组件的中心点,一种是通过UF_MODL_ask_bounding_box获取边界并计算中心,另一种是使用测量体功能获取质心坐标。对于通过UF_MODL_ask_bounding_box得到的坐标,需要进行映射以转换到绝对坐标系。
最低0.47元/天 解锁文章
833

被折叠的 条评论
为什么被折叠?



