|
马上注册登录,享用更多网站功能!
您需要 登录 才可以下载或查看,没有帐号?立即注册
x
在圆柱体的一个平面上建立一个草图,要在草图上画直线,是否先用UF_CURVE_create_line([$sline1,&line1[0])]创建直线,然后用errcod=UF_SKET_add_objects(sketch_id,count1,line1);把直线加入草图中
部分程序如下
int MY_ok_cb ( int dialog_id,
void * client_data,
UF_STYLER_item_value_type_p_t callback_data)
{
int errcod;
char cc5[133];
char name[30]="sketch1";
int option=2;
int reference[2];
int reference1[2];
int plane_dir=1;
int plane_dir1=UF_SKET_WITH_NORMAL;
UF_FEATURE_SIGN sign=UF_NULLSIGN ;
tag_t cyl_obj;
tag_t plane[10];
int listnum=0;
int i;
int ret;
int type;
int count=0;
double origin[3]={0,0,0};
double point[3];
double dir[3];
double direction[3]={0,0,1};
char * height={"20"};
double box[6];
char * diam={"90"};
char * diam1={"30"};
double radius;
double rad_data;
int norm_dir;
uf_list_p_t face_list;
tag_t face_obj[2];
tag_t member=NULL_TAG;
tag_t sketch_id;
tag_t displayed_part;
int body_type;
int sub_type;
int is_parallel;
int count1=1;
double origin2[3]={0,0,20};
double matrix_value[9]={1,0,0,0,1,0,0,0,20};
tag_t line1[3];
UF_CURVE_line_t sline1;
/* Make sure User Function is available. */
if ( UF_initialize() != 0)
return ( UF_UI_CB_CONTINUE_DIALOG );
/* ---- Enter your callback code here ----- */
reference[0]=1;
reference[1]=1;
reference1[0]=UF_SKET_HORIZONTAL;
reference1[1]=UF_SKET_ALONG_CURVE;
UF_MODL_create_cyl1(sign,origin,height,diam,direction,[$cyl_obj)]
displayed_part=UF_PART_ask_display_part();
ret=UF_OBJ_cycle_objs_in_part(displayed_part,UF_solid_type,[$member)]
if(member!= NULL_TAG);
{
UF_OBJ_ask_type_and_subtype(member,[$body_type,&sub_type)]
if(body_type==UF_solid_type && sub_type==UF_solid_body_subtype)
{
UF_MODL_ask_body_faces(member,[$face_list)]
UF_MODL_ask_list_count(face_list,[$listnum)]
for(i=0;i<listnum;i++)
{
UF_MODL_ask_list_item(face_list,i,[$face_obj[0])]
UF_MODL_ask_face_data(face_obj[0],[$type,point,dir,box,&radius,&rad_data,&norm_dir)]
if(type==22)
{
UF_VEC3_is_parallel(dir,direction,0.0001,[$is_parallel)]
if(is_parallel)
{
plane[count]=face_obj[0];
count++;
}
}
}
UF_MODL_delete_list([$face_list)]
}
}
UF_SKET_initialize_sketch(name,[$sketch_id)]
UF_SKET_create_sketch (name,option,matrix_value,plane,reference,plane_dir,[$sketch_id)]
//UF_SKET_attach_to_face(sketch_id,plane[1],plane[1],reference1,plane_dir1,[$sketch_feature_tag1)]
UF_SKET_initialize_sketch(name,[$sketch_id)]
sline1.start_point[0]=0.0;
sline1.start_point[1]=0.0;
sline1.start_point[2]=0.0;
sline1.end_point[0]=10.0;
sline1.end_point[1]=10.0;
sline1.end_point[2]=0.0;
UF_CURVE_create_line([$sline1,&line1[0])]
errcod=UF_SKET_add_objects(sketch_id,count1,line1);
//UF_SKET_update_sketch(sketch_id);
//errcod=
sprintf( cc5, "\na : %d\n" ,errcod);
UF_UI_open_listing_window();
UF_UI_write_listing_window(cc5);
/* Callback acknowledged, terminate dialog */
/* It is STRONGLY recommended that you exit your */
/* callback with UF_UI_CB_EXIT_DIALOG in a ok callback.*/
/* return ( UF_UI_CB_EXIT_DIALOG ); */
return (UF_UI_CB_EXIT_DIALOG);
} |
|