QQ登录

只需一步,快速开始

快捷登录

登录 或者 注册 请先

UG爱好者

查看: 1590|回复: 1
打印 上一主题 下一主题

[悬赏] UG二次开发出问题了 求解有偿300

[复制链接]

二级士官

Rank: 2

1

主题

14

帖子

424

积分
跳转到指定楼层
楼主
发表于 2016-5-13 21:36:04 | 只看该作者 回帖奖励 |倒序浏览 |阅读模式
从网上找的一个源代码,当模型是单个部件时可以到出x_t格式。我的是汽车风洞模型,可以更新prt,但是导不出x_t。我的汽车和风洞模型都是片体,请高手帮忙看看是哪里出了问题,谢谢了!

#include <iostream>
#include <string>
#include <uf.h>
#include <uf_modl.h>
#include <uf_ps.h>
#include <uf_obj.h>
#include <uf_assem.h>
#include <uf_part.h>
#include <uf_modl_expressions.h>
using namespace std;
int  prt_save_as_xt(tag_t,string ps);

//引入lib文件,因人而异
#pragma  comment(lib,"D:\\Program Files\\Siemens\\NX 9.0\\UGOPEN\\libufun.lib")
#define VISUALSAN_NUAA_202_RUN(x)\
if(0!=x)\
{\
    char msg[133];\
    UF_get_fail_message( x,msg );\
    cout<<msg;\
    return -1;\
}

int  main(int argc,char **argv)
{
    VISUALSAN_NUAA_202_RUN( UF_initialize() );
    string  prt,ep;
    string  x_t;//x_t格式文件地址
    if( argc<3 )
    {
        cerr<<"参数个数不足";
        return  -1;
    }
    if(argc==3)
    {
        prt = argv[0];  //prt文件
        ep  = argv[1];  //exp文件
        x_t = argv[2]; //x_t文件
    }
    else
    {
        prt = argv[1]; //prt文件
        ep  = argv[2]; //exp文件
        x_t = argv[3]; //x_t文件
    }
    UF_PART_load_status_t st;
    tag_t  prt_id;
    VISUALSAN_NUAA_202_RUN( UF_PART_open( prt.c_str(), &prt_id, &st ) );
    VISUALSAN_NUAA_202_RUN( UF_MODL_import_exp( (char*)ep.c_str() , 0) );
    VISUALSAN_NUAA_202_RUN( UF_MODL_update() );
    VISUALSAN_NUAA_202_RUN( UF_PART_save() );
    if( -1 == prt_save_as_xt(prt_id,x_t) )
        return -1;
    VISUALSAN_NUAA_202_RUN( UF_PART_close(prt_id,1,1) );
    VISUALSAN_NUAA_202_RUN( UF_PART_free_load_status(&st) );
    VISUALSAN_NUAA_202_RUN( UF_terminate() );

    return 0;
}
int  prt_save_as_xt(tag_t body_tag,string ps)
{
    if( std::string::npos == ps.find( ".x_t" ))
        ps += ".x_t";  
    uf_list_p_t body_list;
    // 获得装配树根事例root_part_occ, 当函数返回NULL_TAG时, 表明当前部件文件中没有装配(即单个部件)
    tag_t root_part_occ = UF_ASSEM_ask_root_part_occ( body_tag );
    VISUALSAN_NUAA_202_RUN( UF_MODL_create_list(&body_list) );
    // 如果是单个部件
    if(root_part_occ == NULL_TAG)
    {
        tag_t object = NULL_TAG;
        int UF_body_type;
        int type;
        int subtype;   
        do{
            VISUALSAN_NUAA_202_RUN(UF_OBJ_cycle_objs_in_part(body_tag, UF_solid_type, &object));
            if(object != NULL_TAG)
            {
                VISUALSAN_NUAA_202_RUN(UF_OBJ_ask_type_and_subtype(object, &type, &subtype));
                VISUALSAN_NUAA_202_RUN(UF_MODL_ask_body_type(object, &UF_body_type));

                if(subtype != UF_solid_body_subtype)
                    continue;
                if(UF_body_type == UF_MODL_SOLID_BODY)
                {
                    VISUALSAN_NUAA_202_RUN(UF_MODL_put_list_item(body_list, object));
                    break;
                }
            }
        }while(1);

    }
    //如果是装配体
    else
    {
        tag_t obj = UF_ASSEM_ask_prototype_of_occ(root_part_occ);
        tag_t object = NULL_TAG;
        int UF_body_type;
        int type;
        int subtype;
        do
        {
            VISUALSAN_NUAA_202_RUN(UF_OBJ_cycle_objs_in_part(body_tag, UF_solid_type, &object) );
            if(object != NULL_TAG)
            {
                VISUALSAN_NUAA_202_RUN(UF_OBJ_ask_type_and_subtype(object, &type, &subtype) );
                // 判断body是否是一个Solid或Sheet
                VISUALSAN_NUAA_202_RUN(UF_MODL_ask_body_type(object, &UF_body_type) );

                if(subtype != UF_solid_body_subtype)
                    continue;
                if(UF_body_type == UF_MODL_SOLID_BODY)
                {
                    // 将对象加入到链表的尾部
                    VISUALSAN_NUAA_202_RUN(UF_MODL_put_list_item(body_list, object) );
                }
            }
            else
            {
                break;
            }
        }while(1);
    }
    // 如果文件存在, 先删除
    remove( ps.c_str() );
    // 创建Parasolid文件
    VISUALSAN_NUAA_202_RUN(UF_PS_export_data(body_list,  (char*)ps.c_str() ) );
    // 删除链表
    VISUALSAN_NUAA_202_RUN(UF_MODL_delete_list(&body_list) );
    return 0;
}
本人联系方式13973386680,价格300,有意向者可以与我联系

有奖推广贴子: 

回复

使用道具 举报

二级士官

Rank: 2

1

主题

14

帖子

424

积分
沙发
 楼主| 发表于 2016-5-15 20:19:30 | 只看该作者
让人伤心啊,若大的一个论坛,难道是我的钱少了吗,还是。。。
回复 支持 反对

使用道具 举报

您需要登录后才可以回帖 登录 | 注册会员

本版积分规则

 
 
QQ:1359218528
工作时间:
9:00-17:00
 
微信公众号
手机APP
机械社区
微信小程序

手机版|UG爱好者论坛 ( 京ICP备10217105号-2 )    论坛管理员QQ:1359218528

本站信息均由会员发表,不代表本网站立场,如侵犯了您的权利请联系管理员,邮箱:1359218528@qq.com  

Powered by UG爱好者 X3.2  © 2001-2014 Comsenz Inc. GMT+8, 2024-6-23 16:49

返回顶部