在制图中标准垂直尺寸,麻烦看下代码按书上的老出错
extern DllExport void ufsta( char *param, int *returnCode, int rlen ){
/* Initialize the API environment */
if( UF_CALL(UF_initialize()) )
{
/* Failed to initialize */
return;
}
/* TODO: Add your application code here */
tag_t part_tag;
part_tag=UF_PART_ask_display_part() ;
int num_views;
char message;
char drawing_name="my_drawing";
UF_DRAW_info_t drawing_info;
tag_t drawing_tag =NULL_TAG;
tag_t view_tag=NULL_TAG;
tag_t front_view_tag=NULL_TAG;
char *front_view_name="FRONT";
double front_reference_point={210,400};
tag_t tri_view_tag=NULL_TAG;
char *tri_view_name="TFR-TRI";
double tri_reference_point={630,120};
UF_DRAW_proj_dir_t botton_projection_direction=UF_DRAW_project_below;
double botton_reference_piont={210,120};
tag_t botton_view_tag=NULL_TAG;
UF_DRAW_proj_dir_t left_projection_directiom=UF_DRAW_project_left;
double left_reference_piont={630,400};
tag_t left_view_tag=NULL_TAG;
drawing_info.drawing_scale=1.0;
drawing_info.projection_angle=UF_DRAW_THIRD_ANGLE_PROJECTION;
drawing_info.size .metric_size_code=UF_DRAW_A1;
drawing_info.size_state=UF_DRAW_METRIC_SIZE;
drawing_info.units =UF_PART_METRIC;
UF_DRAW_create_drawing(drawing_name,&drawing_info,&drawing_tag);
UF_DRAW_open_drawing(drawing_tag);
UF_DRAW_view_info_t view_info;
UF_DRAW_initialize_view_info(&view_info);
view_info.view_status=UF_DRAW_ACTIVE_VIEW;
view_info.anchor_point=NULL_TAG;
view_info.view_scale=1.0;
view_info.use_ref_pt=TRUE;
view_info.inherit_boundary=TRUE;
UF_OBJ_cycle_by_name_and_type(part_tag,front_view_name,UF_view_type,TRUE,&view_tag);
if (view_tag!=NULL_TAG)
{
UF_DRAW_import_view(drawing_tag,view_tag,front_reference_point,&view_info,&front_view_tag);
UF_DRAW_define_view_auto_rect(front_view_tag);
}
view_tag=NULL_TAG;
UF_OBJ_cycle_by_name_and_type(part_tag,tri_view_name,UF_view_type,TRUE,&view_tag);
if (view_tag!=NULL_TAG)
{
UF_DRAW_import_view(drawing_tag,view_tag,tri_reference_point,&view_info,&tri_view_tag);
UF_DRAW_define_view_auto_rect(tri_view_tag);
}
if (front_view_tag!=NULL_TAG)
{
UF_DRAW_add_orthographic_view(drawing_tag,front_view_tag,botton_projection_direction,botton_reference_piont,&botton_view_tag);
UF_DRAW_define_view_auto_rect(botton_view_tag);
}
if (front_view_tag!=NULL_TAG)
{
UF_DRAW_add_orthographic_view(drawing_tag,front_view_tag,left_projection_directiom,left_reference_piont,&left_view_tag);
UF_DRAW_define_view_auto_rect(left_view_tag);
}
UF_DRAW_ask_num_views(NULL_TAG,&num_views);
UF_UI_open_listing_window();
sprintf(message,"当前图纸共有:%d个视图 ",num_views);
UF_UI_write_listing_window(message);
tag_t object=NULL_TAG, front_objects;
int subtype, type, count=0;
UF_VIEW_cycle_objects( front_view_tag, UF_VIEW_VISIBLE_OBJECTS, &object );
while(object!=NULL_TAG)
{
UF_OBJ_ask_type_and_subtype (object,&type, &subtype );
if(type==UF_solid_type&& subtype==UF_solid_edge_subtype )
{
front_objects = object;
count++;
}
UF_VIEW_cycle_objects( front_view_tag, UF_VIEW_VISIBLE_OBJECTS, &object );
}
UF_DRF_object_t object1;
UF_DRF_object_t object2;
UF_DRF_init_object_structure( &object1 );
UF_DRF_init_object_structure( &object2 );
object1.object_tag = front_objects[ 0 ];
object1.object_assoc_type = UF_DRF_end_point;
object1.object_assoc_modifier = UF_DRF_first_end_point;
object1.object_view_tag = front_view_tag;
object2.object_tag = front_objects[ 1 ];
object2.object_assoc_type = UF_DRF_end_point;
object2.object_assoc_modifier = UF_DRF_first_end_point;
object2.object_view_tag = front_view_tag;
UF_DRF_text_t dim_text;
dim_text.lines_app_text = 0;
dim_text.appended_text = NULL;
dim_text.user_dim_text = NULL;
double dimension_3d_origin[ 3 ] = { 360, 400, 0.0 };
tag_t dimension_tag=NULL_TAG;
UF_DRF_create_vertical_dim( &object1, &object2,
&dim_text, dimension_3d_origin, &dimension_tag );
UF_DRAW_upd_out_of_date_views(drawing_tag);
/* Terminate the API environment */
UF_CALL(UF_terminate());
} 第一 确定你编译的版本 和 你说的 书上的 是不是 同一个版本
如果是
那就是书有问题 ,或者是你看书设置的环境有问题,那里报错,看codedebug下
如果版本不一致,那很有可能, 这种问题 你自己通过报错哪一行解决了 UF_DRF_create_vertical_dim( &object1, &object2, &dim_text, dimension_3d_origin, &dimension_tag );
书上用的是NX7.5我用的是NX8.5,就知道这行出错了。这一行错误但是我找不错误原因。 C:\Users\pc\Desktop\捕获.PNG[/img
当前图纸共有:4个视图 *** ERROR code 68 at line 207 in drawing_view.cpp:
+++ Encountered unexpected NULL pointer. See system log for details
UF_DRF_create_vertical_dim( &object1, &object2, &dim_text, dimension_3d_origin, &dimension_tag );
空指针,还是没找到! 北方的候鸟 发表于 2014-8-13 20:43
C:\Users\pc\Desktop\捕获.PNG[/img
当前图纸共有:4个视图 *** ERROR code 68 at line 207 in drawing_vie ...
那就分析这个地方啦
我没法给你解答 没时间给你调试这个
你多看看 我录的 NX9 的二次开发视频教程吧书上的都是比较老的东西了
页:
[1]