|
马上注册,结交更多同行朋友,交流,分享,学习。
您需要 登录 才可以下载或查看,没有帐号?注册
x
为什么我写的代码,对UF_MODL_create_extruded创建的特征有效,对直接在UG中新建的拉伸特征无效?
我遍历了部件中的每一个对象,对每一个对象都调用了UF_MODL_ask_extrusion,可见不是TAG传递错误的问题,那为什么还是无效?
难道UF_MODL_ask_extrusion只对UF_MODL_create_extruded创建的特征有效麽?
下面是我写的代码:
#include <uf.h>
#include <uf_exit.h>
#include <uf_ui.h>
#include <uf_part.h>
#include <uf_obj.h>
#include <uf_modl.h>
#include <stdlib.h>
#include <stdio.h>
#include <uf_curve.h>
#include <math.h>
#include <string.h>
#include <uf_csys.h>
#include <uf_mtx.h>
#if ! defined ( __hp9000s800 ) && ! defined ( __sgi ) && ! defined ( __sun )
# include <strstream>
# include <iostream>
using std:strstream;
using std::endl;
using std::ends;
using std::cerr;
#else
# include <strstream.h>
# include <iostream.h>
#endif
#include "UF_MODL_ask_extrusion_EX.h"
tag_t create_line(double start_x,double start_y,double start_z,double end_x,double end_y,double end_z)
{
UF_CURVE_line_t line_coords;
UF_CURVE_line_p_t p_line_coords=&line_coords;
line_coords.start_point[0]=start_x;
line_coords.start_point[1]=start_y;
line_coords.start_point[2]=start_z;
line_coords.end_point[0]=end_x;
line_coords.end_point[1]=end_y;
line_coords.end_point[2]=end_z;
tag_t line_tag=NULL_TAG;
UF_CURVE_create_line(p_line_coords,&line_tag);
return(line_tag);
}
void object_cycle_all()
{
logical region_specified=true;
logical solid_creation=true;
int n_objects=3;//被拉伸的曲线的条数
tag_t objects[3];//指向一个包含被拉伸的曲线的ID的数组
objects[0]=create_line(0,0,0,1,2,3);
objects[1]=create_line(1,2,3,4,5,6);
objects[2]=create_line(4,5,6,0,0,0);
tag_t* p_object=objects;
double direction[3]={0.0,0.0,0.0};//拉伸的方向向量
double region_point[3]={0.0,0.0,0.0};
char* taper_angle="0.0";//拉伸后沿轴的倾斜角度
char* limits[2]={"0","0"};//拉伸的幅度上下限
char* offsets[2]={"0.0","0.0"};
UF_MODL_SWEEP_TRIM_object_t trim_ptr;
tag_t trim[3]={NULL_TAG,NULL_TAG,NULL_TAG};
trim_ptr.trim_objects=trim;
trim_ptr.trim_count=3;
trim_ptr.sign=UF_MODL_SWEEP_TRIM_NONE;
trim_ptr.thru_bodies=NULL;
trim_ptr.num_thru_bodies=0;
UF_MODL_SWEEP_TRIM_object_p_t p_trim_ptr;
int error=0;
//------------------------------
int i=0;
tag_t display_part_tag=UF_PART_ask_display_part();
tag_t object_tag=NULL_TAG;
int num=0;
char* feature_type="";
FILE* fp=fopen("D:\\对象的编号.txt","w");
do
{
object_tag=UF_OBJ_cycle_all(display_part_tag,object_tag);
//i=ask_extruded(object_tag);
num++;
UF_MODL_ask_feat_name(object_tag,&feature_type);
error=UF_MODL_ask_extrusion(object_tag, &n_objects, &p_object,
&p_trim_ptr, &taper_angle, limits, offsets, region_point,
®ion_specified, &solid_creation, direction);
fprintf(fp,"\n对象%d的id为:%u,其类型为:%s\n错误号为:%d\n",
num,object_tag,feature_type,error);
}while(object_tag!=NULL_TAG);
fclose(fp);
}
extern "C" DllExport void ufusr( char *parm, int *returnCode, int rlen )
{
/* Initialize the API environment */
int errorCode = UF_initialize();
if ( 0 == errorCode )
{
object_cycle_all();
/* TODO: Add your application code here */
/* Terminate the API environment */
errorCode = UF_terminate();
}
/* Print out any error messages */
PrintErrorMessage( errorCode );
}
extern "C" int ufusr_ask_unload( void )
{
return( UF_UNLOAD_IMMEDIATELY );
}
/* PrintErrorMessage
**
** Prints error messages to standard error and the Unigraphics status
** line. */
static void PrintErrorMessage( int errorCode )
{
if ( 0 != errorCode )
{
/* Retrieve the associated error message */
char message[133];
UF_get_fail_message( errorCode, message );
/* Print out the message */
UF_UI_set_status( message );
// Construct a buffer to hold the text.
ostrstream error_message;
// Initialize the buffer with the required text.
error_message << endl
<< "Error:" << endl
<< message
<< endl << endl << ends;
// Write the message to standard error
cerr << error_message.str();
}
}
打印错误号error的值总是非0,一般是580001和875004。 |
|