学UG二次开发就上UG网:
C++UG二次开发求差函数:UF_MODL_subtract_bodies(不保留目标体和工具体);UF_MODL_subtract_bodies_with_retained_options(保留目标体和工具体);
UG二次开发
布尔运算是UG设计中非常常用的功能,用UG二次开发创建的零件应当学会多种布尔运算方式,比如创建的新零件执行布尔运算、选择一个零件执行布尔运算等等;
布尔运算求差UG二次开发C++源码:
- /* TODO: Add your application code here */
- /*中磊国际模具培训-创建求和运算*/
- /*学NX二次开发就上UG网-www.9sug.com块参数 */
- double blk_corner[3] = { 0, 0, 0 };
- char * blk_edg_len[3] = { "20", "20", "20" };
- tag_t blk_obj_id;
- tag_t blk_body_id;
- /*学NX二次开发就上UG网-www.9sug.com圆柱参数 */
- double cyl_origin[3] = { 0, 0, 0 };
- char * cyl_height = "20";
- char * cyl_diam = "10";
- double cyl_direction[3]{0, 0, 1};
- tag_t cyl_obj_id;
- tag_t cyl_body_id;
- /*学NX二次开发就上UG网-www.9sug.com块参数 */
- UF_MODL_create_block1(UF_NULLSIGN, blk_corner, blk_edg_len, &blk_obj_id);
- UF_MODL_ask_feat_body(blk_obj_id, &blk_body_id);
- /*学NX二次开发就上UG网-www.9sug.com圆柱参数 */
- UF_MODL_create_cyl1(UF_NULLSIGN, cyl_origin, cyl_diam,cyl_height,cyl_direction, &cyl_obj_id);
- UF_MODL_ask_feat_body(cyl_obj_id, &cyl_body_id);
- /*调整视图到合适大小*/
- tag_t view_tag = NULL_TAG;
- UF_VIEW_ask_work_view(&view_tag);
- UF_VIEW_fit_view(view_tag, 0.7);
- /*布尔运算-减*/
- int num_result = 0;
- tag_t * resulting_bodies = NULL;
- UF_MODL_subtract_bodies(blk_body_id,
- cyl_body_id,
- &num_result,
- &resulting_bodies);
- /* Terminate the API environment */
复制代码
|