/****************************************************************************** Copyright (c) 1999 Unigraphics Solutions, Inc. Unpublished - All Rights Reserved *******************************************************************************/ /* This UG/Open API program shows how to encode and decode UG/Manager part filenames. It encodes a UG/Manager part filename, and uses the result to create a new part. The part is added to a folder in your "Home" folder named "Test Set Default Folder", if it exists. If "Test Set Default Folder" does not exist, the new part is added to your "Home" folder. The name and description of the new part are set in IMAN. The program then proceeds to ask for the current work part (i.e., the newly created part), and decode the UG/Manager part filename returned to display information about the work part. */ #include #include #include #include #include #include #include #define CHECK( func_ ) \ { int ifail_ = 0; \ char message[133]; \ ifail_ = (func_); if ( ifail_ != 0 ) { \ UF_get_fail_message( ifail_, message ); \ printf("ERROR: %s returned from %s\n", message, # func_); \ return ifail_; } } static int create_part( void ); static int print_work_part_info( void ); /*---------------------------------------------------------------*/ int main(int argc, char *argv[]) { int ifail = 0; ifail = UF_UGMGR_initialize(argc,(const char**)argv); if (ifail != 0) { printf("ERROR: Failed to initialize with error code %d", ifail); exit(1); } create_part(); print_work_part_info(); UF_PART_close_all(); UF_UGMGR_terminate(); return 0; } /*---------------------------------------------------------------*/ static int create_part( void ) { char* part_number = "600-A-wej-mk1-eng"; char* part_revision = "A"; char* part_file_type = "master"; char* part_file_name = ""; char encoded_name[MAX_FSPEC_SIZE + 1]; tag_t part_tag; UF_UGMGR_tag_t db_part_tag; UF_UGMGR_tag_t root_folder; char root_folder_name[UF_UGMGR_NAME_SIZE]; int i, count; UF_UGMGR_tag_t *folder_contents; UF_UGMGR_object_type_t object_type; char folder_name[UF_UGMGR_NAME_SIZE]; logical folder_exists = false; CHECK(UF_UGMGR_ask_root_folder(&root_folder)); CHECK(UF_UGMGR_ask_folder_name(root_folder, root_folder_name)); printf("Root folder is %s\n", root_folder_name); /* Scan through the root folder, looking for a folder called "Test Set Default Folder". If this folder exists, set it to be the default folder into which newly created parts are placed. */ CHECK(UF_UGMGR_list_folder_contents(root_folder, &count, &folder_contents)); for ( i=0; i