哈哈,自己早就摸索出来了,写成了一个函数,供大家使用。
//单选对话框函数,type=1为单选面,2为单选实体,3为单选边,4为单选点,5为单选线,6为钣金件
public NXOpen.Tag EvanSingleSelectDialog(string mesg,string title,int type)
{
int scope, response;
IntPtr user_data=new IntPtr();
NXOpen.Tag faceObj, view;
double[] cursor ={ 0.0, 0.0, 0.0 };
NXOpen.UF.UFUi.SelInitFnT initPro;
scope = NXOpen.UF.UFConstants.UF_UI_SEL_SCOPE_NO_CHANGE;
switch(type)
{
case 1:
initPro = new NXOpen.UF.UFUi.SelInitFnT(initProFace); //type=1设置选择类型为面
break;
case 2:
initPro = new NXOpen.UF.UFUi.SelInitFnT(initProSolid); //type=2设置选择类型为实体
break;
case 3:
initPro = new NXOpen.UF.UFUi.SelInitFnT(initProEdge); //type=3设置选择类型为边
break;
case 4:
initPro = new NXOpen.UF.UFUi.SelInitFnT(initProPoint); //type=4设置选择类型为点
break;
case 5:
initPro = new NXOpen.UF.UFUi.SelInitFnT(initProCurve); //type=5设置选择类型为线
break;
case 6:
initPro = new NXOpen.UF.UFUi.SelInitFnT(initProSheet); //type=6设置选择类型为钣金件
break;
default:
initPro = new NXOpen.UF.UFUi.SelInitFnT(initProSolid); //默认设置选择类型为实体
break;
}
theUFSession.Ui.LockUgAccess(UFConstants.UF_UI_FROM_CUSTOM); //锁定当前工具,防止进入其他工具
theUFSession.Ui.SelectWithSingleDialog(mesg, title, scope, initPro, user_data,
out response, out faceObj, cursor, out view); //调用单选对话框
theUFSession.Ui.UnlockUgAccess(UFConstants.UF_UI_FROM_CUSTOM); //解锁
if (response == NXOpen.UF.UFConstants.UF_UI_OBJECT_SELECTED ||
response == NXOpen.UF.UFConstants.UF_UI_OBJECT_SELECTED_BY_NAME)
{
theUFSession.Disp.SetHighlight(faceObj, 0); //取消选择后实例的高亮显示
}
return faceObj;
} |