Code:
// Include files
#include "uf.h"
#include "uf_part.h"
#include "uf_assem.h"
#include "uf_attr.h"
#include "uf_obj.h"
#include "uf_object_types.h"
#include "uf_modl.h"
#include "uf_sket.h"
#include "windows.h"
#include "string.h"
#include "stdio.h"
#include "stdlib.h"
#include "iostream.h"
// Main routine
extern void main( char argc, char *argv[] )
{
cout << "initializing UGS\n";
// initialize session
UF_initialize();
if (!UF_is_initialized())
{
cout << "error: UF_is_initialized failed!\n";
return;
}
// loading part
char part_name[] = "E:\\PAUL\\CIME_Object\\CAD_UNIGRAPHICS_17\\test.prt";
tag_t part_tag;
UF_PART_load_status_t e_status;
cout << "loading part: " << part_name << "\n";
UF_PART_open(part_name, &part_tag, &e_status );
UF_free_string_array( e_status.n_parts, e_status.file_names );
// reading attributes
UF_ATTR_part_attr_p_t attr;
int attr_count;
UF_ATTR_ask_part_attrs ( part_tag, &attr_count, &attr );
cout << "reading attributes: (" << attr_count << " attributes found)\n";
for ( int a_idx = 0; a_idx < attr_count; a_idx++ )
cout << " title: " << attr[a_idx].title << " value: " << attr[a_idx].string_value << "\n";
UF_free( attr );
// reading decription
cout << "reading description\n";
char *desc;
UF_PART_ask_description ( part_tag, &desc );
cout << " descr: " << desc << "\n";
UF_free( desc );
// reading features
cout << "reading features\n";
tag_t feature;
int type;
char *feature_name;
char *feature_type;
type = UF_feature_type;
feature = NULL_TAG;
UF_OBJ_cycle_objs_in_part( part_tag, type, &feature );
while (feature != 0)
{
UF_MODL_ask_feat_name ( feature, &feature_name );
UF_MODL_ask_feat_type ( feature, &feature_type );
cout << " name: " << feature_name << " type: " << feature_type << "\n";
if ( !strcmp(feature_type,"SWP104"))
{
uf_list_p_t sketches= NULL;
UF_SKET_ask_feature_sketches (feature, &sketches );
int sketch_count;
UF_MODL_ask_list_count (sketches, &sketch_count);
cout << " reading sketches: (" << sketch_count << " sketches found)" << "\n";
// SKETCH ORIGIN
UF_MODL_delete_list( &sketches );
}
UF_OBJ_cycle_objs_in_part( part_tag, 205 , &feature );
}
// closing parts/session
cout << "closing all parts\n";
UF_PART_close_all ();
cout << "terminating session\n";
UF_terminate();
}