iCAx开思网
标题:
关于UF_KF的函数请教
[打印本页]
作者:
thermal
时间:
2005-10-17 11:30
标题:
关于UF_KF的函数请教
extern int UF_KF_create_child_rule (
tag_t part_of_rule,
const char * name_chain,
const char * rule_name,
const char * child_class_name,
int num_parameters,
char ** parameter_names,
char ** parameter_rules,
char ** generated_name );
请问一下这个函数是实现KF的add child rule的功能吗?请问一下具体的各个参数是代表什么意思的呢?和这些参数对应的在KF里面时表示什么的呢?谢谢
作者:
frecar
时间:
2005-10-17 13:56
把jon_wu以前发给我的一个例子共享一下:
希望能解除你的疑惑
extern UFUNEXPORT int UF_KF_create_child_rule (
tag_t part_of_rule, /* <I> Part to create or modify rule in */
const char *name_chain, /* <I> Reference chain of instance here rule will be created or modified. If create then must be "Root:" or NULL. Child rules can only be created on the "Root:" */
const char *rule_name, /* <I> Name of rule. */
const char *child_class_name, /* <I> Class of instance */
int num_parameters, /* <I> number of parameters in the parameter_names array */
char **parameter_names, /* <I,len:num_parameters> num_parameters array of names of parameters specified by the user.*/
char **parameter_rules, /* <I,len:num_parameters> num_parameters array of rules for the parameters whose names are in "parameter_names" above. Each rule may or may not have a trailing
semicolon. */
char **generated_name /* <OF> name generated for the child object. Currently always returns NULL. */
);
part_of_rule - 当前part的tag <BR> name_chain - 总是“Root:”
rule_name - 要创建的child rule的名字
child_class_name - 类名,如ug_block <BR> num_parameters - 有多少个参数规则要输入,如3个
parameter_names - 那些参数名字要输入,如"length", "width", "height"
parameter_rules - 对应的参数规则或值,如“10”,“20”,“30”
generated_name - 没有使用
例:
tag_t part_of_rule = UF_ASSM_ask_work_part();
char *name_chain = "Root:";
char *rule_name = "myblock";
char *child_class_name = "ug_block";
int num_parameters = 3;
char **parameter_names = NULL;
char **parameter_rules = NULL;
char *generated_name = NULL;
int error = 0;
int i = 0;
parameter_names = (char **) UF_allocate_memroy( num_parameters * sizeof ( char * ), [$error )] parameter_rules = (char **) UF_allocate_memroy( num_parameters * sizeof ( char * ), [$error )] for ( i = 0; i < num_parameters; i++ )
{
parameter_names = (char *) UF_allocate_memroy( MAX_LINE_SIZE * sizeof ( char ), [$error )] parameter_rules = (char *) UF_allocate_memroy( MAX_LINE_SIZE * sizeof ( char ), [$error )]
}
strcpy( parameter_names[0], "length" );
strcpy( parameter_rules[0], "10" );
strcpy( parameter_names[1], "width" );
strcpy( parameter_rules[1], "20" );
strcpy( parameter_names[2], "height" );
strcpy( parameter_rules[2], "30" );
error = UF_KF_create_child_rule( part_of_rule, name_chain, rule_name, child_class_name,
num_parameters, parameter_names, parameter_rules, [$generated_name )]
UF_MODL_update();
/* free memory */
for (i=0; i< num_parameters; i++)
{
UF_free( parameter_names );
UF_free( parameter_rules );
}
UF_free( paramter_names );
UF_free( parameter_rules );
作者:
thermal
时间:
2005-10-18 09:29
谢谢了 大哥
作者:
thermal
时间:
2005-10-18 10:17
还有一个问题,我如果要在空白文件中生成child rule的话,part_of_rule应该怎么设?还有就是UF_allocate_memory需要哪个头文件? 我这个生成不了啊 能不能给我一个KF和API共同开发的源程序看看,谢谢
作者:
frecar
时间:
2005-10-21 19:46
上面的程序应该已经非常清楚了
1.part_of_rule = UF_ASSM_ask_work_part();
2.在uf.h里
作者:
ffhi
时间:
2008-11-24 11:09
好贴子就是能解决问题
欢迎光临 iCAx开思网 (https://www.icax.org/)
Powered by Discuz! X3.3