NX二次开发中有关表达式的操作代码分享
NX二次开发中有关表达式的操作代码分享<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_POSITIVE,coner1,"h+30","50",dir,&cyl_tag);</p><p> /*
create expression and delete it
*/
// create expression
char *exp_str,*str,*value;
exp_str = "new_exp= 100";
tag_t new_exp,old_exp_tag;
char *str_exp,*str_old_exp;
int nums;
tag_t *exps;
// before create the new expression, we need check if the expressions have been created or not
// if having, we delete it
tag_t part= UF_PART_ask_display_part();
UF_MODL_ask_exps_of_part(part,&nums,&exps);
UF_UI_open_listing_window();
if(nums != 0 )
{
for(int i = 0 ; i < nums; i++)
{
UF_MODL_ask_exp_tag_string(exps,&str_old_exp);
UF_MODL_dissect_exp_string(str_old_exp,&str,&value,&old_exp_tag);
if(!strcmp(str,"new_exp"))
{
//UF_UI_write_listing_window("we find the alreay expressions ==> new_exp and delete it \n");
//delete expression
UF_MODL_delete_exp(str);
UF_MODL_update();
break;
}
}
}
//UF_UI_write_listing_window("we can not find the expression ==> new_exp and create it \n");
UF_MODL_create_exp_tag(exp_str,&new_exp);
UF_UI_write_listing_window("The new created expression is : \n");
UF_MODL_ask_exp_tag_string(new_exp,&str_exp);
UF_UI_write_listing_window(str_exp);
UF_free(str_exp);
UF_free(str);
UF_free(value);
UF_UI_write_listing_window("\n");</p><p>}</p>
页:
[1]