获取实体的所有面,测量两个面角度,获取面的相邻面

            //获取实体的所有面,测量两个面角度,获取面的相邻面
            int face_1 = 1;
            int face_2 = 5;

            TaggedObject body;
            Point3d point;

            theUI.SelectionManager.SelectTaggedObject("选择实体", "选择", Selection.SelectionScope.AnyInAssembly, false, false, out body, out point);

            Face[] faces = (body as Body).GetFaces();

            //测量两个面
            NXOpen.Unit nullNXOpen_Unit = null;
            NXOpen.MeasureAngle measureAngle1;
            measureAngle1 = theSession.Parts.Work.MeasureManager.NewAngle
                (nullNXOpen_Unit,
                faces[face_1], NXOpen.MeasureManager.EndpointType.StartPoint, 
                faces[face_2], NXOpen.MeasureManager.EndpointType.StartPoint, true, false);

            //编辑显示
            DisplayModification display = theSession.DisplayManager.NewDisplayModification();

            display.NewColor = 75;
            display.Apply(new DisplayableObject[] { faces[face_1] });

            //获取面的相邻面
            Tag[] tags;
            theUfSession.Modl.AskAdjacFaces(faces[face_1].Tag, out tags);

            NXOpen.Utilities.NXObjectManager nXObject = new NXOpen.Utilities.NXObjectManager();

            for (int i = 0; i < tags.Length; i++)
            {
                display.NewColor = 211;
                Face adjacent = (Face)nXObject.GetTaggedObject(tags[i]);
                display.Apply(new DisplayableObject[] { adjacent });
            }

 

posted @ 2018-06-25 22:07  巫居树  阅读(1016)  评论(0编辑  收藏  举报