iCAx开思工具箱

 找回密码
 立即注册

QQ登录

只需一步,快速开始

查看: 23527|回复: 3
打印 上一主题 下一主题

UG 虚拟自动装配问题,等待大侠啊

[复制链接]
跳转到指定楼层
楼主
发表于 2013-1-3 02:16:18 | 只看该作者 回帖奖励 |倒序浏览 |阅读模式

马上注册登录,享用更多网站功能!

您需要 登录 才可以下载或查看,没有帐号?立即注册

x
各位大侠,小弟在做UG虚拟自动装配。首先小弟将零件加载的新建的装配文件中,然后查找加载进来的零件的tag,然后填充装配约束,可装配的时候遇到问题,问题见下面的代码。望大侠不吝赐教啊,小弟感激不尽。我先加载一个零件通过UF_ASSEM_ask_parent_component得到to_part_occ,再加载第二个零件也通过这个函数得到from_part_occ,但得到的这两的tag值都是0,不知为何啊???????肯定是这两个值为0才了装配不成功的。
求大侠赐教啊{:soso_e163:}{:soso_e163:}{:soso_e163:}{:soso_e163:},问题解决后小弟定当感谢

UF_PART_new(part_name,1,&WorkPart);

UF_PART_load_status_t error_status;
char PrtPath[]="D:\\azt\\prt\\model6.prt";
char RefsetName[]="";
char InstanceName[]="";
double Origin[3]={0,0,0};
double CsysMatrix[6]={1,0,0,0,1,0};
tag_t tInsPart;
UF_ASSEM_add_part_to_assembly(WorkPart,PrtPath,RefsetName,InstanceName,
Origin,CsysMatrix,-1,&tInsPart,&error_status);
UF_free_string_array(error_status.n_parts,error_status.file_names);

tag_t part_tag;
part_tag=UF_PART_ask_part_tag(PrtPath);
tag_t first_plan;
int count=0;
tag_t FeaTag=NULL_TAG;
uf_list_p_t face_list=NULL;
uf_list_p_t p1=NULL;
int type=UF_solid_type;
UF_OBJ_cycle_objs_in_part(part_tag,type,&FeaTag);  
while(FeaTag!=NULL_TAG)
{
  UF_MODL_ask_body_faces(FeaTag,&face_list);
  UF_MODL_ask_list_count(face_list,&count);
  p1=face_list;
  do
  {
   int type2,norm_dir;
   double center[3],dir[3],box[6],radius,rad_data;
   UF_MODL_ask_face_data(p1->eid,&type2,center,dir,box,&radius,&rad_data,&norm_dir);
   if(type2==UF_cylinder_type&&radius==5)
   {
    first_plan=p1->eid;
   }
   p1=p1->next;
  }while(p1!=NULL);
}
UF_DISP_set_highlight(first_plan,1);
UF_MODL_delete_list(&face_list);

int ret;
tag_t to_part_occ;
UF_ASSEM_ask_parent_component(first_plan,&to_part_occ); //得到的to_part_occ的值是0,这是为何啊啊??
int b=0;
b=UF_ASSEM_is_occurrence(to_part_occ); //这句运行后,得到的值是0,说明不是occ类型啊

/*------------ 加载第一个部件 -----------*/

    /*char PrtFromPath[]="D:\\azt\\prt\\model6.prt";
    char sRefsetName[]="";
    char sInstanceName[]="";
    double adOrigin[3]={0,0,0};
    double adCsysMatrix[6]={1,0,0,0,1,0};
    tag_t tInsPartFrom;
UF_ASSEM_add_part_to_assembly(WorkPart,PrtFromPath,sRefsetName,sInstanceName,
  adOrigin,adCsysMatrix,-1,&tInsPartFrom,&error_status);

tag_t from_tag;
from_tag=UF_PART_ask_part_tag(PrtFromPath);
tag_t second_plan;
tag_t ff_tag=NULL_TAG;
int from_type=UF_solid_type;
uf_list_p_t from_list=NULL;
UF_OBJ_cycle_objs_in_part(from_tag,from_type,&ff_tag);
while(ff_tag!=NULL_TAG)
{
UF_MODL_ask_body_faces(ff_tag,&from_list);
UF_MODL_ask_list_count(from_list,&count);
p1=from_list;
int type3,norm_dir1;
double center1[3],dir1[3],box1[6],radius1,rad_data1;
UF_MODL_ask_face_data(p1->eid,&type3,center1,dir1,box1,&radius1,&rad_data1,&norm_dir1);
if(type3==UF_cylinder_type&&radius1==5)
{
  second_plan=p1->eid;
}
p1=p1->next;
  }while(p1!=NULL);
  UF_OBJ_cycle_objs_in_part(from_tag,from_type,&ff_tag);
}
UF_DISP_set_highlight(second_plan,1);
tag_t from_part_occ;
ret=UF_ASSEM_ask_parent_component(second_plan,&from_part_occ);
tag_t from_part_ins;
from_part_ins=UF_ASSEM_ask_inst_of_part_occ(from_part_occ);
   
//定义匹配条件
UF_ASSEM_mating_condition_t ftf;
UF_ASSEM_init_mc (&ftf);
ftf.mated_object=from_part_ins;
ftf.name=NULL;
ftf.user_name=FALSE;
ftf.constraints[0].from_status=UF_ASSEM_ok;
ftf.constraints[0].to_status=UF_ASSEM_ok;
ftf.constraints[0].mate_type=UF_ASSEM_v16_mate;
//ftf.constraints[0].sub_type=UF_ASSEM_planar_angle;
ftf.constraints[0].offset=NULL_TAG;
ftf.constraints[0].from_type=UF_ASSEM_cylindrical_face;
ftf.constraints[0].to_type=UF_ASSEM_cylindrical_face;
ftf.constraints[0].from=UF_ASSEM_ask_prototype_of_occ(first_plan);//这里填错了,写成了from_part_occ
ftf.constraints[0].from_part_occ=from_part_occ;
ftf.constraints[0].to=UF_ASSEM_ask_prototype_of_occ(second_plan);
ftf.constraints[0].to_part_occ=to_part_occ;
ftf.constraints[0].name="";
ftf.constraints[0].user_name=TRUE;
ftf.num_constraints=1;
ftf.suppressed=FALSE;

//求解匹配条件
UF_ASSEM_mc_status_t status;
UF_ASSEM_dof_t dof;
double transform[4][4];

ret=UF_ASSEM_solve_mc(&ftf,&status,&dof,transform);
if(status==UF_ASSEM_mc_solved)
{
uc1601("求解成功",1);
}
sprintf(tt,"%d",ret);
UF_UI_open_listing_window();
UF_UI_write_listing_window(tt);
UF_UI_write_listing_window("\n");

//应用匹配条件
if(ret==0||status==UF_ASSEM_mc_solved)
{
UF_ASSEM_mc_structure_state_t struct_status;
ret=UF_ASSEM_apply_mc_data(&ftf,&struct_status,&status);
}

//更新模型
UF_DISP_refresh();
UF_MODL_update();
分享到:  QQ好友和群QQ好友和群 QQ空间QQ空间 腾讯微博腾讯微博 腾讯朋友腾讯朋友
收藏收藏 分享淘帖 支持支持
沙发
 楼主| 发表于 2013-1-7 00:51:16 | 只看该作者

马上注册登录,享用更多网站功能!

您需要 登录 才可以下载或查看,没有帐号?立即注册

x
板凳
 楼主| 发表于 2013-1-7 00:53:58 | 只看该作者

马上注册登录,享用更多网站功能!

您需要 登录 才可以下载或查看,没有帐号?立即注册

x
地板
发表于 2013-8-28 09:11:25 | 只看该作者

马上注册登录,享用更多网站功能!

您需要 登录 才可以下载或查看,没有帐号?立即注册

x
您需要登录后才可以回帖 登录 | 立即注册

本版积分规则

手板模型制作,在线3D打印服务

QQ|小黑屋|手机版|开思工具箱 CAD工具箱_CAM工具箱  

GMT+8, 2024-5-2 10:39 , Processed in 0.013526 second(s), 9 queries , Gzip On, Redis On.

Powered by Discuz! X3.3

© 2002-2024 www.iCAx.org

快速回复 返回顶部 返回列表