NX二次开发(C#)-BlockUI-批量选择点

 /// 
        /// 批量选择点(框选或者多选)
        /// 
        /// 
        public static void SelectPointsByClass(out Point[] points)
        {
            try
            {
                workPart = theSession.Parts.Work;
                string mes = "框选点";
                UFUi.SelectionOption opts = new UFUi.SelectionOption();
                UFUi.Mask[] mask = new UFUi.Mask[1];
                mask[0].solid_type = UFConstants.UF_UI_SEL_SCOPE_WORK_PART_AND_OCC;
                mask[0].object_type = UFConstants.UF_point_type;
                mask[0].object_subtype = 0;
                opts.other_options = 0;
                opts.num_mask_triples = 1;
                opts.scope = UFConstants.UF_UI_SEL_SCOPE_WORK_PART_AND_OCC;
                opts.mask_triples = mask;
                opts.reserved = IntPtr.Zero;

                opts.mask_triples = mask;
                int count;
                int response;
                Tag[] tags;

                theUFUi.SelectByClass(mes, ref opts, out response, out count, out tags);

                points = new Point[0];
                NXObjectManager nXObjectManager = new NXObjectManager();
                foreach (var tg in tags)
                {
                    TaggedObject taggedObject = (TaggedObject)nXObjectManager.GetTaggedObject(tg);
                    Point point = (Point)taggedObject;
                    Array.Resize(ref points, points.Length + 1);
                    points[points.Length - 1] = point;
                }
            }
            catch (Exception ee)
            {
                points = new Point[0];
                NXMessageBox nXMessageBox = theUI.NXMessageBox;
                nXMessageBox.Show("错误",NXMessageBox.DialogType.Error,ee.ToString());  
            }

        }

 

你可能感兴趣的:(C#,UIStyler,NX二次开发)