UG NXapi二次开发教程源代码_创建一个圆柱,并打孔倒角
以下为代码部分:#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; 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={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 ; double dir ; double box ; double radius; doublerad_data; intnorm_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-origin)<0.0005) { bottom=obj; } if(fabs(point-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);}原帖地址:
**** Hidden Message *****
学习学习 最好是要有注释啊。 很好很好很好 学习学习啊 謝謝大大分享此資訊~很實用哦!! 谢谢分享 好资源,过来学习学习 谢谢分享~~ 快快快快快快快快快快快