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

*******************************************************************************/

/*
This code assumes that a part is loaded, and that the drawing contains 
a member view, "TOP@1".
*/

#include <stdlib.h>
#include <stdio.h>
#include <uf.h>
#include <uf_defs.h>
#include <uf_draw.h>
#include <uf_layout.h>
#include <uf_view.h>
void ufusr(char *param, int *retcod, int param_len)
{
  int	ifail = 0;
  int	modeling_view = 1;
  int	drawing_view = 2;
  int	OK = 1;
 tag_t	view_tag = NULL_TAG;
 char	error_message[MAX_LINE_SIZE+1] = "";
 char *	view_name = "TOP@1";
 char	layout_name[MAX_ENTITY_NAME_SIZE+1] = "";
 char	work_view_name[MAX_ENTITY_NAME_SIZE+1] ="";
 logical	is_expanded = FALSE;
    
 ifail = UF_initialize();
 
 /* Enter the Drafting state */
 if ( !ifail)
   ifail = uc6476(drawing_view);
   
 if ( ifail == OK )
   ifail = 0;
   	      
  if( !ifail )
   ifail = UF_VIEW_ask_tag_of_view_name( view_name, &view_tag );
  
  /* Test and validate expansion of a drawing member view. */       
                                
  if ( !ifail && view_tag )
   ifail = UF_VIEW_expand_view( view_tag );
    
 /* Ensure that the view is in the expanded state. */   
  if( !ifail )
    ifail = UF_VIEW_is_expanded( &is_expanded );
    
  /* Unexpand the currently expanded view. */
  if ( ! ifail && is_expanded )
    ifail = UF_VIEW_unexpand_work_view();
    	
   /* Enter the Modeling state. */
   if ( !ifail) 
    ifail = uc6476(modeling_view);
    
  if ( ifail == OK )
    ifail = 0;
  
  /* Ask the names of the current layout and work view. */  
  if ( !ifail )
    ifail = uc6466( layout_name, work_view_name );
    	
  if ( !ifail )
    ifail = UF_VIEW_ask_tag_of_view_name( work_view_name, 
                                          &view_tag );
                                             
   /* Test and validate the expansion of the modeling work view. */
   if ( !ifail )
    ifail = UF_VIEW_expand_view( view_tag );
    
  printf( "UF_VIEW_expand_view for %s ", work_view_name );
  if( ifail )
  {
    ifail = UF_get_fail_message( ifail, error_message );
    printf( "fails.\nError is: %s\n", error_message );
  }
  else    
    printf( "is successful.\n" );
    
  ifail = UF_terminate();
}

