/****************************************************************************** Copyright (c) 1999 Unigraphics Solutions, Inc. Unpublished - All Rights Reserved *******************************************************************************/ /* The following example is an internal UG/Open API program. A block primitive is created in a new part. The solid body object identifier is obtained for the feature object identifier of the block. This identifier is then converted to its corresponding Parasolid tag in preparation for calling the Parasolid solid modeler routines. The Parasolid tag is then converted back to the object identifier of the block. */ #include #include #include #include #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 messg[133]; printf("%s, line %d: %s\n", file, line, call); (UF_get_fail_message(irc, messg)) ? printf(" returned a %d\n", irc) : printf(" returned error %d: %s\n", irc, messg); } return(irc); } static void do_ugopen_api(void) { int units = UF_PART_METRIC; char *part_name = "ps_sample"; char buffer[133]; char *block_len[3] = {"10","10","5"}; tag_t part,block_feat_id,block_body_id,ps_tag, ug_tag; double block_origin[3] = {0.0,0.0,0.0}; UF_FEATURE_SIGN sign = UF_NULLSIGN; /* Create a new part. */ UF_CALL(UF_PART_new(part_name,units,&part)); /*create a block that is 10 x 10 x 5*/ UF_CALL(UF_MODL_create_block1(sign,block_origin,block_len, &block_feat_id)); /* Convert feature object id to body object id. */ UF_MODL_ask_feat_body(block_feat_id,&block_body_id); /* Interface with the Parasolid routines using the ps tag. */ /* Open the Information Window */ UF_UI_open_listing_window(); /* Obtain the Parasolid identifier for the given UG tag. */ if(UF_CALL(UF_PS_ask_ps_tag_of_object(block_body_id, &ps_tag))) { return; } if(UF_CALL(UF_PS_ask_object_of_ps_tag(ps_tag, &ug_tag))) { return; } /* Print a report on tag information. */ sprintf(buffer,"\nThe Parasolid Tag is: %d", ps_tag); UF_UI_write_listing_window(buffer); sprintf(buffer, "\nThe UG tag is: %d", ug_tag); UF_UI_write_listing_window(buffer); sprintf(buffer, "\nThe block feature tag is: %d", block_feat_id); UF_UI_write_listing_window(buffer); sprintf(buffer, "\nThe solid body tag is: %d", block_body_id); UF_UI_write_listing_window(buffer); UF_PART_save(); } /*ARGSUSED*/ void ufusr(char *param, int *retcode, int param_len) { if (!UF_CALL(UF_initialize())) { do_ugopen_api(); UF_CALL(UF_terminate()); } } int ufusr_ask_unload(void) { return (UF_UNLOAD_IMMEDIATELY); }