购买与咨询 NX 二次开发视频教程,请联系微信号:13890821008 QQ号:85585969
函数结构:
UF_MODL_ask_features_of_exp
(
tag_t exp,
int * number_of_features,
tag_t * * features
)
函数说明:
获取所有使用提供的表达式的功能。
函数参数:
第1个参数为输入:
exp代表参数变量,tag_t 为输入参数类型,查询表达式
第2个参数为输出:
输出int * 整数型的参数,参数的变量格式为number_of_features,返回的特征标签的数
第3个参数为输出:
features代表参数变量,tag_t * * 为输出参数类型,有关定表达式功能。该数组必须通过调用UF_free释放。
UF_MODL_ask_features_of_exp函数实例代码演示:
#include <uf.h>
#include <uf_defs.h>
#include <stdio.h>
#include <uf_modl.h>
#include <uf_part.h>
#include <uf_assem.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)
{
int i,j, num_exps;
tag_t *oexps;
tag_t part;
int num_feats;
tag_t *feats; char *string;
char *feat_type;
char *feat_name;
/* Test UF_MODL_ask_features_of_exp */
part = UF_ASSEM_ask_work_part();
UF_CALL(UF_MODL_ask_exps_of_part(part, &num_exps, &oexps));
printf ("Total number of expressions in part = %d\n", num_exps);
for (i=0; i<num_exps; i++)
{
if (UF_CALL(UF_MODL_ask_exp_tag_string(oexps[i], &string)))
{
UF_terminate();
}
else
printf("\nExpression #%d: %s\n",i, string);
if(UF_CALL(UF_MODL_ask_features_of_exp(oexps[i], &num_feats,
&feats)))
{
if (num_feats > 0) UF_free(feats);
UF_terminate();
}
else
{
printf ("Number of times expression %s is used = %d\n",
string, num_feats);
printf ("The following features are affected:\n");
for (j=0; j<num_feats; j++)
{
UF_CALL(UF_MODL_ask_feat_name(feats[j], &feat_name));
UF_CALL(UF_MODL_ask_feat_type(feats[j], &feat_type));
printf("Feature %u is named %s and is of type %s\n",
feats[j], feat_name, feat_type);
}
}
if (num_feats > 0) UF_free(feats);
}
UF_free(oexps);
}
/*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);
}