点击查看详细介绍

创建型腔和孔代码 精华帖

pooltool 9年前 6479 38

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


//创建型腔和孔
#include <stdio.h>
#include <uf.h>
#include <uf_modl.h>
#include <uf_ui.h>
#include <malloc.h>
/*定义全局变量,用于转递相对定位的目标边*/
tag_t   edge_blk[12];
tag_t   edge_blend[4];
/*注册型腔定位的用户函数*/
int rpo_routine_pocket(tag_t obj_id)
{
        int irc=0,i;
        uf_list_p_t  edge_list;
        int count_list;
        tag_t   tem_tag,*edge_pock;
        edge_pock=(tag_t *)malloc(12*sizeof(tag_t));
        
        tag_t *obj_id_target,*obj_id_tool; 
        obj_id_target=(tag_t *)malloc(3*sizeof(tag_t));
        obj_id_tool=(tag_t *)malloc(3*sizeof(tag_t));
        char *constraint_value[]={"0.0","0.0"};
        char *constraint_array[]={"PARA_EDGE_PARMS","PARA_EDGE_PARMS"};
        int target_qualifier[]={UF_MODL_ENDPOINT_1,UF_MODL_ENDPOINT_1};
        int tool_qualifier[]={UF_MODL_ENDPOINT_1,UF_MODL_ENDPOINT_1};
        
        UF_MODL_ask_feat_edges(obj_id,&edge_list );
        UF_MODL_ask_list_count(edge_list,&count_list);        
        for (i=0;i<count_list;i++)
{
                UF_MODL_ask_list_item(edge_list,i,&tem_tag);
                edge_pock=tem_tag;
        }
        UF_MODL_delete_list(&edge_list);
        
        obj_id_tool[0]=edge_pock[0];
        obj_id_tool[1]=edge_pock[4];
        
        obj_id_target[0]=edge_blk[1];
        obj_id_target[1]=edge_blk[0];
        
irc=UF_MODL_create_rpo_constraints(obj_id,NULL_TAG,NULL_TAG,obj_id_target,
                target_qualifier,obj_id_tool,tool_qualifier,constraint_value,constraint_array,2);
        
        free(edge_pock);
        free(obj_id_target);
        free(obj_id_tool);
        
        if (irc == 0)
        return (0);
    else
        return (1);
}
//孔定位的用户函数
int rpo_routine_hole(tag_t obj_id)
{
    int irc,i;
    int count_list;
    tag_t   tem_tag;        
    tag_t   edge_tool[5];
    uf_list_p_t  edge_list;

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

    obj_id_target[0]=edge_blend[2];
    obj_id_tool[0]=edge_tool[1];
irc=UF_MODL_create_rpo_constraints(obj_id,NULL_TAG,NULL_TAG,obj_id_target,
        target_qualifier,obj_id_tool,tool_qualifier,constraint_value,constraint_array,1);
if (irc == 0)
        return (0);
    else
        return (1);
}
/*UG/OPEN API内部环境的入口函数*/
void ufusr(char *param, int *retcode, int paramLen)
{
        if (!UF_initialize())
        {
                /*定义创建块的参数*/
                UF_FEATURE_SIGN sign = UF_NULLSIGN;
                double block_orig[3] = {0.0,0.0,0.0};
                char *block_len[3] = {"100","60","40"};
                tag_t blk_fea,blk_obj,tem_tag,face_blk[6];
                uf_list_p_t face_list,edge_list;
                int count_list;
                int i;        
                
                /*定义创建型腔的参数*/
                double pock_loc[3] = {25.0,30.0,40.0};
                double pock_dir[3] = {0.0,0.0,-1.0}; 
                double pock_x_dir[3]= {1.0,0.0,0.0};
                char *pock_len[3]={"50.0","40.0","20.0"};
                char *pock_corner={"0.0"};
                char *pock_floor={"0.0"}; 
                char *pock_angle={"0.0"}; 
                tag_t pock_id; 
                
                /*定义创建边倒圆的参数*/
                char *blend_radius="20.0";
                uf_list_p_t blend_list,blend_edge_list;
                tag_t blend_id;
                
                /*定义创建孔的参数*/
                double  hole_origin[3] = {60.0,30.0,40.0};
                double  hole_cyl_dir[3] = {0.0,0.0,-1.0};
                char    *hole_dia = "25.0";
                char    *hole_height = "5.0";
                char    *hole_angle = "0.0";
                tag_t hole_id;
                
                /*创建块*/
                UF_MODL_create_block1(sign, block_orig, block_len, &blk_fea);
                UF_MODL_ask_feat_body(blk_fea,&blk_obj);
                
                /*获得块上面的标识,用于确定成型特征的孔和型腔安置面,
                以及孔的穿透面*/
                UF_MODL_ask_body_faces(blk_obj,&face_list);
                UF_MODL_ask_list_count(face_list,&count_list);           
                for (i=0;i<count_list;i++)
{
                        UF_MODL_ask_list_item(face_list,i,&tem_tag);
                        face_blk=tem_tag;
                }
                UF_MODL_delete_list(&face_list);
                
                /*获得块上边的标识,用于相对定位*/
                UF_MODL_ask_body_edges(blk_obj,&edge_list);
                UF_MODL_ask_list_count(edge_list,&count_list);           
                for (i=0;i<count_list;i++)
{
                        UF_MODL_ask_list_item(edge_list,i,&tem_tag);
                        edge_blk=tem_tag;
                }
                UF_MODL_delete_list(&edge_list);
                
                /*创建型腔,并进行相对定位*/
                UF_MODL_register_rpo_routine(rpo_routine_pocket); 
                UF_MODL_create_rect_pocket(pock_loc,pock_dir,pock_x_dir,pock_len,
                        pock_corner,pock_floor,pock_angle,face_blk[0],&pock_id );
                UF_MODL_unregister_rpo_routine();
                
                /*进行边倒圆*/
                UF_MODL_create_list(&blend_list);
                UF_MODL_put_list_item(blend_list,edge_blk[6]);
                UF_MODL_create_blend(blend_radius,blend_list,0,0,0,0.5,&blend_id);
                
                /*获取倒圆的边,用于孔的相对定位*/
                UF_MODL_ask_feat_edges(blend_id,&blend_edge_list);
                UF_MODL_ask_list_count(blend_edge_list,&count_list);           
                for (i=0;i<count_list;i++)
{
                        UF_MODL_ask_list_item(blend_edge_list,i,&tem_tag);
                        edge_blend=tem_tag;
                }
                UF_MODL_delete_list(&blend_edge_list);
                
                /*创建孔,并进行相对定位*/
                UF_MODL_register_rpo_routine(rpo_routine_hole);        
                UF_MODL_create_simple_hole(hole_origin,hole_cyl_dir,hole_dia,
                        hole_height,hole_angle,face_blk[0],face_blk[1],&hole_id);                
                UF_MODL_unregister_rpo_routine();
                
                UF_terminate();
        }
}


2

最新回复 (38)
  • lxiaoj111 VIP会员 9年前
    1

    下来看看,希望是我要的源码

  • ahqqqq22 9年前
    2

    禾禾禾禾禾禾禾禾禾禾禾tt

  • zzhug 8年前
    3

    下来看看,希望是我要的源码

  • q1355188058 8年前
    4

    看看内容怎样,学习中

  • wucrew 8年前
    5

    谢谢分享,学习,辛苦了

  • y18408284447 8年前
    6

    正在学习中,希望可以运行。

  • jiaming090 8年前
    7

    谢谢分享 万分感谢

  • xiaobai 8年前
    8

    看看内容怎样,学习中

  • huyongde 8年前
    9

    正在学习中, 谢谢

  • liu177459528 8年前
    10

    可以发现一些有价值的东西哦

  • h15824295982 8年前
    11

    很好很不错谢谢分享很好很不错谢谢分享

  • zhixiang 8年前
    12

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

  • zhizhuomsj 8年前
    13

    正在学习!!!!!!!!!顶顶顶顶顶顶顶顶顶顶顶顶

  • king_chinese VIP会员 8年前
    14

    创建型腔和孔代码

  • dodo 8年前
    15

    谢谢楼主分享,正在学习中

请登录后发表新帖