NX二次开发代码分享: 获取实体的最小包络尺寸bounding box
NX二次开发代码分享: 获取实体的最小包络尺寸bounding box很多时候我们需要指导毛坯的尺寸,也就是stock size,在moldwizard里面已经有这个类似的功能,如果通过开发,如何获得,请参考如下代码,执行结果,就是显示x,y,z方向的尺寸!
static int UF_UI_sel_init(UF_UI_selection_p_t select, void * user_data)
{
UF_UI_mask_tmask_triples[] = {
UF_solid_type, 0, 0};
if (UF_CALL(UF_UI_set_sel_mask(select,UF_UI_SEL_MASK_CLEAR_AND_ENABLE_SPECIFIC,1,mask_triples))==0)
{
return (UF_UI_SEL_SUCCESS);
}
else
{
return (UF_UI_SEL_FAILURE);
}
}
static void do_api()
{
tag_t object,view;
char cue[] = "select object to get the dimensions";
int scope = UF_UI_SEL_SCOPE_WORK_PART;
double x,y,z;
intresponse;
double boundingbox;
double cursor;
UF_UI_select_with_single_dialog(cue,"select the object",scope, UF_UI_sel_init, NULL, &response, &object, cursor, &view );
if (response == UF_UI_OBJECT_SELECTED ||
response == UF_UI_OBJECT_SELECTED_BY_NAME)
{
UF_DISP_set_highlight(object,0);
UF_MODL_ask_bounding_box(object,boundingbox);
x = boundingbox-boundingbox;
y = boundingbox-boundingbox;
z = boundingbox-boundingbox;
char message;
sprintf(message," X dimension = %.3f\n Y dimension = %.3f\n Z dimension = %.3f\n",x,y,z);
uc1601(message,1);
}
else
uc1601("No object selected",1);
}
版主能否用C#写个简单的例子啊,C++的看不懂啊 能用NXOpen C++整个bounding box的例子吗
页:
[1]