点击查看详细介绍

UF_FLTR_create_box_zone() 函数的参数解释说明、函数详细用法,以及实例代码演示

misnn 9年前 1359 0

购买与咨询 NX 二次开发视频教程,请联系微信号:13890821008  QQ号:85585969  


函数结构:
UF_FLTR_create_box_zone
(
tag_t part_tag,
char * name,
double centroid [ 3 ],
double corner [ 3 ],
double orientation [ 9 ],
tag_t * zone_tag
)

函数说明:
该函数是创建一个box箱体并返回它的tag标记.放置点是box中心(绝对坐标).需要指定方体的矢量角点和矢量方向。

函数参数:
第1个参数为输入:
part_tag代表参数变量,tag_t 为输入参数类型,指定在哪个PART部件中创建。

第2个参数为输入:
输入char * 字符类型的参数,参数的变量格式为name,要创建的box方体的名称。

第3个参数为输入:
输入double 双精度类型的参数,参数的变量格式为centroid [ 3 ],
box方体的中心点(在绝对坐标。)

第4个参数为输入:
输入double 双精度类型的参数,参数的变量格式为corner [ 3 ],
矢量角点

第5个参数为输入:
输入double 双精度类型的参数,参数的变量格式为orientation [ 9 ],法向方向(
相对于绝对坐标的)。

第6个参数为输出:
zone_tag代表参数变量,tag_t * 为输出创建的box。

UF_FLTR_create_box_zone函数实例代码演示:
在下面的例子代码中,创建一个box方体和平面。该代码演示如何编辑和创建、以及有关它们的参数查询。
[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]

0

最新回复 (0)
请登录后发表新帖