下冲头问题

exturded下冲头拉伸得到的是 uf_list_t ,后续操作上没有tag_t来的方便,
UF_MODL_create_extruded( objects, taper_angle, limit1,point, direction, sign_ex, &features );
改用UF_MODL_create_extrusion(generators,face_num,trim_data,tape_angle,limit1,offsets,region_point,false,true,dir,sign,&objects_e,&obj_cnt);
获得的objects_e,为tag_t
后面打孔采用三步走策略
UF_MODL_ask_feat_faces(*objects_e,&objects);
UF_MODL_ask_list_item(objects,2,&face_d2);
UF_MODL_create_simple_hole(origin2,direction1,&d2,"70","120",face_d2,face_t1,&hole_2);
UF_MODL_delete_list( &objects );
UF_free(objects_e);

下面是源代码:


/*****************************************************************************
**
** NX8_Open1_EJ.cpp
**
** Description:
** Contains Unigraphics entry points for the application.
**
*****************************************************************************/

/* Include files */

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.h>

include <uf_ui.h>

include <uf_exit.h>

include <uf_modl.h>

include <math.h>

include <uf_part.h>

include <uf_curve.h>

include <uf_layer.h>

include <uf_view.h>

include <uf_defs.h>

include <UF_drf.h>

include< uf_facet.h>

include <uf_obj.h>//test

include <uf_part.h>//test

define UF_CALL(X) (report_error( FILE, LINE, #X, (X)))

static int report_error( char *file, int line, char *call, int irc)
{
if (irc)
{
char err[133],
msg[133];

    sprintf(msg, "*** ERROR code %d at line %d in %s:\n+++ ",
        irc, line, file);
    UF_get_fail_message(irc, err);

    UF_print_syslog(msg, FALSE);
    UF_print_syslog(err, FALSE);
    UF_print_syslog("\n", FALSE);
    UF_print_syslog(call, FALSE);
    UF_print_syslog(";\n", FALSE);

    if (!UF_UI_open_listing_window())
    {
        UF_UI_write_listing_window(msg);
        UF_UI_write_listing_window(err);
        UF_UI_write_listing_window("\n");
        UF_UI_write_listing_window(call);
        UF_UI_write_listing_window(";\n");
    }
}

return(irc);

}

/*****************************************************************************
** Activation Methods
*****************************************************************************/
/* Unigraphics Startup
** This entry point activates the application at Unigraphics startup */
extern DllExport void ufsta( char *param, int returnCode, int rlen )
{
/
Initialize the API environment /
if( UF_CALL(UF_initialize()) )
{
/
Failed to initialize */
return;
}

/* TODO: Add your application code here */
//交互数据声明
double k=1.20,g=0.01,ic=12.7,s=4.76,r1=1.191,r2=r1,d=5.156,r=0,d_in=0,ang=80,ang_hole=0;
//double pi=3.1415926;
//外部特征声明
UF_FEATURE_SIGN  sign=UF_NULLSIGN;//UF_NEGATIVE;
double origin[3]={0,0,0};
double dir [ 3 ] ={0,0,1};
tag_t   cyl_obj_id;
double  location[3]={0,0,9};
tag_t   face;
tag_t   boss_obj_id;
uf_list_p_t boss_list;
//Chamfer声明
uf_list_p_t blend_edge_list = NULL;

//extrude 声明
UF_CURVE_line_t sline1, sline2, sline3, sline4;
tag_t line1, line2, line3, line4;
int i;
double j=0.3;
uf_list_p_t objects;
tag_t generators[4];
char *taper_angle = "0.0";
char *limit[ 2 ] = { "75", "90" };
char *limit1[ 2 ] = { "34", "75" };
double point[ 3 ] = { 0.0, 0.0, 0.0 };
double direction[ 3 ] = { 0.0, 0.0, 1.0 };
uf_list_p_t features,features1;
UF_FEATURE_SIGN sign_ex=UF_POSITIVE;//UF_POSITIVE,,UF_NULLSIGN

//temporary
char text[132];

tag_t view_tag = NULL_TAG;
UF_VIEW_visualization_t view_data;
double view_rotate_axis[3] = { 0.0, 0.0, 1.0 };
double view_rotate_delta_angle = 1;
int view_rotate_time = 45;
   




//Hole声明
tag_t   hole_bot_id,hole_2;
tag_t  face_li,face_d2;
tag_t  face_t1=null_tag;
tag_t  face_t2;
double origin2[3]={0,0,75};
double direction1[ 3 ] = { 0.0, 0.0, -1 };
double d2_1=ceil((d*k+1.25)*2)/2;
char d2;

//Extrude声明
//int face_num=1;

//Boolean声明
int num_result=0;
tag_t *resulting_bodies=NULL;

//主体框架
UF_MODL_create_cyl1(sign, origin,"9","45",dir, &cyl_obj_id );
UF_MODL_ask_feat_faces(cyl_obj_id,&boss_list);
UF_MODL_ask_list_item(boss_list,1,&face);
UF_MODL_create_boss(location,dir,"32","25","0",face,&boss_obj_id);
//Boolen
//UF_MODL_subtract_bodies(cyl_obj_id,boss_obj_id,&num_result,&resulting_bodies );

//创建沉头孔
UF_MODL_ask_list_item(boss_list,0,&face_li);
UF_MODL_delete_list( &boss_list );
UF_MODL_create_c_bore_hole(origin,dir,"12","24","20","1","90",face_li,face_t1,&hole_bot_id);
//Chamfer

//Line&&Extrude0

//L1    
    sline1.start_point[0] =ceil(ic*k/2*1000)/1000-j;
    sline1.start_point[1] =-ceil(ic*k/2*tan(ang*PI/180/2)*1000)/1000+j;
    sline1.start_point[2] = 0.0;
    sline1.end_point[0] =-ceil(ic*k/2*1000)/1000+j;
    sline1.end_point[1] = -ceil(ic*k/2/tan(ang*PI/180/2)*1000)/1000+j;
    sline1.end_point[2] = 0.0;
    UF_CURVE_create_line(&sline1,&line1);
    //L2
    sline2.start_point[0] =-ceil(ic*k/2*1000)/1000+j;
    sline2.start_point[1] =-ceil(ic*k/2/tan(ang*PI/180/2)*1000)/1000+j;
    sline2.start_point[2] = 0.0;
    sline2.end_point[0] =-ceil(ic*k/2*1000)/1000+j;
    sline2.end_point[1] =ceil(ic*k/2*tan(ang*PI/180/2)*1000)/1000-j;
    sline2.end_point[2] = 0.0;
    UF_CURVE_create_line(&sline2,&line2);
    //L3
    sline3.start_point[0] =-ceil(ic*k/2*1000)/1000+j;
    sline3.start_point[1] =ceil(ic*k/2*tan(ang*PI/180/2)*1000)/1000-j;
    sline3.start_point[2] = 0.0;
    sline3.end_point[0] =ceil(ic*k/2*1000)/1000-j;
    sline3.end_point[1] =ceil(ic*k/2/tan(ang*PI/180/2)*1000)/1000-j;
    sline3.end_point[2] = 0.0;
    UF_CURVE_create_line(&sline3,&line3);
    //L4
    sline4.start_point[0] =ceil(ic*k/2*1000)/1000-j;
    sline4.start_point[1] =ceil(ic*k/2/tan(ang*PI/180/2)*1000)/1000-j;
    sline4.start_point[2] = 0.0;
    sline4.end_point[0] =ceil(ic*k/2*1000)/1000-j;
    sline4.end_point[1] =-ceil(ic*k/2*tan(ang*PI/180/2)*1000)/1000+j;
    sline4.end_point[2] = 0.0;
    UF_CURVE_create_line(&sline4,&line4);

    /* 把四根线的tag放组 */
    generators[0] = line1;
    generators[1] = line2;
    generators[2] = line3;
    generators[3] = line4;
    /* 把四根线的tag放入数组 */
    generators[0] = line1;
    generators[1] = line2;
    generators[2] = line3;
    generators[3] = line4;
    /* 创建一个链表,以存放扫描的截面线串 */
    UF_MODL_create_list( &objects );    
    for ( i = 0; i < 4; i++ )
    {
        UF_MODL_put_list_item( objects, generators[ i ] );
    }

    //Extrude0
    UF_MODL_SWEEP_TRIM_object_p_t trim_data=NULL;
    tag_t *objects_e;
    char *tape_angle="0";

    char *offsets[2]      = {"0.0", "0.0"};

double region_point[ 3 ]={0,0,0};
int obj_cnt,face_num=4;
UF_MODL_create_extrusion(generators,face_num,trim_data,tape_angle,limit1,offsets,region_point,false,true,
dir,sign,&objects_e,&obj_cnt);

    UF_free(objects_e);
    //UF_MODL_create_extruded( objects, taper_angle, limit1,point, direction, sign_ex, &features );
    //UF_MODL_delete_list( &objects );
    
    
    //hole3
    //声明
    UF_UI_selection_p_t select_=NULL;
    tag_p_t * objs=NULL ;
    int * count=0;
    //UF_MODL_ask_feat_faces(features,&boss_list);
    //UF_MODL_create_list(&features);
    //UF_FACET_ask_face_id_of_solid_face(features[0], );
    UF_UI_ask_sel_object_list(select_,count,objs);//~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~☆
    UF_free(objs);
    ///*
    UF_MODL_ask_list_item(features,0,&face_d2);
    UF_MODL_ask_list_item(features,1,&face_t2);
    UF_MODL_delete_list( &features );
    gcvt(d2_1,3,&d2);
    UF_MODL_create_simple_hole(origin2,direction1,"d2","70","120",face_d2,face_t2,&hole_2);
    //*/

    //Extrude1
    //L1    
    sline1.start_point[0] =ceil(ic*k/2*1000)/1000;
    sline1.start_point[1] =-ceil(ic*k/2*tan(ang*PI/180/2)*1000)/1000;
    sline1.start_point[2] = 0.0;
    sline1.end_point[0] =-ceil(ic*k/2*1000)/1000;
    sline1.end_point[1] = -ceil(ic*k/2/tan(ang*PI/180/2)*1000)/1000;
    sline1.end_point[2] = 0.0;
    UF_CURVE_create_line(&sline1,&line1);
    //L2
    sline2.start_point[0] =-ceil(ic*k/2*1000)/1000;
    sline2.start_point[1] =-ceil(ic*k/2/tan(ang*PI/180/2)*1000)/1000;
    sline2.start_point[2] = 0.0;
    sline2.end_point[0] =-ceil(ic*k/2*1000)/1000;
    sline2.end_point[1] =ceil(ic*k/2*tan(ang*PI/180/2)*1000)/1000;
    sline2.end_point[2] = 0.0;
    UF_CURVE_create_line(&sline2,&line2);
    //L3
    sline3.start_point[0] =-ceil(ic*k/2*1000)/1000;
    sline3.start_point[1] =ceil(ic*k/2*tan(ang*PI/180/2)*1000)/1000;
    sline3.start_point[2] = 0.0;
    sline3.end_point[0] =ceil(ic*k/2*1000)/1000;
    sline3.end_point[1] =ceil(ic*k/2/tan(ang*PI/180/2)*1000)/1000;
    sline3.end_point[2] = 0.0;
    UF_CURVE_create_line(&sline3,&line3);
    //L4
    sline4.start_point[0] =ceil(ic*k/2*1000)/1000;
    sline4.start_point[1] =ceil(ic*k/2/tan(ang*PI/180/2)*1000)/1000;
    sline4.start_point[2] = 0.0;
    sline4.end_point[0] =ceil(ic*k/2*1000)/1000;
    sline4.end_point[1] =-ceil(ic*k/2*tan(ang*PI/180/2)*1000)/1000;
    sline4.end_point[2] = 0.0;
    UF_CURVE_create_line(&sline4,&line4);

    /* 把四根线的tag放组 */
    generators[0] = line1;
    generators[1] = line2;
    generators[2] = line3;
    generators[3] = line4;
    /* 把四根线的tag放入数组 */
    generators[0] = line1;
    generators[1] = line2;
    generators[2] = line3;
    generators[3] = line4;
    /* 创建一个链表,以存放扫描的截面线串 */
    
    UF_MODL_create_list( &objects );    
    for ( i = 0; i < 4; i++ )
    {
        UF_MODL_put_list_item( objects, generators[ i ] );
    }
    
    
    
    UF_MODL_create_extruded( objects, taper_angle, limit,point, direction, sign_ex, &features1 );
    UF_MODL_delete_list( &objects );
    
    
    /*test_temporary
    UF_UI_open_listing_window();
    sprintf(text,"%f",tan(ang*PI/180/2));
    UF_UI_write_listing_window(text);*/
    
    //Hole






/* 设置视图 */
UF_VIEW_ask_work_view( &view_tag );
UF_VIEW_ask_visualization( view_tag, &view_data );
UF_VIEW_fit_view( view_tag, 0.3 );
view_data.display_mode = UF_VIEW_FULLY_SHADED;
UF_VIEW_set_visualization( view_tag, &view_data );
UF_VIEW_rotate_view( view_tag, view_rotate_axis,
                    view_rotate_delta_angle, view_rotate_time );
view_rotate_axis[0] = -1.0;
view_rotate_axis[2] = 0.0;
UF_VIEW_rotate_view( view_tag, view_rotate_axis,
    view_rotate_delta_angle, view_rotate_time );
UF_VIEW_fit_view( view_tag, 0.7 );
UF_LAYER_set_all_but_work( UF_LAYER_INACTIVE_LAYER );

    /* 保存部件文件 */
    UF_PART_save( );
    UF_terminate();
/* Terminate the API environment */
UF_CALL(UF_terminate());

}
extern int ufusr_ask_unload (void)
{
/* 设置UF程序运行以后立刻从内存中卸除,即当重新修改、编译成新的DLL文件时,UG无须关闭重启动,就可调用此新的*.DLL文件 */
return (UF_UNLOAD_IMMEDIATELY);

}
/*****************************************************************************
** Utilities
*****************************************************************************/

/* Unload Handler
** This function specifies when to unload your application from Unigraphics.
** If your application registers a callback (from a MenuScript item or a
** User Defined Object for example), this function MUST return
** "UF_UNLOAD_UG_TERMINATE". /
/
extern int ufusr_ask_unload( void )
{
return( UF_UNLOAD_UG_TERMINATE );
}

*/

最后编辑于
©著作权归作者所有,转载或内容合作请联系作者
  • 序言:七十年代末,一起剥皮案震惊了整个滨河市,随后出现的几起案子,更是在滨河造成了极大的恐慌,老刑警刘岩,带你破解...
    沈念sama阅读 205,236评论 6 478
  • 序言:滨河连续发生了三起死亡事件,死亡现场离奇诡异,居然都是意外死亡,警方通过查阅死者的电脑和手机,发现死者居然都...
    沈念sama阅读 87,867评论 2 381
  • 文/潘晓璐 我一进店门,熙熙楼的掌柜王于贵愁眉苦脸地迎上来,“玉大人,你说我怎么就摊上这事。” “怎么了?”我有些...
    开封第一讲书人阅读 151,715评论 0 340
  • 文/不坏的土叔 我叫张陵,是天一观的道长。 经常有香客问我,道长,这世上最难降的妖魔是什么? 我笑而不...
    开封第一讲书人阅读 54,899评论 1 278
  • 正文 为了忘掉前任,我火速办了婚礼,结果婚礼上,老公的妹妹穿的比我还像新娘。我一直安慰自己,他们只是感情好,可当我...
    茶点故事阅读 63,895评论 5 368
  • 文/花漫 我一把揭开白布。 她就那样静静地躺着,像睡着了一般。 火红的嫁衣衬着肌肤如雪。 梳的纹丝不乱的头发上,一...
    开封第一讲书人阅读 48,733评论 1 283
  • 那天,我揣着相机与录音,去河边找鬼。 笑死,一个胖子当着我的面吹牛,可吹牛的内容都是我干的。 我是一名探鬼主播,决...
    沈念sama阅读 38,085评论 3 399
  • 文/苍兰香墨 我猛地睁开眼,长吁一口气:“原来是场噩梦啊……” “哼!你这毒妇竟也来了?” 一声冷哼从身侧响起,我...
    开封第一讲书人阅读 36,722评论 0 258
  • 序言:老挝万荣一对情侣失踪,失踪者是张志新(化名)和其女友刘颖,没想到半个月后,有当地人在树林里发现了一具尸体,经...
    沈念sama阅读 43,025评论 1 300
  • 正文 独居荒郊野岭守林人离奇死亡,尸身上长有42处带血的脓包…… 初始之章·张勋 以下内容为张勋视角 年9月15日...
    茶点故事阅读 35,696评论 2 323
  • 正文 我和宋清朗相恋三年,在试婚纱的时候发现自己被绿了。 大学时的朋友给我发了我未婚夫和他白月光在一起吃饭的照片。...
    茶点故事阅读 37,816评论 1 333
  • 序言:一个原本活蹦乱跳的男人离奇死亡,死状恐怖,灵堂内的尸体忽然破棺而出,到底是诈尸还是另有隐情,我是刑警宁泽,带...
    沈念sama阅读 33,447评论 4 322
  • 正文 年R本政府宣布,位于F岛的核电站,受9级特大地震影响,放射性物质发生泄漏。R本人自食恶果不足惜,却给世界环境...
    茶点故事阅读 39,057评论 3 307
  • 文/蒙蒙 一、第九天 我趴在偏房一处隐蔽的房顶上张望。 院中可真热闹,春花似锦、人声如沸。这庄子的主人今日做“春日...
    开封第一讲书人阅读 30,009评论 0 19
  • 文/苍兰香墨 我抬头看了看天上的太阳。三九已至,却和暖如春,着一层夹袄步出监牢的瞬间,已是汗流浃背。 一阵脚步声响...
    开封第一讲书人阅读 31,254评论 1 260
  • 我被黑心中介骗来泰国打工, 没想到刚下飞机就差点儿被人妖公主榨干…… 1. 我叫王不留,地道东北人。 一个月前我还...
    沈念sama阅读 45,204评论 2 352
  • 正文 我出身青楼,却偏偏与公主长得像,于是被迫代替她去往敌国和亲。 传闻我的和亲对象是个残疾皇子,可洞房花烛夜当晚...
    茶点故事阅读 42,561评论 2 343

推荐阅读更多精彩内容