public static Point3d[] AskPoints() { var selectionoptions = new UFUi.SelectionOption(); // Type Filter (right next to the 'Menu' dropdown menu in the NX GUI) var selectionFilter = new UFUi.Mask(); selectionFilter.object_type = UFConstants.UF_point_type; selectionFilter.object_subtype = UFConstants.UF_point_subtype; selectionFilter.solid_type = 0; selectionoptions.mask_triples = new[] { selectionFilter }; selectionoptions.num_mask_triples = 1; // Only objects in workpart, not in an assembly or other components of an assembly // aka. Selection Scope (right next the 'Type Filter in the NX GUI) selectionoptions.scope = UFConstants.UF_UI_SEL_SCOPE_WORK_PART; int response; int pointCount; Tag[] pointTags; UfSession.Ui.SelectByClass("Select Points to export as CSV.", ref selectionoptions, out response, out pointCount, out pointTags); Point3d[] pts = new Point3d[pointCount]; for (int i = 0; i < pointCount; i++) { // The dialog only returns the Tags (ID as unsigend integer) of the points. The object concrete object will be obtained via the global object manager Point point = (Point)UfSession.GetObjectManager().GetTaggedObject(pointTags[i]); pts[i] = point.Coordinates; } return(pts); }
/// <summary> /// 过滤选择 /// </summary> /// <param name="select"></param> /// <param name="user_data"></param> /// <returns></returns> private static int sele_in_proc(IntPtr select, IntPtr user_data) { int num_triples = 1; UFUi.Mask[] triples = new UFUi.Mask[1]; triples[0].object_type = 70; triples[0].solid_type = 0; triples[0].object_subtype = 0; theUFSession.Ui.SetSelMask(select, UFUi.SelMaskAction.SelMaskClearAndEnableSpecific, num_triples, triples); return(UFConstants.UF_UI_SEL_SUCCESS); }