购买与咨询 NX 二次开发视频教程,请联系微信号:13890821008 QQ号:85585969
函数结构:UF_FLTR_ask_box_zone( tag_t box_zone, char* name, double centroid [ 3 ], double corner [ 3 ], double matrix [ 9 ]) 函数说明:
输出由一个标记指定的箱区的参数。转角值表示偏移位置可以是从重心位置减去,得到的最小角,或添加到质心位置,得到的最大角。转角值始终处于价值阳性。说边框有0,0,0最低角落的100,100,100最大角落。质心是在((0,0,0)+(100,100,100))/ 2=(50,50,50),而在角计算为((100,100,100) - (0,0,0))/ 2 =(50,50,50)。
函数参数:
第1个参数为输入:
box_zone代表参数变量,tag_t 为输入参数类型,带标签被查询
第2个参数为输出:
输出char* 字符类型的参数,参数的变量格式为name,被查询区名称(30个字符最大值)
第3个参数为输出:
输出double 双精度类型的参数,参数的变量格式为centroid [ 3 ],区的质心(在绝对坐标。)
第4个参数为输出:
输出double 双精度类型的参数,参数的变量格式为corner [ 3 ],角矢量
第5个参数为输出:
输出double 双精度类型的参数,参数的变量格式为matrix [ 9 ],区的定位。
UF_FLTR_ask_box_zone函数实例代码演示:
在下面的例子中,代码创建一个框区域和平面区域。该代码还编辑创建的区域,以及有关它们的参数查询。
[quote]
#include <stdio.h>
#include <uf.h>
#include <uf_part.h>
#include <uf_fltr.h>
#define UF_CALL(X) (report( __FILE__, __LINE__, #X, (X)))
static void zone_function(void);
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)
{
zone_function();
}
/*ARGSUSED*/
void ufusr(char *param, int *retcode, int paramLen)
{
if (!UF_CALL(UF_initialize()))
{
do_ugopen_api();
UF_CALL(UF_terminate());
}
}
int ufusr_ask_unload(void)
{
return (UF_UNLOAD_IMMEDIATELY);
}
static void zone_function(void)
{
tag_t box_zone_tag;
tag_t plane_zone_tag;
tag_t part_tag;
tag_t displayed_part_tag;
int uf_stat=UF_FLTR_OK;
double centroid[3];
double corner[3];
double orientation[9];
double origin[3];
char name[30]="";
char newname[] = "newzonename";
/* open part file and create some zones */
printf("Creating part... \n");
UF_CALL(UF_PART_new("zone_example.prt",
2, /* english units = 2 */
&part_tag));
centroid[0] = 1.0;
centroid[1] = 2.0;
centroid[2] = 3.0;
corner[0] = 1.0;
corner[1] = 1.0;
corner[2] = 1.0;
orientation[0] = 1.0;
orientation[1] = 0.0;
orientation[2] = 0.0;
orientation[3] = 0.0;
orientation[4] = 1.0;
orientation[5] = 0.0;
orientation[6] = 0.0;
orientation[7] = 0.0;
orientation[8] = 1.0;
displayed_part_tag = UF_PART_ask_display_part();
/*********** Create Box Zone **************/
UF_CALL(UF_FLTR_create_box_zone(displayed_part_tag,
"ZONE_BOX1", centroid,
corner, orientation,
&box_zone_tag));
printf ("Created box zone 'ZONE_BOX1' \n:"
"Tag is %d status is %d\n ",
box_zone_tag, uf_stat );
/*********** Create plane Zone **************/
UF_CALL(UF_FLTR_create_plane_zone(displayed_part_tag,
"ZONE_PLANE1", origin,
orientation,
&plane_zone_tag));
printf ("Created plane zone 'ZONE_PLANE1': \n"
"Tag is %d status is %d\n ",
plane_zone_tag, uf_stat );
/*********** Modify Box Zone **************/
centroid[0] = -5.0;
centroid[1] = -10.0;
centroid[2] = -20.0;
corner[0] = 2.0;
corner[1] = 4.0;
corner[2] = 7.0;
orientation[0] = 0.5;
orientation[1] = 0.5;
orientation[2] = 0.5;
orientation[3] = 0.5;
orientation[4] = 0.5;
orientation[5] = 0.5;
orientation[6] = 0.5;
orientation[7] = 0.5;
orientation[8] = 0.5;
UF_CALL(UF_FLTR_edit_box_zone( box_zone_tag, newname,
centroid, corner,
orientation));
/*********** Modify plane Zone **************/
origin[0] = 10.0;
origin[1] = -20.0;
origin[2] = 30.0;
UF_CALL(UF_FLTR_edit_plane_zone(plane_zone_tag, newname,
origin, orientation));
/*********** Ask about zones *****************/
UF_CALL(UF_FLTR_ask_plane_zone( plane_zone_tag,
name, origin,
orientation));
UF_CALL(UF_FLTR_ask_box_zone( box_zone_tag, name,
centroid, corner,
orientation));
printf("\n New name: %s\n", name);
}
[/quote]