admin 发表于 2019-3-2 14:25:23

NX二次开发源码分享:从当前视图创建CSYS


NX二次开发源码分享:从当前视图创建CSYS

比较有用哦,尤其在 PMI 视图选取的时候,自己想想!


double[] center = new double { 0.0, 0.0, 0.0 };
            Tag viewTag = Tag.Null;

            theUfSession.View.AskWorkView(out viewTag);

            if (viewTag == Tag.Null) return;

            theUfSession.View.AskCenter(viewTag, center);

            View view = (View)(NXObjectManager.Get(viewTag));

            Point3d point3d = new Point3d (center, center, center);
            Vector3d xDirection = new Vector3d(view.Matrix.Xx, view.Matrix.Xy, view.Matrix.Xz);
            Vector3d yDirection = new Vector3d(view.Matrix.Yx, view.Matrix.Yy, view.Matrix.Yz);

            Xform xform = workPart.Xforms.CreateXform(point3d, xDirection, yDirection, NXOpen.SmartObject.UpdateOption.WithinModeling, 1.0);

            NXOpen.Features.DatumCsysBuilder datumCsysBuilder = workPart.Features.CreateDatumCsysBuilder(null);
            datumCsysBuilder.Csys = workPart.CoordinateSystems.CreateCoordinateSystem(xform, NXOpen.SmartObject.UpdateOption.WithinModeling);
            datumCsysBuilder.DisplayScaleFactor = 1.25;
            datumCsysBuilder.Commit();
            datumCsysBuilder.Destroy();
页: [1]
查看完整版本: NX二次开发源码分享:从当前视图创建CSYS