给大家一个例子。
#include <uf_ui.h>
#include <uf_defs.h>
#include <uf_part.h>
#include <uf_assem.h>
void RetrieveAllParts(tag_t child_tag)
{
tag_t* ChildPartOccs;
int PartNum = UF_ASSEM_ask_part_occ_children(child_tag , [$ChildPartOccs)]
for( int i = 0 ; i < PartNum ; i++)
{
char PartName[ MAX_LINE_SIZE + 1 ];
char RefsetName[ MAX_ENTITY_NAME_SIZE + 1 ];
char InstanceName[ MAX_ENTITY_NAME_SIZE + 1 ];
double Origin[3];
double CsysMatrix[9];
double Transform[4][4];
char Buf[ 1024 ] = "";
UF_ASSEM_ask_component_data(ChildPartOccs,PartName , RefsetName ,
InstanceName , Origin , CsysMatrix , Transform);
UF_UI_write_listing_window( "art name is " );
UF_UI_write_listing_window( PartName );
UF_UI_write_listing_window( "\nInstance name is " );
UF_UI_write_listing_window( InstanceName );
tag_t ProtoTypeTag =
UF_ASSEM_ask_prototype_of_occ ( ChildPartOccs );
sprintf( Buf, "\t The Proto type tag is %d", ProtoTypeTag);
UF_UI_write_listing_window( Buf );
sprintf( Buf, "\t The occ tag is %d \n", ChildPartOccs);
UF_UI_write_listing_window( Buf );
UF_UI_write_listing_window( "\n" );
RetrieveAllParts(ChildPartOccs);
}
UF_free(ChildPartOccs);
}
void RetrieveAssem()
{
char PartName[ UF_CFI_MAX_PATH_NAME_SIZE ] = "";
char Buf[ 1024 ] = "";
UF_UI_open_listing_window();
tag_t DisplayPart = UF_PART_ask_display_part();
UF_PART_ask_part_name( DisplayPart, PartName);
UF_UI_write_listing_window( "Display Part Name is " );
UF_UI_write_listing_window( PartName );
sprintf(Buf,"\nPart Tag :%d\n",DisplayPart);
UF_UI_write_listing_window( Buf );
tag_t RootPartOcc = UF_ASSEM_ask_root_part_occ(DisplayPart);
UF_PART_ask_part_name( RootPartOcc, PartName);
UF_UI_write_listing_window( "Root Part Occ Name is " );
UF_UI_write_listing_window( PartName );
sprintf( Buf,"\nPart Tag :%d\n", RootPartOcc );
UF_UI_write_listing_window( Buf );
RetrieveAllParts(RootPartOcc);
} |