点击查看详细介绍

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

misnn 9年前 1783 0

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


函数结构:
UF_ATTR_assign
(
tag_t object,
char * title,
UF_ATTR_value_t value
)

函数说明:
分配给指定的对象的属性。如果属性不存在指定的属性类型,然后创建属性;否则,修改其现有的值。调用程序必须调用UF_MODL_update()来传播属性 更改。传递一个对象标签会导致修改或创建一个属性关于该对象。在零件标记传递会导致修改或创建该零件的零件属性。该对象驻留必须完全加载的部分。如果属性的类型UF_ATTR_string或UF_ATTR_reference,的其价值的最大长度由UF_ATTR_MAX_STRING_BUFSIZE限制。如果属性是类型UF_ATTR_time的,则该值被假设为在运行程序的计算机的当前时区。该值,存储在NX时,从该时区为UTC转换。类型UF_ATTR_time属性的有效范围是从1月11970年31 - 12月2105。

函数参数:
第1个参数为输入:
object代表参数变量,tag_t 为输入参数类型,兼职或部分属性标记。

第2个参数为输入:
输入char * 字符类型的参数,参数的变量格式为title,属性名称(最大字符长度为UF_ATTR_MAX_TITLE BUFSIZE)

第3个参数为输入:
value代表参数变量,UF_ATTR_value_t 为输入参数类型,类型化的属性值

UF_ATTR_assign函数实例代码演示:
[quote]
#include <stdlib.h>
#include <stdio.h>
#include <uf.h>
#include <uf_attr.h>
#include <uf_cfi.h>
#include <uf_curve.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)
{
/* Variable Declarations */
tag_t pnt;
double zero[3] = { 0,0,0 };
UF_ATTR_value_t value;
/* Create a point to assign the attributes to */
UF_CALL(UF_CURVE_create_point(zero, &pnt));
/* Assign an integer attribute to the point */
value.type = UF_ATTR_integer;
value.value.integer = 1;
UF_CALL(UF_ATTR_assign(pnt, "INTEGER_ATTRIBUTE", value));
/* Assign a real attribute to the point */
value.type = UF_ATTR_real;
value.value.real = 1.5;
UF_CALL(UF_ATTR_assign(pnt, "REAL_ATTRIBUTE", value));
/* Assign a date and time attribute to the point */
value.type = UF_ATTR_time;
/* Init to current date and time */
UF_CALL(uc4583("", "", value.value.time));
UF_CALL(UF_ATTR_assign(pnt, "DATE_AND_TIME_ATTRIBUTE", value));
/* Assign a null attribute to the point */
value.type = UF_ATTR_null;
UF_CALL(UF_ATTR_assign(pnt, "NULL_ATTRIBUTE", value));
/* Assign a string attribute to the point */
value.type = UF_ATTR_string;
value.value.string = "This is a string";
UF_CALL(UF_ATTR_assign(pnt, "STRING_ATTRIBUTE", value));
}
/*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);
}



[/quote]

0

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