iCAx开思工具箱
标题:
再没有人看要死人了!!!!!
[打印本页]
作者:
zhaobinbob
时间:
2005-4-13 21:23
标题:
再没有人看要死人了!!!!!
int ZB_action_peihe_cb ( int dialog_id,
void * client_data,
UF_STYLER_item_value_type_p_t callback_data)
{
/* Make sure User Function is available. */
if ( UF_initialize() != 0)
return ( UF_UI_CB_CONTINUE_DIALOG );
/* ---- Enter your callback code here ----- */
//选择两个平面
int errorCode;
char message[133];
message[0]='\0';
strcpy(message,"请选择第一个平面");
UF_UI_selection_options_t opts;
UF_UI_mask_t mask;
int response;
tag_t view;
double cursor[3];
int unhighlight=0;
opts.other_options=0;
opts.reserved=NULL;
opts.num_mask_triples=1;
opts.mask_triples=[$mask]
opts.mask_triples->object_type=UF_face_type;
opts.mask_triples->object_subtype=UF_bounded_plane_subtype;
opts.mask_triples->solid_type=UF_UI_SEL_FEATURE_ANY_FACE;
opts.scope=UF_UI_SEL_SCOPE_ANY_IN_ASSEMBLY;
int type;
double point[3];
double dir[3],box[6],radius,rad_data;
int norm_dir;
tag_t first_plan;
do
{
int irc=UF_UI_select_single(message,
[$opts,&response,&first_plan,cursor,&view)]
UF_MODL_ask_face_data(first_plan,&type,point,dir,
box,[$radius,&rad_data,&norm_dir)]
if(type!=22)
{
uc1601("请选择一个平面",1);
UF_DISP_set_highlight(first_plan,0);
}
}
while(!(type==22 [$&response==5))]
if(response!=5)
{
uc1601("没有选择平面",1);
UF_terminate();
}
int ret;
tag_t from_part_occ;
ret=UF_ASSEM_ask_parent_component(first_plan,[$from_part_occ)]
logical is_occ=UF_ASSEM_is_occurrence(from_part_occ);
tag_t from_part_ins=UF_ASSEM_ask_inst_of_part_occ(from_part_occ);
char part_name[133];
char refset_name[31];
char instance_name[31];
double origin[3];
double csys_matrix[9];
double transform[4][4];
ret=UF_ASSEM_ask_component_data(from_part_occ,part_name,
refset_name,instance_name,origin,csys_matrix,transform);
uc1601(instance_name,1);
message[0]='\0';
strcpy(message,"请选择第二个平面");
tag_t second_plan;
do
{
int irc=UF_UI_select_single(message,[$opts,&response,&second_plan,cursor,&view)]
UF_MODL_ask_face_data(second_plan,&type,point,dir,box,
[$radius,&rad_data,&norm_dir)]
if(type!=22)
{
uc1601("请选择另一个平面",1);
UF_DISP_set_highlight(first_plan,0);
}
}
while(!(type==22 [$& response==5))]
if(response!=5)
{
uc1601("没有选择平面",1);
UF_terminate();
}
tag_t to_part_occ;
ret=UF_ASSEM_ask_parent_component(second_plan,[$to_part_occ)]
tag_t 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);
uc1601(instance_name,1);
//构造配合关系
UF_ASSEM_mating_condition_t 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].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(first_plan);
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].offset=NULL_TAG;
ftf.constraints[0].name="face to face";
ftf.constraints[0].user_name=TRUE;
ftf.num_constraints=1;
ftf.suppressed=FALSE;
UF_ASSEM_mc_status_t status;
UF_ASSEM_mc_structure_state_t struct_status;
UF_ASSEM_dof_t dof;
ret=UF_ASSEM_init_mc([$ftf)]
UF_get_fail_message(ret,message);
uc1601(message,1);
ret=UF_ASSEM_solve_mc([$ftf,&status,&dof,transform)]
UF_get_fail_message(ret,message);
uc1601(message,1);
if(ret==0 || status==UF_ASSEM_mc_solved)
{
uc1601("成功配合",1);
ret=UF_ASSEM_apply_mc_data([$ftf,&struct_status,&status)]
UF_DISP_refresh();
UF_MODL_update();
}
else
uc1601("失败",1);
UF_DISP_set_highlight(first_plan,0);
UF_DISP_set_highlight(second_plan,0);
errorCode=UF_terminate();
UF_terminate ();
/* Callback acknowledged, do not terminate dialog */
return (UF_UI_CB_CONTINUE_DIALOG);
/* or Callback acknowledged, terminate dialog. */
/* return ( UF_UI_CB_EXIT_DIALOG ); */
}
作者:
zhaobinbob
时间:
2005-4-13 21:31
这段代码大家可能很熟悉吧,呵呵,我照着UG/OPEN API书上抄的,好像一点儿改动都没做,可是运行的时候提示出错,错误:UF_ASSEM_mating_condition_t结构初始化错误,提示调用UF_assem_init_mc( ),可我用上这个函数后,有提示:内存存取冲突,不知道怎么办了,谢谢帮忙啦!!
作者:
zzz
时间:
2005-4-14 09:16
mask没有初始化
作者:
zhaobinbob
时间:
2005-4-14 10:12
斑竹能不能说的详细一点儿,在那里做改动阿?我是个ug初学者,直接让我搞二次开发有点儿难度阿,好多基本的东西不会,可是我这是毕业设计内容,不做又没有办法,麻烦啦!!!
作者:
zzz
时间:
2005-4-14 21:58
UF_UI_mask_t mask[] =
{{UF_solid_type,
UF_solid_face_subtype,
UF_UI_SEL_FEATURE_PLANAR_FACE}};
作者:
zhaobinbob
时间:
2005-4-14 22:06
zzz:在马? 真是不好意思 ,能不能说的再仔细一些,应该用在那里?
还有 ,uf_assem_init_mc应该在那里用,是刚定义完ftf还是对ftf赋值以后?
作者:
zhaobinbob
时间:
2005-4-15 10:15
opts.num_mask_triples=1;
opts.mask_triples=[$mask]
opts.mask_triples->object_type=UF_face_type;
opts.mask_triples->object_subtype=UF_bounded_plane_subtype;
opts.mask_triples->solid_type=UF_UI_SEL_FEATURE_ANY_FACE;
请问斑竹,这段代码不就是对mask的初始化马?
这段代码我已经调试了一个星期了,也没有结果,我用的是nx 1.0版本,
麻烦问一下你那里有没有调试好的例题,能不能给我一个,不胜感激!!
我的邮箱:zb2001270@sohu.com
作者:
zhaobinbob
时间:
2005-4-17 11:31
急死我了,没有人帮我吗?!?!?!
作者:
zzz
时间:
2005-4-18 11:31
先调用
UF_ASSEM_init_mc([$ftf)]
然后再望ftf里面加数据。
作者:
zhaobinbob
时间:
2005-4-18 12:55
我放到前面也不行啊,我已经试过了,!!!
给我个例子吧,谢谢了,求求了>>>>>>>>>>>
我这样做的时候,ug还是提示memory access violation.我已经快死掉了>>>>>
作者:
zhaobinbob
时间:
2005-4-19 20:47
bang wo a !!!!
作者:
zzz
时间:
2005-4-20 14:27
是哪句话导致了memory access violation
作者:
ugopenman
时间:
2005-4-20 16:21
我有自动装配的源程序,需要请EMAIL zhouym1971@hotmail.com
作者:
zhaobinbob
时间:
2005-4-20 21:57
zzz你好,就是在调用UF_ASSEM_INIT_MC的时候吧,如果我把这个函数去掉,就没有这个错误了,但是会出现新的错误:说装配结构初始化不正确.是什么问题,望解答,谢谢!!!!
作者:
zhaobinbob
时间:
2005-4-20 22:03
谢谢ugopenman
作者:
zhaobinbob
时间:
2005-4-23 14:09
我的问题还没有解决啊,还有人帮忙吗!!!!!
作者:
miraculous
时间:
2005-4-24 00:16
memory access violation很可能是你的获得的occurrence tag值不正确,用单步调试看看获得的tag值是自己所需要的吗?
我这里有段代码可以参考一下,不过写的比较乱:
void CDlgAssem::OnBnClickedButton1()
{
int irc;
char message[132+1] = "Select Object First Plane";
UF_UI_selection_options_t opts;
UF_UI_mask_t mask;
int Response;
tag_t view, FirstPlane, SecondPlane;
tag_p_t pObj = new tag_t;
double cursor[3];
char PartName[132+1];
int unhighlight=0;
int Type;
double Point[3];
double Dir[3];
double Box[6];
double Radius;
double RadData;
int NormDir;
CString str;
UF_UI_lock_ug_access(UF_UI_FROM_CUSTOM);
irc = UF_UI_select_with_single_dialog(message,NULL,UF_UI_SEL_SCOPE_ANY_IN_ASSEMBLY, SelInitProc,NULL,[$Response,&FirstPlane,cursor,&view)]
UF_MODL_ask_face_data(FirstPlane,&Type,Point,Dir,Box,
[$Radius,&RadData,&NormDir)]
tag_t FromPartOcc;
int ret = UF_ASSEM_ask_parent_component(FirstPlane,[$FromPartOcc)]
logical IsOcc = UF_ASSEM_is_occurrence(FromPartOcc);
tag_t FromPartIns = UF_ASSEM_ask_inst_of_part_occ(FromPartOcc);
char RefsetName[30+1];
char InstanceName[30+1];
double Origin[3];
double CsysMatrix[9];
double TransForm[4][4];
ret = UF_ASSEM_ask_component_data(FromPartOcc, PartName, RefsetName,
InstanceName, Origin, CsysMatrix, TransForm);
message[0]='\0';
strcpy(message,"Please choose the second plane");
irc = UF_UI_select_with_single_dialog(message,NULL,UF_UI_SEL_SCOPE_ANY_IN_ASSEMBLY,
SelInitProc,NULL,[$Response,&SecondPlane,cursor,&view)]
UF_MODL_ask_face_data(SecondPlane,&Type,Point,Dir,Box,
[$Radius,&RadData,&NormDir)]
if(Type != UF_MODL_PLANAR_FACE)
{
uc1601("Please choose a Second plan",1);
UF_DISP_set_highlight(FirstPlane,0);
}
tag_t ToPartOcc, ToPartIns;
ret = UF_ASSEM_ask_parent_component(SecondPlane,[$ToPartOcc)]
ToPartIns = UF_ASSEM_ask_inst_of_part_occ(ToPartOcc);
ret = UF_ASSEM_ask_component_data(ToPartOcc, PartName, RefsetName,
InstanceName, Origin, CsysMatrix, TransForm);
UF_ASSEM_mating_condition_t ftf;
ret = UF_ASSEM_init_mc([$ftf)]
UF_get_fail_message(ret, message);
int num = 1;
ftf.mated_object = FromPartIns;
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].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(FirstPlane);
ftf.constraints[0].from_part_occ = FromPartOcc;
ftf.constraints[0].to = UF_ASSEM_ask_prototype_of_occ(SecondPlane);
ftf.constraints[0].to_part_occ = ToPartOcc;
ftf.constraints[0].offset = NULL_TAG;
ftf.constraints[0].name = "face to face";
ftf.constraints[0].user_name = TRUE;
ftf.num_constraints = 2;
ftf.suppressed = FALSE;
UF_ASSEM_mc_status_t Status;
UF_ASSEM_mc_structure_state_t StructStatus;
UF_ASSEM_dof_t Dof;
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, &StructStatus, &Status)]
UF_DISP_refresh();
UF_MODL_update();
}
UF_DISP_set_highlight(FirstPlane,0);
UF_DISP_set_highlight(SecondPlane,0);
UF_UI_unlock_ug_access(UF_UI_FROM_CUSTOM);
}
static int SelInitProc(UF_UI_selection_p_t select, void* user_data)
{
int num_triples = 1;
UF_UI_mask_t mask_triples[] = {
UF_face_type, UF_bounded_plane_subtype, UF_UI_SEL_FEATURE_ANY_FACE}; //see uf_ui_types.h
/* enable only faces*/
if(!UF_UI_set_sel_mask(select,
UF_UI_SEL_MASK_CLEAR_AND_ENABLE_SPECIFIC,
num_triples, mask_triples))
{
return (UF_UI_SEL_SUCCESS);
}
else
{
return (UF_UI_SEL_FAILURE);
}
}
作者:
ugopenman
时间:
2005-4-25 09:20
关于UGII自动装配的文章与代码我已放到我们网站(www.ugopen.cn)的技术文档下了,需要的朋友可以直接下载。
作者:
zhaobinbob
时间:
2005-4-25 09:48
感谢ugopenman了。
欢迎光临 iCAx开思工具箱 (https://t.icax.org/)
Powered by Discuz! X3.3