NX二次开发(C#)-建模-在屏幕中间显示组件的定位点信息
Posted NX二次开发专注者
tags:
篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了NX二次开发(C#)-建模-在屏幕中间显示组件的定位点信息相关的知识,希望对你有一定的参考价值。
选择一个组件,在屏幕中间显示组件的定位点信息,其代码如下:
/// <summary>
/// 在屏幕中显示组件定位点的信息
/// </summary>
/// <param name="component"></param>
public static void DisplayPosition(Component component)
{
Point3d point3D = new Point3d();
Matrix3x3 matrix3X3 = new Matrix3x3();
component.GetPosition(out point3D, out matrix3X3);
#region 在屏幕中心点处显示轴向
uFDisp.Refresh();
NXOpen.View workView = theSession.Parts.Work.Views.WorkView;
Point3d absolutePoint3D = workView.AbsoluteOrigin;
double[] coord = new double[3] { absolutePoint3D.X, absolutePoint3D.Y, absolutePoint3D.Z };
double[] endLine = new double[3] { point3D.X, point3D.Y, point3D.Z };
UFObj.DispProps dispProps = new UFObj.DispProps();
dispProps.color = UFConstants.UF_OBJ_RED;
dispProps.font = 0;
dispProps.line_width = -1;
uFDisp.DisplayTemporaryLine(workView.Tag, UFDisp.ViewType.UseWorkView, coord, endLine, ref dispProps);
#endregion
#region 显示位置点信息
string displayText = "XC=" + point3D.X.ToString() + "\\nYC=" + point3D.Y.ToString() + "\\nZC=" + point3D.Z.ToString();
uFDisp.DisplayTemporaryText(workView.Tag, UFDisp.ViewType.UseWorkView, displayText, coord, UFDisp.TextRef.Middlecenter, ref dispProps, 0, 1);
#endregion
}
以上是关于NX二次开发(C#)-建模-在屏幕中间显示组件的定位点信息的主要内容,如果未能解决你的问题,请参考以下文章