UG二次开发 获取零件的中心

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

获取实体、组件的中心点,这里有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(
评论 2
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包

打赏作者

MarcoPro

你的鼓励将是我创作的最大动力

¥1 ¥2 ¥4 ¥6 ¥10 ¥20
扫码支付:¥1
获取中
扫码支付

您的余额不足,请更换扫码支付或充值

打赏作者

实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值