Исходники для Unigraphics. В качестве параметра принимает имя файла сборки - *.prt, открывает этот файл и перебирает все части сборки и их компоненты. Результат перебора выводится на консоль, можете перенаправить в файл.
Код на C++ /* Include files */ #if ! defined ( __hp9000s800 ) && ! defined ( __sgi ) && ! defined ( __sun ) # include <strstream> # include <iostream> using std::ostrstream; using std::endl; using std::ends; using std::cerr; #else # include <strstream.h> # include <iostream.h> #endif #include <uf_ui.h> #include <uf.h> #include <uf_part.h> #include <uf_assem.h> #include <stdio.h> #include <conio.h> #include <uf_assem.h> #include <uf_cfi.h> #include <uf_obj.h> #include <uf_object_types.h> #include <uf_view.h> #define UF_CALL(X) (report_error( __FILE__, __LINE__, #X, (X))) // VARS tag_t part_tag=NULL_TAG; static int report_error( char *file, int line, char *call, int irc) { if (irc) { char err[133], msg[133]; sprintf(msg, "*** ERROR code %d at line %d in %s:\n", irc, line, file); UF_get_fail_message(irc, err); printf(msg); 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); } return(irc); } int cycle_obj_in_part(tag_t cur_part,char *rz=NULL){ tag_t next_tag=NULL_TAG; tag_t *ch_components = NULL; tag_t parent; char p_name[MAX_FSPEC_SIZE+1]; char rzl[MAX_FSPEC_SIZE+1]; char r_name[MAX_ENTITY_NAME_SIZE+1]; char c_name[UF_CFI_MAX_FILE_NAME_SIZE]; char local_indentation[256]; double origin[3]; double csys_matrix[9]; double transform[4][4]; int ifail,c_count,cnt_obj=0,cnt_comps=0; char view_name[UF_OBJ_NAME_LEN + 1]; int view_dep,type,subtype; if (cur_part == NULL_TAG) return 0; ifail = UF_ASSEM_ask_component_data(cur_part,p_name,r_name, c_name,origin,csys_matrix, transform); UF_CALL(ifail); if (ifail != 0) return ifail; strcpy(rzl, rz); printf("%sPart: %s\tRefset: %s\tInstance: %s",rzl,p_name,r_name,c_name); strcat(rzl,"\t"); //UF_OBJ_cycle_objs_in_part(cur_part,UF_component_type,&next_tag); c_count = UF_ASSEM_ask_part_occ_children(cur_part,&ch_components); ifail = UF_ASSEM_cycle_objs_in_comp(cur_part, &next_tag); UF_CALL(ifail); if (ifail != 0) return ifail; while (next_tag != NULL_TAG) { ifail = UF_ASSEM_ask_parent_component(next_tag, &parent); UF_CALL(ifail); if ((parent != cur_part) || (ifail != 0)) { printf("ERROR: Wrong parent %u for member %u\n",parent, next_tag); return 1; } UF_OBJ_ask_type_and_subtype(next_tag, &type, &subtype ); if (type==UF_component_type) cnt_comps++; cnt_obj++; ifail = UF_ASSEM_cycle_objs_in_comp(cur_part, &next_tag); UF_CALL(ifail); if (ifail != 0) return ifail; } printf("\tComps: %d\tObjs: %d\n",cnt_comps,cnt_obj); b52 ifail = UF_ASSEM_cycle_objs_in_comp(cur_part, &next_tag); UF_CALL(ifail); if (ifail != 0) return ifail; while (next_tag != NULL_TAG) { ifail = UF_ASSEM_ask_parent_component(next_tag, &parent); UF_CALL(ifail); if ((parent != cur_part) || (ifail != 0)) { printf("ERROR: Wrong parent %u for member %u\n",parent, next_tag); return 1; } UF_OBJ_ask_type_and_subtype(next_tag, &type, &subtype ); ifail = uc6409( next_tag, &view_dep, view_name ); printf("%s%u\t%u\t%u\t",rzl, next_tag, type, subtype); if ( view_dep == 0 ) printf("Model Views"); else printf(view_name); printf("\n"); ifail = UF_ASSEM_cycle_objs_in_comp(cur_part, &next_tag); UF_CALL(ifail); if (ifail != 0) return ifail; cnt_obj++; } for (int i=0; i<c_count; i++) { ifail = cycle_obj_in_part(ch_components[i], rzl); } return 0; } int open_part_file(char *part_name) { logical unused; int err; UF_PART_load_status_t load_status; UF_CALL(UF_PART_open( part_name, &part_tag, &load_status )); return(load_status.failed); } /* Main routine */ extern void main( char argc, char *argv[] ) { tag_t main_part; char rz[MAX_FSPEC_SIZE+1],part_fspec[MAX_FSPEC_SIZE+1]; if( UF_CALL(UF_initialize())) { /* Failed to initialize */ return; } if (argc>1){ if (open_part_file(argv[1])){ printf("Error open part"); return; } rz[0]=0; main_part = UF_ASSEM_ask_root_part_occ(part_tag); if (main_part != NULL_TAG) { cycle_obj_in_part(main_part,rz); } } else printf("Count of param = 0"); UF_CALL(UF_terminate()); } /***************************************************************************** ** Utilities *****************************************************************************/
Код на Text Part: E:\UG\den tests\practic 2\sborka.prt Refset: None Instance: Comps: 2 Objs: 2 9565 63 1 9578 63 1 Part: E:\UG\den tests\practic 2\shaiba.prt Refset: MODEL Instance: SHAIBA1 Comps: 0 Objs: 9 10456 70 2 Model Views 10461 70 2 Model Views 10459 70 3 Model Views 10458 70 2 Model Views 10463 70 3 Model Views 10460 70 3 Model Views 10464 70 0 Model Views 10457 70 2 Model Views 10462 70 3 Model Views Part: E:\UG\den tests\practic 2\bolt.prt Refset: MODEL Instance: BOLT1 Comps: 0 Objs: 12 10466 70 3 Model Views 10468 70 2 Model Views 10473 70 2 Model Views 9597 70 0 Model Views 10475 70 3 Model Views 10470 70 3 Model Views 10467 70 2 Model Views 10471 70 0 Model Views 10469 70 2 Model Views 10474 70 2 Model Views 9596 70 2 Model Views 10472 70 3 Model Views
|