单选和多选及过滤
1 char sCue[] = "选择"; 2 char sTitle[] = "功能测试"; 3 int iScope = UF_UI_SEL_SCOPE_NO_CHANGE; 4 int iResponse; 5 tag_t tObject; 6 tag_t viewTag = NULL_TAG; 7 double cursor[3]; 8 double min_corner[3] = { 0.0,0.0,0.0 }; 9 double directions[3][3]; 10 double distances[3]; 11 UF_UI_select_with_single_dialog(sCue, sTitle, iScope, init_face, NULL, &iResponse, &tObject, cursor, &viewTag);
单选
1 char sCue[] = "象选择对话框"; 2 char sTitle[] = "象选择对话框"; 3 int iScope = UF_UI_SEL_SCOPE_NO_CHANGE; 4 int iResponse; 5 tag_t *tObject; 6 int count = 0; 7 UF_UI_select_with_class_dialog(sCue, sTitle, iScope, init_proc, NULL, &iResponse, &count, &tObject); 8 多选
1 static int select_filter_proc_fn(tag_t object, int type[1], void* user_data, UF_UI_selection_p_t select) 2 { 3 if (object == NULL) 4 { 5 return UF_UI_SEL_REJECT; 6 } 7 else 8 { 9 return UF_UI_SEL_ACCEPT; 10 } 11 } 12
static int init_proc_body(UF_UI_selection_p_t select, void* user_data)
{
int errorCode = 0;
int num_triples = 1;
UF_UI_mask_t mask_triples[] = { UF_solid_type,UF_solid_face_subtype, UF_UI_SEL_FEATURE_CYLINDRICAL_FACE };
errorCode = UF_UI_set_sel_mask(select, UF_UI_SEL_MASK_CLEAR_AND_ENABLE_SPECIFIC, num_triples, mask_triples);
if ((UF_UI_set_sel_procs(select, select_filter_proc_fn, NULL, user_data)) == 0)
{
return UF_UI_SEL_SUCCESS;
}
else
{
return UF_UI_SEL_FAILURE;
}
}
过滤
1 //selection控件设置过滤类型 2 void SetSelectionType(NXOpen::BlockStyler::SelectObject* selectionID) 3 { 4 //设置过滤 5 Selection::SelectionAction action = Selection::SelectionActionClearAndEnableSpecific; 6 std::vector<Selection::MaskTriple> maskArray; 7 //maskArray.push_back(Selection::MaskTriple( UF_solid_type, UF_solid_body_subtype, UF_UI_SEL_FEATURE_SOLID_BODY )); // 实体 8 //maskArray.push_back(Selection::MaskTriple( UF_solid_type, UF_all_subtype, UF_UI_SEL_FEATURE_ANY_FACE)); // 面 9 maskArray.push_back(Selection::MaskTriple( UF_solid_type, UF_all_subtype, UF_UI_SEL_FEATURE_PLANAR_FACE)); //平面 10 //maskArray.push_back(Selection::MaskTriple( UF_solid_type, UF_all_subtype, UF_UI_SEL_FEATURE_ANY_EDGE)); // 边 11 //maskArray.push_back(Selection::MaskTriple( UF_component_type, 0, 0)); //组件 12 //maskArray.push_back(Selection::MaskTriple( UF_point_type, 0, 0 )); 13 //maskArray.push_back(Selection::MaskTriple( UF_line_type, 0, 0 )); // 线 14 //maskArray.push_back(Selection::MaskTriple( UF_circle_type, 0, 0 )); //圆弧 15 //maskArray.push_back(Selection::MaskTriple( UF_spline_type, 0, 0 )); 16 //maskArray.push_back(Selection::MaskTriple( UF_coordinate_system_type, 0, 0 )); 17 //maskArray.push_back(Selection::MaskTriple( UF_datum_axis_type, 0, 0 )); 18 //maskArray.push_back(Selection::MaskTriple( UF_datum_plane_type, 0, 0 )); 19 //maskArray.push_back(Selection::MaskTriple( UF_plane_type, 0, 0 )); 20 //maskArray.push_back(Selection::MaskTriple( UF_axis_type, 0, 0 )); 21 //maskArray.push_back(Selection::MaskTriple( UF_drafting_entity_type, 0, 0 )); // 制图对象 22 selectionID->GetProperties()->SetSelectionFilter("SelectionFilter", action, maskArray); 23 }
NXOpen控件过滤
1 std::vector<NXOpen::Selection::MaskTriple> selectionfilter(1); 2 NXOpen::Selection::MaskTriple maskTriple1 ; 3 maskTriple1.Type = UF_solid_type; 4 maskTriple1.Subtype = UF_solid_face_subtype; 5 maskTriple1.SolidBodySubtype = UF_UI_SEL_FEATURE_ANY_FACE; 6 selectionfilter.push_back(maskTriple1); 7 8 PropertyList *selectionToolFaceProps = selectionToolFace->GetProperties(); 9 selectionToolFaceProps->SetSelectionFilter("SelectionFilter", NXOpen::Selection::SelectionAction::SelectionActionClearAndEnableSpecific, selectionfilter); 10 delete selectionToolFaceProps; 11 selectionToolFaceProps = NULL;
控件不过滤
1 PropertyList* selectionObjProps = selectionObj->GetProperties(); 2 std::vector<TaggedObject*> selObjs; 3 selObjs = selectionObjProps->GetTaggedObjectVector("SelectedObjects"); 4 delete selectionObjProps; 5 selectionObjProps = NULL;