点击查看详细介绍

判断面半径,类型轴中心极点坐标

xiaoliu8 9年前 5898 41

购买与咨询 NX 二次开发视频教程,请联系微信号:13890821008  QQ号:85585969  


判断面半径,类型轴中心极点坐标

UF_MODL_ask_face_data
判断面类型 圆柱或圆锥等等轴中心方向 极点坐标 半径 大小

#include <uf.h>
#include <uf_exit.h>
#include <uf_ui.h>
#if ! defined ( __hp9000s800 ) && ! defined ( __sgi ) && ! defined ( __sun )
# include <strstream>
# include <iostream>
using std::ostrstream;
using std::endl;
using std::ends;
using std::cerr;
#else
# include <strstream.h>
# include <iostream.h>
#endif
#include <uf_modl.h>
#include <uf_obj.h>

//设置选择的实体类型
static int init_proc( UF_UI_selection_p_t select, void *user_data )
{
int errorCode = 0;

int num_triples = 1; //选择类型 数量
UF_UI_mask_t mask_triples[]={UF_face_type,0,0,}; //定义选择类型

errorCode = UF_UI_set_sel_mask(select, UF_UI_SEL_MASK_CLEAR_AND_ENABLE_SPECIFIC,num_triples, mask_triples);
if( errorCode == 0)
{
return UF_UI_SEL_SUCCESS;
}
else
{
return UF_UI_SEL_FAILURE;
}
}

extern "C" DllExport void ufsta( char *param, int *returnCode, int rlen )
{
/* Initialize the API environment */
int errorCode = UF_initialize();

if ( 0 == errorCode )

●●●请先 登陆注册 后查看●●●

UF_UI_lock_ug_access (UF_UI_FROM_CUSTOM);//加锁
UF_UI_select_with_single_dialog(message,title,scope,init_proc,NULL,&response,&object_tag,cursor,&view); //选择框
UF_DISP_set_highlight(object_tag,0); //1高亮显示 0不高亮显示
UF_UI_unlock_ug_access (UF_UI_FROM_CUSTOM);//解锁

if (response==UF_UI_OBJECT_SELECTED)
{
UF_MODL_ask_feat_body (object_tag,&object_tag);
// 分析面
int type=0; //判断面类型
int norm_dir=0; //面法向,norm_dir=1 外R
double point[3]; //轴中心 点
double dir[3]; //轴方向
double box[6]; //极点坐标
double radius[1]; //半径 圆锥=最小半径 + 最大半径 /2
double rad_data[1];
UF_MODL_ask_face_data (
object_tag, //输入面
&type,point,dir,box,radius,rad_data,&norm_dir); //分析面

//判断面类型 type值
//16 =圆柱
//17 =圆锥
//18 =球
//19 =旋转(环形)
//20 =挤压
//22 =有界平面
//23 =角(物)
//43 = b级表面
//65 =偏移曲面
//66 =外表面

char msg[64];
UF_UI_open_listing_window(); //打开窗口
sprintf(msg, "判断面类型:%d\n",type);
UF_UI_write_listing_window(msg);

if (norm_dir==1)
UF_UI_write_listing_window("外R\n");
else
UF_UI_write_listing_window("内R\n");

sprintf(msg, "轴中心 点:%.2f,%.2f,%.2f\n",point[0],point[1],point[2]);
UF_UI_write_listing_window(msg);

sprintf(msg, "轴方向:%.2f,%.2f,%.2f\n",dir[0],dir[1],dir[2]);
UF_UI_write_listing_window(msg);

sprintf(msg, "半径 圆锥=最小半径 + 最大半径 /2:%.2f\n",radius[0]);
UF_UI_write_listing_window(msg);

}
/* Terminate the API environment */
errorCode = UF_terminate();
}

/* Print out any error messages */
return;
}

extern "C" int ufusr_ask_unload( void )
{
return (UF_UNLOAD_IMMEDIATELY);

}

1

最新回复 (41)
  • hzx1495 9年前
    1

    感谢楼主的分享,学习学习~

  • hzx1495 9年前
    2

    在调用动态链接库后选择表面,UG出现了闪退的情况,请问这是怎么回事呢?

  • xiaoliu8 9年前
    3

    回复:2楼

    注意版本与库文件的问题

  • BAO694893367 VIP会员 9年前
    4

  • BAO694893367 VIP会员 9年前
    5

  • BAO694893367 VIP会员 9年前
    6

    是 什么问题? 生成不了

  • ahqqqq22 9年前
    7

    感谢楼主的分享,学习学习~

  • 宋宇 9年前
    8

    感谢楼主的分享,学习学习~

  • c1_wangyf 9年前
    9

    好东西一定要顶,加油!

  • xyq407 9年前
    10

    感谢楼主的分享,学习学习~

  • jinhehuan 9年前
    11

    感谢楼主的分享,学习学习

  • qazqaz000 9年前
    12

    感谢楼主的分享

  • Mister_xv 8年前
    13

    感谢分享阿斯达岁的啊啊是

  • zhixiang 8年前
    14

    谢谢分享!!!!!!!!!!!!!!

  • bbs1860 8年前
    15

    学习中,谢谢分享!!!

请登录后发表新帖