|
马上注册登录,享用更多网站功能!
您需要 登录 才可以下载或查看,没有帐号?立即注册
x
下面这段代码是自动装配一上垫板与一上模板的程序,可却得不到我想要的结果,请高手帮忙调下,谢谢:
int CM1800_apply_cb ( int dialog_id,
void * client_data,
UF_STYLER_item_value_type_p_t callback_data)
{
int ret;
char * cface2="SHANGMOBAN_LCOL_FACE1";
char * cface3="SHANGMOBAN_LCOL_FACE2";
char * cface5="SHANGDIANBAN_LCOL_FACE1";
char * cface6="SHANGDIANBAN_LCOL_FACE2";
char * fface1="SHANGMOBAN_FLA_FACE";
char * fface3="SHANGDIANBAN_SFLA_FACE";
tag_t shang_lcplan1,shang_lcplan2,shang_fplan,
dian_lcplan1,dian_lcplan2,dian_sfplan;
tag_t from_part_occ;
tag_t to_part_occ;
tag_t from_part_ins;
tag_t to_part_ins;
logical is_occ;
tag_t from_part_occ1;
tag_t to_part_occ1;
tag_t from_part_ins1;
tag_t to_part_ins1;
tag_t flat_from_part_occ1;
tag_t flat_from_part_ins1;
tag_t flat_from_part_occ;
tag_t flat_to_part_occ;
tag_t flat_from_part_ins;
tag_t flat_to_part_ins;
/*提示所显示的实例的名称*/
char part_name[ 256 + 1 ];
char refset_name[ 30 + 1 ];
char instance_name[ 30 + 1 ];
double origin[ 3 ];
double csys_matrix[ 9 ];
double transform[ 4 ][ 4 ] ;
char message[133];
UF_ASSEM_mc_status_t status;
UF_ASSEM_mc_structure_state_t struct_status;
UF_ASSEM_dof_t dof;
UF_ASSEM_mating_condition_t ftf;
if ( UF_initialize() != 0)
return ( UF_UI_CB_CONTINUE_DIALOG );
shang_lcplan1=NULL_TAG;
shang_lcplan2=NULL_TAG;
shang_fplan=NULL_TAG;
dian_lcplan1=NULL_TAG;
dian_lcplan2=NULL_TAG;
dian_sfplan=NULL_TAG;
UF_OBJ_cycle_by_name(cface2, &shang_lcplan1);
UF_OBJ_cycle_by_name(cface3, &shang_lcplan2);
UF_OBJ_cycle_by_name(cface5, &dian_lcplan1);
UF_OBJ_cycle_by_name(cface6, &dian_lcplan2);
UF_OBJ_cycle_by_name(fface1, &shang_fplan);
UF_OBJ_cycle_by_name(fface3, &dian_sfplan);
ret=UF_ASSEM_ask_parent_component(dian_sfplan, &flat_from_part_occ);
is_occ=UF_ASSEM_is_occurrence(flat_from_part_occ);
flat_from_part_ins=UF_ASSEM_ask_inst_of_part_occ(flat_from_part_occ);
ret=UF_ASSEM_ask_component_data(flat_from_part_occ,part_name,refset_name,instance_name,
origin, csys_matrix, transform);
ret=UF_ASSEM_ask_parent_component(shang_fplan, &flat_to_part_occ);
flat_to_part_ins=UF_ASSEM_ask_inst_of_part_occ(flat_to_part_occ);
ret=UF_ASSEM_ask_component_data(flat_to_part_occ,part_name,refset_name,instance_name,
origin, csys_matrix, transform);
UF_ASSEM_init_mc (&ftf);
ftf.mated_object=flat_from_part_ins;
ftf.name=NULL;
ftf.user_name=FALSE;
ftf.suppressed=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].from_type=UF_ASSEM_planar_face; //定义为选取圆周面匹配
ftf.constraints[0].to_type=UF_ASSEM_planar_face; //定义为选取圆周面匹配
ftf.constraints[0].from=UF_ASSEM_ask_prototype_of_occ(dian_sfplan);//获取选取对象原型的tag
ftf.constraints[0].from_part_occ=flat_from_part_occ; //匹配对象的part occurrence的tag
ftf.constraints[0].to=UF_ASSEM_ask_prototype_of_occ(shang_dfplan);
ftf.constraints[0].to_part_occ=flat_to_part_occ;
ftf.constraints[0].offset=NULL_TAG; //定义距离,可利用表达式控制
ftf.constraints[0].name="plan to plan";
ftf.constraints[0].user_name=TRUE;
ftf.num_constraints = 1;
ret=UF_ASSEM_solve_mc (&ftf, &status, &dof, transform);//条件计算
UF_get_fail_message (ret,message);
if (ret==0||status==UF_ASSEM_mc_solved)
{
ret=UF_ASSEM_apply_mc_data (&ftf, &struct_status, &status);//执行匹配
UF_DISP_refresh();
UF_MODL_update();
}
ret=UF_ASSEM_ask_parent_component(dian_lcplan1, &from_part_occ); //获取父标志
is_occ=UF_ASSEM_is_occurrence(from_part_occ); //确定父标志类型
from_part_ins=UF_ASSEM_ask_inst_of_part_occ(from_part_occ); //获取part occurrence中instance的tag
ret=UF_ASSEM_ask_component_data(from_part_occ,part_name,refset_name,instance_name,
origin, csys_matrix, transform);
ret=UF_ASSEM_ask_parent_component(shang_lcplan1, &to_part_occ);
to_part_ins=UF_ASSEM_ask_inst_of_part_occ(to_part_occ);
ret=UF_ASSEM_ask_component_data(to_part_occ,part_name,refset_name,instance_name,
origin, csys_matrix, transform);
UF_ASSEM_init_mc (&ftf);
ftf.mated_object=from_part_ins;
ftf.name=NULL;
ftf.user_name=FALSE;
ftf.suppressed=FALSE;
ftf.constraints[0].from_status=UF_ASSEM_ok;
ftf.constraints[0].to_status=UF_ASSEM_ok;
ftf.constraints[0].mate_type=UF_ASSEM_align; //选择同轴匹配类型
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(dian_lcplan1);
ftf.constraints[0].from_part_occ=from_part_occ;
ftf.constraints[0].to=UF_ASSEM_ask_prototype_of_occ(shang_lcplan1);
ftf.constraints[0].to_part_occ=to_part_occ;
ftf.constraints[0].offset=NULL_TAG;
ftf.constraints[0].name="center to center";
ftf.constraints[0].user_name=TRUE;
ftf.constraints[0].sub_type=UF_ASSEM_center_1_to_1; //选取角度和同轴对齐的适当子类型
ftf.num_constraints = 1;
ret=UF_ASSEM_solve_mc (&ftf, &status, &dof, transform);//条件计算
UF_get_fail_message (ret,message);
if (ret==0||status==UF_ASSEM_mc_solved)
{
ret=UF_ASSEM_apply_mc_data (&ftf, &struct_status, &status);//执行匹配
UF_DISP_refresh();
UF_MODL_update();
}
ret=UF_ASSEM_ask_parent_component(dian_lcplan2, &from_part_occ); //获取父标志
is_occ=UF_ASSEM_is_occurrence(from_part_occ); //确定父标志类型
from_part_ins=UF_ASSEM_ask_inst_of_part_occ(from_part_occ); //获取part occurrence中instance的tag
ret=UF_ASSEM_ask_component_data(from_part_occ,part_name,refset_name,instance_name,
origin, csys_matrix, transform);
ret=UF_ASSEM_ask_parent_component(shang_lcplan2, &to_part_occ);
to_part_ins=UF_ASSEM_ask_inst_of_part_occ(to_part_occ);
ret=UF_ASSEM_ask_component_data(to_part_occ,part_name,refset_name,instance_name,
origin, csys_matrix, transform);
UF_ASSEM_init_mc (&ftf);
ftf.mated_object=from_part_ins;
ftf.name=NULL;
ftf.user_name=FALSE;
ftf.suppressed=FALSE;
ftf.constraints[0].from_status=UF_ASSEM_ok;
ftf.constraints[0].to_status=UF_ASSEM_ok;
ftf.constraints[0].mate_type=UF_ASSEM_align; //选择同轴匹配类型
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(dian_lcplan2);
ftf.constraints[0].from_part_occ=from_part_occ;
ftf.constraints[0].to=UF_ASSEM_ask_prototype_of_occ(shang_lcplan2);
ftf.constraints[0].to_part_occ=to_part_occ;
ftf.constraints[0].offset=NULL_TAG;
ftf.constraints[0].name="center to center";
ftf.constraints[0].user_name=TRUE;
ftf.constraints[0].sub_type=UF_ASSEM_center_1_to_1; //选取角度和同轴对齐的适当子类型
ftf.num_constraints = 1;
ret=UF_ASSEM_solve_mc (&ftf, &status, &dof, transform);//条件计算
UF_get_fail_message (ret,message);
if (ret==0||status==UF_ASSEM_mc_solved)
{
ret=UF_ASSEM_apply_mc_data (&ftf, &struct_status, &status);//执行匹配
UF_DISP_refresh();
UF_MODL_update();
}
UF_terminate ();
/* Callback acknowledged, do not terminate dialog */
/* A return value of UF_UI_CB_EXIT_DIALOG will not be accepted */
/* for this callback type. You must respond to your apply button.*/
return (UF_UI_CB_CONTINUE_DIALOG);
}
可用手动按这个顺序装却没问题
E:\1.BMP
这是用手动装配好的图 |
-
-
part.rar
151.41 KB, 下载次数: 23, 下载积分: 贡献 -2
零件
|