标题: 【求助】UG 中如何实现对象的transform? [打印本页] 作者: ddp_ 时间: 2004-12-7 16:21 标题: 【求助】UG 中如何实现对象的transform? 比如要使UG中的一个实体进行旋转变换!
UG open API中说明使用:
uf5947_
Transform objects according to a previously defined matrix.
The upper limit on the number of objects to transform is 32767. The object types supported for non-uniform scaling are the same as those supported by non-uniform scaling in interactive Unigraphics.
函数原型如下:
extern void uf5947_ (
const double * rp1,
const tag_t * np2,
const int * ip3,
const int * ip4,
const int * ip5,
const int * ip6,
tag_t * nr7,
tag_t * nr8,
int * ir9 );
可是在使用此函数时返回值表明成功,但是实际没有完成;郁闷ing!!
程序代码如下:
/*****************************************************************************
**
** test_trans.c
**
** Description:
** Contains Unigraphics entry points for the application.
**
*****************************************************************************/
//Transform 参数
//input
// double * rp1; //Defined Transformation Matrix
// tag_t * np2; //Array of object identifiers.
int ip3=1; //Number of objects in np2 array
int ip4 = 1; // 1-move, 2-copy
int ip5 = 0; //Destination Layer, 0-the original layer, -1 - the work layer
int ip6 = 1; //Trace Curve Status, 1 means on, 2 means off
//output
tag_t nr7[100]; //List of copied object identifiers
tag_t nr8[100]; //Group of trace curves
int ir9; //Status Code: 0 - Success
//* fetch the matrix containing mirro information to move an
//* object around X-Y mirror plane
//得到实体的边界筐
UF_CALL ( UF_MODL_ask_bounding_box ( solid_tag[0], bound ));
/*//使用此函数生产旋转变换的矩阵
extern void uf5945_ ( //Returns a matrix to perform a rotation around an arbitrary axis
double * rp1, //Origin Of The Axis - Absolute Coordinates
double * rp2, //Direction Vector - Absolute Coordinates
double * rp3, //Rotation Angle In Degrees
double * rr4, //Rotation Matrix
int * ir5 ); //Status Code: 0 - Success; 1 - Direction Vector Is A Zero Vector
*/
//对实体进行旋转变换:
uf5947_( transform, solid_tag, [$ip3, &ip4, &ip5, &ip6, nr7, nr8, &ir9)]
sprintf( cc, "\nthe trans Status Code is : %d\n" , ir9);
UF_CALL(UF_UI_open_listing_window());
UF_CALL(UF_UI_write_listing_window(cc));
}
/* Explicit Activation
** This entry point is used to activate the application explicitly, as in
** "File->Execute UG/Open->User Function..." */
extern DllExport void ufusr( char *parm, int *returnCode, int rlen )
{
/* Initialize the API environment */
int errorCode = UF_initialize();
if ( 0 == errorCode )
{
/* TODO: Add your application code here */
do_it();
/* Terminate the API environment */
errorCode = UF_terminate();
}
/* Print out any error messages */
PrintErrorMessage( errorCode );
}
/*****************************************************************************
** Utilities
*****************************************************************************/
/* Unload Handler
** This function specifies when to unload your application from Unigraphics.
** If your application registers a callback (from a MenuScript item or a
** User Defined Object for example), this function MUST return
** "UF_UNLOAD_UG_TERMINATE". */
extern int ufusr_ask_unload( void )
{
return( UF_UNLOAD_UG_TERMINATE );
}作者: 深夜摔键盘 时间: 2004-12-7 17:31
uf5947_( transform, solid_tag, [$ip3, &ip4, &ip5, &ip6, nr7, nr8, &ir9)]
用这个函数的前提是必须知道旋转矩阵,就是你想让你的对象沿X,Y,Z转多少个角度,你就要生成你的旋转矩阵,4*4的方阵,然后使用这个函数进行几何变换。