在NX8.5以上版本可以使用NXOpen.View.AbsoluteOrigin或UF_VIEW_ask_center等方式获取视图中心绝对坐标
但NX6.0版本的.NET中没有UF_VIEW_ask_center以及uc6430等获取视图中心坐标的相关UF函数,在NXOPEN中只有NXOpen.View.Origin,但此属性获取到的坐标系不是绝对坐标系的值,需要进行坐标转换。
/// <summary>/// 获取视图中心绝对坐标/// </summary>/// <param name="theview"></param>/// <returns></returns>public static double[] AskViewCenter(NXOpen.View theview){UI theUI = UI.GetUI();Session theSession = Session.GetSession();NXOpen.UF.UFSession theUfSession = NXOpen.UF.UFSession.GetUFSession();double[] center = new double[3];if (theview == null) theview = theSession.Parts.Work.Views.WorkView;Point3d theOri = theview.Origin;//此视图中心坐标非绝对坐标系坐标,NX8.5以上可以用NXOpen.View.AbsoluteOrigin获取绝对坐标Vector3d xVec = theview.GetAxis(XYZAxis.XAxis);Vector3d yVec = theview.GetAxis(XYZAxis.YAxis);double[] viewOrign = new double[] { -theOri.X, -theOri.Y, -theOri.Z };double[] viewXvec = new double[3] { xVec.X, xVec.Y, xVec.Z };double[] viewYvec = new double[3] { yVec.X, yVec.Y, yVec.Z };double[] viewMtx = new double[9];theUfSession.Mtx3.Initialize(viewXvec, viewYvec, viewMtx);theUfSession.Mtx3.VecMultiplyT(viewOrign, viewMtx, center);return center;}