NXOpen绝对座标值转为WCS座标值

VS2010 NX8.5

 

//定义函数

Point3d WCSPointTransposeCsysPoint(Point3d origionPoint3D);//工作部件绝对坐标值转化为新坐标下点坐标值
Point3d PointMatrixToNewPoint(Point3d origionPoint3D,Matrix3x3 matrix3X3,Point3d newPoint3D);// 点的转换

 

Point3d HoleTable::WCSPointTransposeCsysPoint(Point3d origionPoint3D) //工作部件绝对坐标值转化为WCS坐标下点坐标值
{
try
{
Point3d WcsOrigin ;//WCS 原点
NXOpen::Matrix3x3 WCSmatrix1;//WCS 矩阵
NXOpen::Vector3d WCSxDirection;//WCS X轴
NXOpen::Vector3d WCSyDirection;//WCS Y轴
NXOpen::CartesianCoordinateSystem* OriginalWcsData = workPart->WCS()->CoordinateSystem();
WcsOrigin = workPart->WCS()->Origin();//获得WCS的原点
WCSmatrix1 = workPart->WCS()->CoordinateSystem()->Orientation()->Element();//获得WCS的矩阵
OriginalWcsData->GetDirections(&WCSxDirection, &WCSyDirection);//获得WCS的XY轴

Point3d tmpPoint3D;//转换
tmpPoint3D.X = origionPoint3D.X - WcsOrigin.X;
tmpPoint3D.Y = origionPoint3D.Y - WcsOrigin.Y;
tmpPoint3D.Z = origionPoint3D.Z - WcsOrigin.Z;

Point3d WCSPoint3D=PointMatrixToNewPoint(tmpPoint3D,WCSmatrix1,origionPoint3D);//点的转换

return Point3d(WCSPoint3D);

}
catch(exception& ex)
{
//---- Enter your exception handling code here -----
HoleTable::theUI->NXMessageBox()->Show("点的转换", NXOpen::NXMessageBox::DialogTypeError, ex.what());
}
}

Point3d HoleTable::PointMatrixToNewPoint(Point3d origionPoint3D,Matrix3x3 matrix3X3,Point3d newPoint3D)// 点的转换
{
try
{
newPoint3D.X = matrix3X3.Xx * origionPoint3D.X + matrix3X3.Xy * origionPoint3D.Y + matrix3X3.Xz * origionPoint3D.Z;
newPoint3D.Y = matrix3X3.Yx * origionPoint3D.X + matrix3X3.Yy * origionPoint3D.Y + matrix3X3.Yz * origionPoint3D.Z;
newPoint3D.Z = matrix3X3.Zx * origionPoint3D.X + matrix3X3.Zy * origionPoint3D.Y + matrix3X3.Zz * origionPoint3D.Z;
Point3d WCSPoint3D =newPoint3D;//转换后的点
return Point3d(WCSPoint3D);
}
catch(exception& ex)
{
//---- Enter your exception handling code here -----
HoleTable::theUI->NXMessageBox()->Show("点的转换", NXOpen::NXMessageBox::DialogTypeError, ex.what());
}
}

 

 

NXOpen绝对座标值转为WCS座标值

上一篇:2018年学习JavaScript的十大课程


下一篇:NXOPEN 选择材料库对实体进行缩放比例