书签 分享 收藏 举报 版权申诉 / 24
上传文档赚钱

类型NX二次开发习题及源码.doc

  • 上传人(卖家):刘殿科
  • 文档编号:5856019
  • 上传时间:2023-05-12
  • 格式:DOC
  • 页数:24
  • 大小:4.60MB
  • 【下载声明】
    1. 本站全部试题类文档,若标题没写含答案,则无答案;标题注明含答案的文档,主观题也可能无答案。请谨慎下单,一旦售出,不予退换。
    2. 本站全部PPT文档均不含视频和音频,PPT中出现的音频或视频标识(或文字)仅表示流程,实际无音频或视频文件。请谨慎下单,一旦售出,不予退换。
    3. 本页资料《NX二次开发习题及源码.doc》由用户(刘殿科)主动上传,其收益全归该用户。163文库仅提供信息存储空间,仅对该用户上传内容的表现方式做保护处理,对上传内容本身不做任何修改或编辑。 若此文所含内容侵犯了您的版权或隐私,请立即通知163文库(点击联系客服),我们立即给予删除!
    4. 请根据预览情况,自愿下载本文。本站不保证下载资源的准确性、安全性和完整性, 同时也不承担用户因使用这些下载资源对自己和他人造成任何形式的伤害或损失。
    5. 本站所有资源如无特殊说明,都需要本地电脑安装OFFICE2007及以上版本和PDF阅读器,压缩文件请下载最新的WinRAR软件解压。
    配套讲稿:

    如PPT文件的首页显示word图标,表示该PPT已包含配套word讲稿。双击word图标可打开word文档。

    特殊限制:

    部分文档作品中含有的国旗、国徽等图片,仅作为作品整体效果示例展示,禁止商用。设计者仅对作品中独创性部分享有著作权。

    关 键  词:
    NX 二次开发 习题 源码
    资源描述:

    1、1、创建NXhello界面代码:#include In a non-assembly part, this is the same as the work part. If there currently isnt a displayed part, a NULL_TAG is returned. */obj=UF_PART_ask_display_part();if(obj = NULL_TAG) ll文件时,就直接跑到建模环境了,没有信息提示框。当然你可以多申明几个tag_tchar part_name13 = F:;/ UF_get_fail_message(error_code, fa

    2、il_message); UF_UI_set_status (fail_message); printf ( %sn, fail_message ); UF_terminate(); return;extern int ufusr_ask_unload (void) return ( UF_UNLOAD_IMMEDIATELY );extern void ufusr_cleanup (void) return;int CHANGE_apply_cb ( int dialog_id,void * client_data,UF_STYLER_item_value_type_p_t callback

    3、_data) if ( UF_initialize() != 0) return ( UF_UI_CB_CONTINUE_DIALOG ); / UF_get_fail_message(error_code, fail_message); UF_UI_set_status (fail_message); printf ( %sn, fail_message ); UF_terminate(); return;extern int ufusr_ask_unload (void) /* unload immediately after application exits*/ return ( UF

    4、_UNLOAD_IMMEDIATELY ); /*via the unload selection dialog. */ /*return ( UF_UNLOAD_SEL_DIALOG ); */ /*when UG terminates. */ /*return ( UF_UNLOAD_UG_TERMINATE ); */extern void ufusr_cleanup (void) return;int CHANGE_apply_cb ( int dialog_id, void * client_data, UF_STYLER_item_value_type_p_t callback_d

    5、ata) /* Make sure User Function is available. */ if ( UF_initialize() != 0) return ( UF_UI_CB_CONTINUE_DIALOG ); /* - Enter your callback code here - */ UF_terminate (); /* Callback acknowledged, do not terminate dialog */ /* A return value of UF_UI_CB_EXIT_DIALOG will not be accepted */ /* for this

    6、 callback type. You must respond to your apply button.*/ return (UF_UI_CB_CONTINUE_DIALOG); int CHANGE_action_1_act_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_D

    7、IALOG ); /* - Enter your callback code here - */ UF_UI_create_filebox ( prompt_string, title_string, filter_string, default_name, filename, &response); /* 从文件中读信息*/ int error; fstream file1(filename); char *file_contents = (char*)UF_allocate_memory(sizeof(char*)*16,&error); int i=0; while(!() file_c

    8、ontentsi = (char*)UF_allocate_memory(MAX_LINE_SIZE+1,&error); file1file_contentsi; UF_UI_write_listing_window(file_contentsi); UF_UI_write_listing_window(n); i+; UF_STYLER_item_value_type_t data; = MTXT_0; = UF_STYLER_VALUE; = UF_STYLER_STRING_PTR_VALUE; = i; = file_contents; UF_STYLER_set_value(dia

    9、log_id,&data); UF_STYLER_free_value(&data); (); 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 ); */int CHANGE_action_2_act_cb ( int dialog_id, void * client_d

    10、ata, 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 - */ UF_STYLER_item_value_type_t data; = MTXT_0; = UF_STYLER_VALUE; UF_STYLER_ask_value(dialog_id,&data); c

    11、har prompt_string=Select File; char title_string=File Access; char filter_stringUF_CFI_MAX_PATH_NAME_SIZE+1=*.txt; char default_name133=; char filenameUF_CFI_MAX_PATH_NAME_SIZE; int response; int error = UF_UI_create_filebox(prompt_string, title_string, filter_string, default_name, filename, &respon

    12、se); if(error !=0 ) return UF_UI_CB_CONTINUE_DIALOG; fstream file2(filename); for (int i=0;i;i+) if(!(file2&file2endl) (); UF_STYLER_free_value(&data); UF_terminate (); /* Callback acknowledged, do not terminate dialog */ return (UF_UI_CB_CONTINUE_DIALOG); /* or Callback acknowledged, terminate dial

    13、og. */ /* return ( UF_UI_CB_EXIT_DIALOG ); */ 注意:这个项目需要在UG中创建一个人机交互界面8、(1)创建点收集器,创建参考点并返回点的坐标代码如下:#include #include #include #define UF_CALL(X) (report( _FILE_, _LINE_, #X, (X) static int report( char *file, int line, char *call, int irc) if (irc) char messg133; printf(%s, line %d: %sn, file, line,

    14、call); (UF_get_fail_message(irc, messg) printf( returned a %dn, irc) : printf( returned error %d: %sn, irc, messg); return(irc); static void do_ugopen_api(void) bject;UF_UI_open_listing_window(); char str 133;for(int i=0;i3;i+)sprintf(str,%f,points0.pti);nn,msg);exit(1);static void report_error(int

    15、result,char *alt_msg)char err_message200;int found = UF_get_fail_message(result,err_message);if (found != 0)error_return(alt_msg);elseerror_return(err_message);static void create_blo( double origin_y, char *blo_length,char*blo_width,char*blo_height ) UF_FEATURE_SIGN sign = UF_NULLSIGN; tag_t taget =

    16、 NULL_TAG; double blo_origin 3 = 0,0,0; */ if(UF_CALL(UF_UI_select_with_class_dialog(cue, title, UF_UI_SEL_SCOPE_NO_CHANGE ,init_proc, NULL, &response, &count, &objects) = 0) In a non-assembly part, this is the same as the work part. If there currently isnt a displayed part, a NULL_TAG is returned.

    17、*/tag_t root_occ = UF_ASSEM_ask_root_part_occ(display_part);if(root_occ=null_tag)rom_part_occ = from_part_occ;0.from_status = UF_ASSEM_ok;0.from = UF_ASSEM_ask_prototype_of_occ( objs0 );0.from_type = UF_ASSEM_planar_face;0.to = UF_ASSEM_ask_prototype_of_occ( objs1 );0.to_part_occ = to_part_occ;0.to_

    18、status = UF_ASSEM_ok;0.to_type = UF_ASSEM_planar_face;0.mate_type = UF_ASSEM_align;UF_ASSEM_mc_status_t status;UF_ASSEM_dof_t dof;double transform_matrix44; UF_MODL_ask_exp_tag_value(target1,&value); /创建孔特征的变量声明区 double location3=, ; double direction = ,; tag_t obj=null_tag; char *diam=30; char *ang

    19、le=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 l

    20、inked list of objects for(int i=0;icount;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

    21、 face if(type=22)/“22”代表有界平面 if(fabs(point2-origin2) bottom=obj; if(fabs(point2-value) 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_coun

    22、t(face_list,&count);for(int i=0;icount;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

    23、,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,

    24、int param_len) if (!UF_CALL(UF_initialize() do_ugopen_api(); UF_CALL(UF_terminate(); int ufusr_ask_unload(void) return (UF_UNLOAD_IMMEDIATELY);运行结果截屏如下:(2)创建一个对象,使其沿着X轴平移100,以Z轴为旋转轴旋转90度。代码如下:#include #include#include#include#include#include#includeextern void ufusr(char *param, int *retcode, int pa

    25、ramLen) if(UF_initialize()!=0) return; /获取实体 tag_t display_part = UF_PART_ask_display_part(); tag_t objects = NULL_TAG; UF_OBJ_cycle_objs_in_part(display_part,UF_solid_type,&objects); /返回平移的矩阵 double translation3=,; double matrix116; uf5943(translation,matrix1); /返回旋转的矩阵 double origin3=,; double dir

    26、ection3=,; double degrees_rotation=; double matrix216; int status1; uf5945(origin,direction,°rees_rotation,matrix2,&status1); /实现平移及旋转 const int n_objects=1 ; const int move_or_copy=1; const int dest_layer=0 ; const int trace_curves=2 ; tag_t copies; tag_t trace_curve_group; int status2; uf5947(m

    27、atrix1,&objects,&n_objects,&move_or_copy,&dest_layer, &trace_curves,&copies,&trace_curve_group,&status2); uf5947(matrix2,&objects,&n_objects,&move_or_copy,&dest_layer, &trace_curves,&copies,&trace_curve_group,&status2); UF_terminate(); int ufusr_ask_unload(void) return (UF_UNLOAD_IMMEDIATELY); void ufusr_cleanup(void)

    展开阅读全文
    提示  163文库所有资源均是用户自行上传分享,仅供网友学习交流,未经上传用户书面授权,请勿作他用。
    关于本文
    本文标题:NX二次开发习题及源码.doc
    链接地址:https://www.163wenku.com/p-5856019.html

    Copyright@ 2017-2037 Www.163WenKu.Com  网站版权所有  |  资源地图   
    IPC备案号:蜀ICP备2021032737号  | 川公网安备 51099002000191号


    侵权投诉QQ:3464097650  资料上传QQ:3464097650
       


    【声明】本站为“文档C2C交易模式”,即用户上传的文档直接卖给(下载)用户,本站只是网络空间服务平台,本站所有原创文档下载所得归上传人所有,如您发现上传作品侵犯了您的版权,请立刻联系我们并提供证据,我们将在3个工作日内予以改正。

    163文库