uf
获得图纸所有尺寸信息
#include <stdio.h>
#include <uf.h>
#include <uf_assem.h>
#include <uf_defs.h>
#include <uf_drf.h>
#include <uf_obj.h>
#include <uf_object_types.h>
#include <uf_part.h>
//获得图纸所有尺寸信息
char error_message[133] = "";
int ifail = 0;
tag_t dim_tag = NULL_TAG;
int dim_type;
double dim_origin[ 3 ];
UF_DRF_dim_info_t *dim_info;
// UF_DRF_draft_aid_text_info_t *text_info;
// int num_text , num_lines;
FILE *file1;
/* Initialize UG/Open API. */
ifail = UF_initialize();
/*获得一个尺寸类型 */
ifail = UF_OBJ_cycle_objs_in_part( UF_ASSEM_ask_work_part(),UF_dimension_type,&dim_tag );
file1 = fopen("C:\\CC\\cc\\5521_bef.dat","w+");
/* 获得信息 */
while( !ifail && dim_tag )
{
{
ifail = UF_DRF_ask_dim_info ( dim_tag, &dim_type,
&dim_origin[ 0 ],
&dim_info );
fprintf(file1,"dim_tag=%d, dim_type = %d \n" , dim_tag,dim_type );
fprintf(file1,"dim_origin[ 0 ]=%f, dim_origin[ 1 ] = %f, dim_origin[ 2 ] = %f \n" ,
dim_origin[ 0 ],dim_origin[ 1 ],dim_origin[ 2 ] );
fprintf(file1,"dim_info.num_lines=%d, dim_info.num_test=%d\n" , dim_info->num_lines,dim_info->num_text );
fprintf(file1,"dimation_value=%s, \n" , dim_info->text_info->text->string );
fprintf(file1,"d \n" );
/* 自由尺寸信息的记忆 */
if( !ifail )
UF_DRF_free_dimension( &dim_info );
}
/*获得一个尺寸类型 */
ifail = UF_OBJ_cycle_objs_in_part(
UF_ASSEM_ask_work_part(),
UF_dimension_type,
&dim_tag );
}
// UF_DRF_ask_dim_info sample
ifail = UF_get_fail_message( ifail, error_message );
uc1601( error_message,1 );
fclose(file1);
_____________________________________________________________________________ _
中磊UG二次开发教程 梅雷著 qq1821117007
学UG就上UG网 http://www.9sug.com/ |