admin 发表于 2013-11-26 16:14:18

获取部件中所有的表达式,并对表达式进行更改,更新模型

获取部件中所有的表达式,并对表达式进行更改,更新模型

结果:

Before change the value :
p0=20
p1=h
w=100
h=20
l=200
Start to change the expressions :
p0=20
p1=h
w=100
h=20
l=200


<p>
static void do_ugopen_api(void)
{
// create block 1
double coner = {0,0,0};
char *edges = {"l=100","w=100","h=20"};
tag_t blk_tag;
UF_MODL_create_block1(UF_NULLSIGN,coner,edges,&blk_tag);
// create a hole
double dir = {0,0,1};
double coner1 = {50,50,0};
tag_t cyl_tag;
UF_MODL_create_cyl1(UF_NEGATIVE,coner1,"h","20",dir,&cyl_tag);</p><p> // get the expressions
tag_t part=UF_PART_ask_display_part();
int number_of_exps = 0;
tag_t *exps;
char *str;
char expStr;
UF_UI_open_listing_window();
UF_MODL_ask_exps_of_part(part,&number_of_exps,&exps);
UF_UI_write_listing_window("Before change the value : \n");
for(int i = 0 ; i < number_of_exps;i++)
{
      
   UF_MODL_ask_exp_tag_string(exps,&str);
   UF_UI_write_listing_window(str);
   UF_UI_write_listing_window("\n");
   UF_free(str);
}

UF_free(exps);
//Start to change the expressions
UF_UI_write_listing_window("Start to change the expressions : \n");
char *exp_str = "l = 200";
UF_MODL_edit_exp(exp_str);
UF_MODL_update();
exp_str = "\0";
//get the new exps
UF_MODL_ask_exps_of_part(part,&number_of_exps,&exps);
for(int i = 0 ; i < number_of_exps;i++)
{
   UF_MODL_ask_exp_tag_string(exps,&str);
   UF_UI_write_listing_window(str);
   UF_UI_write_listing_window("\n");
   UF_free(str);
}
UF_free(exps);
}</p><p> </p>
页: [1]
查看完整版本: 获取部件中所有的表达式,并对表达式进行更改,更新模型