|
以下为代码部分: - #include <stdio.h>#include <uf.h>#include <uf_ui.h>#include <uf_disp.h>#include<uf_modl.h>#include<uf_layer.h>#include<uf_assem.h>#include<uf_obj.h>#include<uf_part.h>#include<iostream>#define UF_CALL(X) (report( __FILE__, __LINE__, #X, (X)))static int report( char *file, int line, char *call, int irc){ if (irc) { char messg[133]; printf("%s, line %d: %s\n", file, line, call); (UF_get_fail_message(irc, messg)) ? printf(" returned a %d\n", irc) : printf(" returned error %d: %s\n", irc, messg); } return(irc);}static void do_ugopen_api(void){ UF_FEATURE_SIGN sign = UF_NULLSIGN; tag_t target = NULL_TAG; double origin [] = {0.0,0.0,0.0}; char* height = "100"; char* cyl_diam = "80"; double cyl_direction [] = {0.0,0.0,1.0}; tag_t cyl_feat_tag = NULL_TAG; UF_MODL_create_cylinder(sign,target,origin,height,cyl_diam,cyl_direction,&cyl_feat_tag); double value; tag_t target1; UF_MODL_create_exp_tag(height,&target1);//Creates a parameter expression, based upon the input string. UF_MODL_ask_exp_tag_value(target1,&value);//Asks the value of an expression tag. double location[3]={0.0,0.0,0.0} ; double direction [] = {0.0,0.0,1.0}; tag_t obj=null_tag; char *diam="30"; char *angle="0"; tag_t bottom,top; tag_t feature_obj_id ; uf_list_p_t face_list; UF_MODL_create_list(&face_list);//Retrieves an object from a linked list of objects UF_MODL_ask_feat_faces(cyl_feat_tag,&face_list); int count=0; UF_MODL_ask_list_count(face_list,&count);//Retrieves the count from a linked list of objectsfor(int i=0;i<count;i++){ UF_MODL_ask_list_item(face_list,i,&obj); int type; double point [3] ; double dir [3] ; double box [6] ; double radius; double rad_data; int norm_dir ; UF_MODL_ask_face_data(obj,&type,point,dir,box,&radius,&rad_data,&norm_dir);//Queries the data associated with a face if(type==22)//“22”代表有界平面 { if(fabs(point[2]-origin[2])<0.0005) { bottom=obj; } if(fabs(point[2]-value)<0.0001) { UF_MODL_ask_feat_location(obj,location); top=obj; } }}UF_MODL_create_simple_hole(location,direction,diam,height,angle,top,bottom,&feature_obj_id);UF_MODL_ask_feat_faces(feature_obj_id,&face_list);UF_MODL_ask_list_count(face_list,&count);for(int i=0;i<count;i++){ UF_MODL_ask_list_item(face_list,i,&obj);//Retrieves an object from a linked list of objects int typel; UF_MODL_ask_face_type(obj,&typel); //倒圆角 if(typel== UF_MODL_CYLINDRICAL_FACE ) { uf_list_p_t facesl; UF_MODL_create_list(&facesl); UF_MODL_ask_shared_edges(top,obj,&facesl); const char * radius="3"; int smooth_overflow=0; int cliff_overflow=0; int notch_overflow=0; double vrb_tool=3; tag_t feature_obj_idl; UF_MODL_create_blend(radius, facesl, smooth_overflow, cliff_overflow, notch_overflow, vrb_tool, &feature_obj_id ); } }}void ufusr(char *param, int *retcode, int param_len){ if (!UF_CALL(UF_initialize())) { do_ugopen_api(); UF_CALL(UF_terminate()); }}int ufusr_ask_unload(void){ return (UF_UNLOAD_IMMEDIATELY);}
复制代码
原帖地址:
http://www.ugufun.com/?p=111
|
|