iCAx开思网
标题:
ug实体的复制和平移问题
[打印本页]
作者:
xiaochao0221
时间:
2005-5-28 23:11
标题:
ug实体的复制和平移问题
最近小弟做毕业设计,刚接触ug二次开发,想实现实体的复制和平移,但是函数
FTN(uf5947
)的返回值
resp=3,不为0
,不知应该怎样改正,请高手赐教,源代码如下
#include <stdio.h>
#include <uf.h>
#include <uf_ui.h>
#include <uf_curve.h>
#include <math.h>
#include <uf_modl.h>
#include <uf_trns.h>
#include <uf_part.h>
#include "create_circular_iset.h"
#define UF_CALL(X) (report( __FILE__, __LINE__, #X, (X)))
static int report( char *file, int line, char *call, int irc)
{
if (irc)
{
char messg[133];
printf("%s, line %d: %s\n", file, line, call);
(UF_get_fail_message(irc, messg)) ?
printf(" returned a %d\n", irc) :
printf(" returned error %d: %s\n", irc, messg);
}
return(irc);
}
static void do_ugopen_api(void)
{
double DN=700,D=815,D1=780,D3=740,B=36,d=18,NUM=28,THIN=10;
double origin[3] = {0.0, 0.0, 0.0};
double orig_iset[3] = {0.0, -390, 0.0};
double direction[3] = {0.0, 0.0, 1.0};
UF_CURVE_line_t sline,sline1,sline2,sline3,sline4,sline5,sline6,sline7,sline8;
tag_t line,line1,line2,line3,line4,line5,line6,line7,line8;
int obj_count;
UF_FEATURE_SIGN mode_sign=UF_NULLSIGN;
tag_t generators[9],generators1[3],*objects;
char *body_limit[2]={"0.0","360.0"};
char *offsets[2]={"0.0","0.0"};
UF_MODL_SWEEP_TRIM_object_p_t trim_data=NULL;
char height[256];
char diam_iset[256];
char degree[256];
char num[256];
char message[133];
UF_FEATURE_SIGN sub = UF_NEGATIVE;
tag_t iset_id,feat_obj;
uf_list_p_t feat_list;
double matrix[16];
int copy_Flag=2, layer=-1, curveFlag=2,count=3,resp;
tag_t curve_id;
height[0]='\0';
diam_iset[0]='\0';
num[0]='\0';
degree[0]='\0';
message[0]='\0';
sprintf(height,"%f",B-3);
sprintf(diam_iset,"%f",d);
sprintf(num,"%f",NUM);
sprintf(degree,"%f",360/NUM);
sline.start_point[0]=DN/2;
sline.start_point[1]=0;
sline.start_point[2]=B;
sline.end_point[0]=D3/2;
sline.end_point[1]=0;
sline.end_point[2]=B;
UF_CALL(UF_CURVE_create_line([$sline,&line))]
sline1.start_point[0]=D3/2;
sline1.start_point[1]=0;
sline1.start_point[2]=B;
sline1.end_point[0]=D3/2+3;
sline1.end_point[1]=0;
sline1.end_point[2]=B-3;
UF_CALL(UF_CURVE_create_line([$sline1,&line1))]
sline2.start_point[0]=D3/2+3;
sline2.start_point[1]=0;
sline2.start_point[2]=B-3;
sline2.end_point[0]=D/2;
sline2.end_point[1]=0;
sline2.end_point[2]=B-3;
UF_CALL(UF_CURVE_create_line([$sline2,&line2))]
sline3.start_point[0]=D/2;
sline3.start_point[1]=0;
sline3.start_point[2]=B-3;
sline3.end_point[0]=D/2;
sline3.end_point[1]=0;
sline3.end_point[2]=0;
UF_CALL(UF_CURVE_create_line([$sline3,&line3))]
sline4.start_point[0]=D/2;
sline4.start_point[1]=0;
sline4.start_point[2]=0;
sline4.end_point[0]=DN/2+THIN+2+3*sqrt(3);
sline4.end_point[1]=0;
sline4.end_point[2]=0;
UF_CALL(UF_CURVE_create_line([$sline4,&line4))]
sline5.start_point[0]=DN/2+THIN+2+3*sqrt(3);
sline5.start_point[1]=0;
sline5.start_point[2]=0;
sline5.end_point[0]=DN/2+THIN+2;
sline5.end_point[1]=0;
sline5.end_point[2]=3;
UF_CALL(UF_CURVE_create_line([$sline5,&line5))]
sline6.start_point[0]=DN/2+THIN+2;
sline6.start_point[1]=0;
sline6.start_point[2]=3;
sline6.end_point[0]=DN/2+THIN+2;
sline6.end_point[1]=0;
sline6.end_point[2]=13;
UF_CALL(UF_CURVE_create_line([$sline6,&line6))]
sline7.start_point[0]=DN/2+THIN+2;
sline7.start_point[1]=0;
sline7.start_point[2]=13;
sline7.end_point[0]=DN/2;
sline7.end_point[1]=0;
sline7.end_point[2]=13+(THIN+2)/sqrt(3);
UF_CALL(UF_CURVE_create_line([$sline7,&line7))]
sline8.start_point[0]=DN/2;
sline8.start_point[1]=0;
sline8.start_point[2]=13+(THIN+2)/sqrt(3);
sline8.end_point[0]=DN/2;
sline8.end_point[1]=0;
sline8.end_point[2]=B;
UF_CALL(UF_CURVE_create_line([$sline8,&line8))]
generators[0]=line;
generators[1]=line1;
generators[2]=line2;
generators[3]=line3;
generators[4]=line4;
generators[5]=line5;
generators[6]=line6;
generators[7]=line7;
generators[8]=line8;
UF_CALL(UF_MODL_create_revolution(generators,9,trim_data,body_limit,offsets,
origin,false,true,origin,direction,mode_sign,[$objects,&obj_count))]
UF_free(objects);
UF_CALL(UF_MODL_create_cyl1(sub,orig_iset,height,diam_iset,direction,
[$iset_id))]
UF_CALL(UF_MODL_create_list([$feat_list))]
UF_CALL(UF_MODL_put_list_item(feat_list,iset_id));
UF_CALL(UF_MODL_create_circular_iset(0,origin,direction,num,degree,feat_list,[$feat_obj))]
UF_CALL(UF_MODL_delete_list([$feat_list))]
generators1[0]=*objects;
generators1[1]=iset_id;
generators1[2]=feat_obj;
FTN(uf5943)(orig_iset,matrix );
FTN(uf5947)(matrix,generators1,[$count,©_Flag,&layer,&curveFlag,&curve_id,NULL,&resp)]
UF_UI_open_listing_window();
sprintf(message,"resp=%d,*objects=%d\n",resp,*objects);
UF_UI_write_listing_window(message);
}
/*ARGSUSED*/
void ufusr(char *param, int *retcode, int param_len)
{
if (!UF_CALL(UF_initialize()))
{
do_ugopen_api();
UF_CALL(UF_terminate());
}
}
int ufusr_ask_unload(void)
{
return (UF_UNLOAD_IMMEDIATELY);
}
作者:
mizzle
时间:
2005-5-29 09:41
你检查一下
FTN(uf5943)(orig_iset,matrix );
这里的输入,你用的是orig_iset应该是你要移动的一个向量
比如你要从orig_iset移动到新的一点a = {x,y,z};
那么应该定义length = {orig_iset[0] - x,orig_iset[1] - y,orig_iset[2] - z};
FTN(uf5943)(length,matrix );
而你输入的这个是让你希望移动的物体移动y方向390吗
或者你查一下你的matrix的返回值是多少?
作者:
会思考的石头
时间:
2005-5-29 11:29
3 - Invalid Object (Not Alive Or Not
Transformable)
你创建的旋转特征,圆柱特征。。。那些tag是特征tag,而这个函数要求对象的tag。
欢迎光临 iCAx开思网 (https://www.icax.org/)
Powered by Discuz! X3.3