要首次添加一个视图可以用uc6481或者UF_DRAW_import_view:
uc6481 add view to drawing
extern int uc6481 (
const char * dwg_name,
const char * view_name,
const double * reference_pt,
const int view_status );
UF_DRAW_import_view
extern int UF_DRAW_import_view (
const tag_t drawing_tag,
const tag_t view_tag,
double dwg_reference_point[ 2 ],
UF_DRAW_view_info_t * view_info,
tag_t * draw_view_tag );
以下是帮助文档给出的例子:
/*
This example imports the BOTTOM view onto the drawing as an
active view, with a scale of 1.0, no anchor point. It uses the stored
reference point. The drawing member view inherits the model view's
boundary.
*/
#include <stdlib.h>
#include <stdio.h>
#include <uf.h>
#include <uf_defs.h>
#include <uf_draw.h>
#include <uf_draw_types.h>
#include <uf_obj.h>
#include <uf_part.h>
void ufusr(char *param, int *retcod, int param_len)
{
int ifail = 0;
double reference_point[2] = {10.0, 12.0};
tag_t drawing_tag = NULL_TAG;
tag_t part_tag = NULL_TAG;
tag_t view_tag = NULL_TAG;
tag_t draw_view_tag = NULL_TAG;
char error_message[133];
char *view_name = "BOTTOM";
UF_DRAW_view_info_t 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 = FALSE;
view_info.inherit_boundary = TRUE;
ifail = UF_initialize();
if( !ifail )
part_tag = UF_PART_ask_display_part();
if( !ifail && part_tag != NULL_TAG )
ifail = UF_DRAW_ask_current_drawing( &drawing_tag );
if( !ifail && part_tag != NULL_TAG && drawing_tag != NULL_TAG
)
{
ifail = UF_OBJ_cycle_by_name( view_name, &view_tag );
if( !ifail && view_tag != NULL_TAG )
{
ifail = UF_DRAW_import_view( drawing_tag, view_tag,
reference_point, &view_info,
&draw_view_tag );
}
}
printf( "UF_DRAW_import_view " );
if( ifail )
{
ifail = UF_get_fail_message( ifail, error_message );
printf( "fails. \nError is:%s\n", error_message );
}
else if( part_tag == NULL_TAG )
printf( "fails.\nError is: no active part.\n" );
else if ( drawing_tag == NULL_TAG )
printf( "fails.\nError is: no current drawing.\n" );
else if ( view_tag == NULL_TAG )
printf( "fails.\nError is: invalid view tag.\n" );
else
printf( "is successful.\n" );
ifail = UF_terminate();
} |