西门子帮助文件中的例子,居然运行不了。真真奇怪了
求大神指导!求大神指导!#include <string.h>#include <stdio.h>#include <uf_defs.h>#include <uf.h>#include <uf_assem.h>#include <uf_attr.h>#include <uf_curve.h>#include <uf_part.h>#include <uf_route.h>#include <uf_dirpath.h>#define UF_CALL(X)(report_error( __FILE__, __LINE__, #X, (X)))static int report_error( char *file, int line, char *call, int irc ){ if(irc) { char err, msg; sprintf( msg, "*** ERROR code %d at line %d in %s:\n+++", irc, line, file ); UF_get_fail_message( irc, err ); UF_print_syslog( msg, FALSE ); UF_print_syslog( err, FALSE ); UF_print_syslog( "\n", FALSE ); UF_print_syslog( call, FALSE ); UF_print_syslog( ";\n", FALSE ); if( !UF_UI_open_listing_window() ) { UF_UI_write_listing_window( msg ); UF_UI_write_listing_window( err ); UF_UI_write_listing_window( "\n" ); UF_UI_write_listing_window( call ); UF_UI_write_listing_window( ";\n" ); } } return( irc );}/*ARGSUSED*/void ufusr(char *param, int *retcod, int parm_len){ double stock_and_part_nps = 3.0; char *stock_material = "ASTM A312 TP304(W)"; char *stock_schedule = "80S"; char *std_part_material = "ASTM A403 WP316L(W)"; char *std_part_rating = "10S"; char *app_view_name = NULL; char *app_view_symb = "UGII_ROUTE_MECH_APP_VIEW"; char *part_search_symb = "UGII_ROUTE_MECH_PART_PATH"; char full_name; doublepos1 = {0.0, 0.0, 0.0 }; doublepos2 = { 10.0, 0.0, 0.0 }; doublepos3 = { 10.0, 10.0, 0.0 }; doublepos4 = { 10.0, 10.0, 10.0 }; doublepos5 = { 10.0, 0.0, 10.0 }; doubleorigin = { 0.0, 0.0, 0.0 }; doublecsys = { 1.0, 0.0,0.0, 0.0, 1.0, 0.0 }; doubleradius = 2.0; doubleratio = 2.0; int n_stock_charx; int n_stock_matches; int n_std_part_charx; int n_std_part_matches; int inx; int style = UF_ROUTE_STYLE_SIMPLE; int num_segs; int num_places; tag_t point; tag_t line; tag_t rcps; tag_t segs; tag_t stock_data; tag_t anchor; tag_t cross; tag_t corner; tag_t work_part; tag_t fit_part; tag_t inst_id; tag_t occ; tag_t work_part_comp; tag_t work_part_occ; tag_t dir_path; UF_CURVE_line_tline_s; UF_ROUTE_charx_tstock_charx; UF_ROUTE_charx_tstd_part_charx; UF_ROUTE_part_lib_part_p_t stock_matches; UF_ROUTE_part_lib_part_p_t std_part_matches; UF_ROUTE_application_view_p_t old_app_view; UF_ROUTE_application_view_p_t app_view; UF_PART_load_status_t error_code ; UF_ROUTE_place_solution_p_t *places; UF_CALL( UF_initialize() ); /* Load and set the application view *** Routing -> Base */ old_app_view = UF_ROUTE_ask_current_app_view( ); UF_CALL( UF_translate_variable( app_view_symb, &app_view_name ) ); UF_CALL( UF_ROUTE_load_app_view( app_view_name, &app_view ) ); UF_CALL( UF_ROUTE_set_current_app_view( app_view ) ); /* Set the search path for locating Routing (Base) parts / stock */ UF_CALL( UF_DIRPATH_create_from_env ( part_search_symb, &dir_path ) ); UF_CALL( UF_ROUTE_set_part_search_path ( dir_path ) ); /* Create the RCPs at absolute positions */ UF_CALL( UF_ROUTE_create_rcp_position( pos1, &rcps ) ); UF_CALL( UF_ROUTE_create_rcp_position( pos2, &rcps ) ); /* Create RCPs at existing point */ UF_CALL( UF_CURVE_create_point( pos3, &point ) ); UF_CALL( UF_ROUTE_create_rcp_point( point, &rcps ) ); /* Create the Segments through these RCPs */ UF_CALL( UF_ROUTE_create_seg_thru_rcps( rcps, rcps, &segs ) ); UF_CALL( UF_ROUTE_create_seg_thru_rcps( rcps, rcps, &segs ) ); /* Create a curve and use this object to create a segment */ for( inx = 0 ; inx < 3 ; inx++ ) { line_s.start_point = pos4; line_s.end_point = pos5; } UF_CALL( UF_CURVE_create_line( &line_s, &line ) ); /* Create the Segments through RCPs that follows a curve In this case the RCPs should be created along the curve parameter */ UF_CALL( UF_ROUTE_create_rcp_curve_parm( line, 0, &rcps ) );/* Curve start parm=0 */ UF_CALL( UF_ROUTE_create_rcp_curve_parm( line, 1, &rcps ) );/* Curve end parm=1 */ UF_CALL( UF_ROUTE_create_seg_thru_rcps( rcps, rcps, &segs ) ); /* Connecting Segment */ UF_CALL( UF_ROUTE_create_seg_on_curve( line, rcps, rcps, &segs ) ); /* Set up the characteristics for the stock we wish to assign */ stock_charx.type = UF_EPLIB_CHARX_TYPE_REAL; strcpy (stock_charx.title, "NPS"); stock_charx.value.r_value = stock_and_part_nps; stock_charx.type = UF_EPLIB_CHARX_TYPE_STR; strcpy (stock_charx.title, "MATERIAL"); stock_charx.value.s_value = stock_material; stock_charx.type = UF_EPLIB_CHARX_TYPE_STR; strcpy (stock_charx.title, "SCHEDULE"); stock_charx.value.s_value = stock_schedule; n_stock_charx = sizeof( stock_charx ) / sizeof( stock_charx ); /* Find the stock we want in the Routing Part Library */ UF_CALL( UF_ROUTE_match_charx_in_plib( "STOCK", n_stock_charx, stock_charx, &n_stock_matches, &stock_matches ) ); /* Locate (or load) the stock data which matches our criteria */ UF_CALL( UF_ROUTE_load_stock_by_charx( &stock_matches, "", style, &stock_data, &anchor, &cross ) ); UF_CALL( UF_ROUTE_free_match_results( n_stock_matches, stock_matches ) ); /* Create a bend corner at one of the RCP junctions */ UF_CALL( UF_ROUTE_create_bend_by_radius( rcps, radius, &corner, &segs ) ); /* Assigns the stock data to segments */ num_segs = 5; UF_CALL( UF_ROUTE_assign_stock( stock_data, anchor, cross, num_segs, segs ) ); /* Create a bend corner by the ratio of stock dia to the bend radius The stock gets automatically updated at the bend */ UF_CALL( UF_ROUTE_create_bend_by_ratio( rcps, ratio, &corner, &segs ) ); /* Set up the characteristics for the Standard part we wish to place */ std_part_charx.type = UF_EPLIB_CHARX_TYPE_REAL; strcpy (std_part_charx.title, "NPS"); std_part_charx.value.r_value = stock_and_part_nps; std_part_charx.type = UF_EPLIB_CHARX_TYPE_REAL; strcpy (std_part_charx.title, "ELBOW_ANG"); std_part_charx.value.r_value = 90.0; std_part_charx.type = UF_EPLIB_CHARX_TYPE_STR; strcpy (std_part_charx.title, "FITTING_MATERIAL"); std_part_charx.value.s_value = std_part_material; std_part_charx.type = UF_EPLIB_CHARX_TYPE_STR; strcpy (std_part_charx.title, "RATING"); std_part_charx.value.s_value = std_part_rating; n_std_part_charx = sizeof( std_part_charx ) / sizeof( std_part_charx ); UF_CALL( UF_ROUTE_match_charx_in_plib( "ELBOWS", n_std_part_charx, std_part_charx, &n_std_part_matches, &std_part_matches ) ); UF_CALL( UF_ROUTE_load_part_by_charx( std_part_matches.num_charx, std_part_matches.charx, &fit_part ) ); /* Add the elbow as a component of the work part */ UF_CALL( UF_PART_ask_part_name( fit_part, full_name ) ); work_part = UF_ASSEM_ask_work_part( ); UF_CALL( UF_ASSEM_add_part_to_assembly( work_part, full_name, NULL, NULL, origin, csys, -1, &inst_id, &error_code ) ); /* For the following Routing operations of setting the characteristics of the fitting part and for placing it within the Routing, we use the part occurrence of the fitting in the part occurrence tree that is "rooted" at the work part. This is because the Routing characteristics and placement functions expect this particular part occurrence. */ work_part_comp = UF_ASSEM_ask_parent_of_instance( inst_id ); work_part_occ = UF_ASSEM_ask_root_part_occ( work_part_comp ); occ = UF_ASSEM_ask_part_occ_of_inst( work_part_occ, inst_id ) ; /* We now have the part occurrence of the fitting in the work part's part occurrence tree. So we can attach the Routing characteristics to this part occurrence and place this occurrence within the Routing. */ UF_CALL( UF_ROUTE_set_characteristics( occ, std_part_matches.num_charx, std_part_matches.charx ) ); /* Place the elbow at the fourth RCP */ num_places = 0; places = NULL; UF_CALL( UF_ROUTE_solve_places( rcps, occ, &num_places, &places ) ); UF_CALL( UF_ROUTE_ask_places_transform( places, origin, csys ) ); UF_CALL( UF_ASSEM_reposition_instance( inst_id, origin, csys ) ); UF_CALL( UF_ROUTE_free_places( num_places, places ) ); UF_CALL( UF_ROUTE_set_part_in_stock( occ ) ); UF_CALL( UF_ROUTE_unload_app_view( app_view ) ); UF_CALL( UF_ROUTE_set_current_app_view( old_app_view ) ); UF_terminate(); return;}
管线布置模块的模块没怎么了解过,可能需要布置一下环境吧。。 蓝摩羯 发表于 2019-7-6 11:32
管线布置模块的模块没怎么了解过,可能需要布置一下环境吧。。
是的,是管线布置模块,和您说的一样。创建管路需要选择管路的型材,这个需要在NX重用库中选择管路的截面大小。一起研究研究?C:\Users\HYM_PC\Pictures\图片1.pngC:\Users\HYM_PC\Pictures\图片1.pngC:\Users\HYM_PC\Pictures\图片1.png
C:\Users\HYM_PC\Pictures\图片2.png 蓝摩羯 发表于 2019-7-6 11:32
管线布置模块的模块没怎么了解过,可能需要布置一下环境吧。。
是的,是管线布置模块,和您说的一样。创建管路需要选择管路的型材,这个需要在NX重用库中选择管路的截面大小。一起研究研究?C:\Users\HYM_PC\Pictures\图片1.pngC:\Users\HYM_PC\Pictures\图片1.pngC:\Users\HYM_PC\Pictures\图片1.png
C:\Users\HYM_PC\Pictures\图片2.png 蓝摩羯 发表于 2019-7-6 11:32
管线布置模块的模块没怎么了解过,可能需要布置一下环境吧。。
C:\Users\HYM_PC\Pictures\图片2.png C:\Users\HYM_PC\Pictures\图片2.png
页:
[1]