/******************************************************************************
             Copyright (c) 1999 Unigraphics Solutions, Inc.
                       Unpublished - All Rights Reserved

*******************************************************************************/
/* The code in the following example creates 2 cubes of size 1.0 x 3.2 x
1.5 and then exports them into a new part. This example must be run
with an active work part.
*/
#include <stdio.h>
#include <uf.h>
#include <uf_modl.h>
#include <uf_defs.h>
#include <uf_part.h>
#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)
{
  double corner_pts[][3] = { {5.0, 2.0, 0.0},
                              {0.0, 0.0, 0.0} };
  char *edge_lens[] = {"1.0", "3.2", "1.5"};
  tag_t features[2];
  tag_t blocks[2];
  int i;
  for (i = 0; i < 2; i++)
  {
   
    if (UF_CALL(UF_MODL_create_block1(UF_NULLSIGN, corner_pts[i],
                                      edge_lens, &features[i])))
    {
      return;
    }
    /* The previous block creation routines created features. We
        need to obtain the body tags for UF_PART_export.
    */
    if (UF_CALL(UF_MODL_ask_feat_body(features[i], &blocks[i])))
    {
      return;
    }
  }
  UF_CALL(UF_PART_export("exported_blocks", 2, blocks));
}
/*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);
}