PLM之家PLMHome-国产软件践行者

[二次开发源码] NX二次开发中有关表达式的操作代码分享

[复制链接]

2013-11-27 10:03:27 3556 0

admin 发表于 2013-11-27 10:03:27 |阅读模式

admin 楼主

2013-11-27 10:03:27

请使用QQ关联注册PLM之家,学习更多关于内容,更多精彩原创视频供你学习!

您需要 登录 才可以下载或查看,没有账号?注册

x
NX二次开发中有关表达式的操作代码分享
5 G$ v1 P5 X9 | 0 O: i% M' b. ~. c4 J* H6 o$ q( w
  1. ! ]7 o9 s3 @2 Y2 f7 F
  2. <p>static void do_UGopen_api(void)- X3 P) [- U: I$ e/ m- J* |
  3. {) U! U* _# o/ n- ~
  4. // create block 1
    8 ^1 C) r: `+ {" [
  5. double coner[3] = {0,0,0};
    ; D* y7 J) `. G
  6. char *edges[3] = {"l=100","w=100","h=20"};
    6 `7 p; P+ j, v4 a
  7. tag_t blk_tag;/ ~, u: T( Y6 X4 H
  8. UF_MODL_create_block1(UF_NULLSIGN,coner,edges,&blk_tag);* D8 B9 ^& M: s* U" k8 _0 j
  9. // create a hole, B6 ?1 u' ?0 f! \: Z
  10. double dir[3] = {0,0,1};, i% b, g  z) y. C1 P2 c
  11. double coner1[3] = {50,50,0};
    / k3 O) Z3 \! j' l' j
  12. tag_t cyl_tag;
    5 f" s8 {+ M  Q% o
  13. UF_MODL_create_cyl1(UF_POSITIVE,coner1,"h+30","50",dir,&cyl_tag);</p><p> /*
    2 I# R+ s3 k' z9 @) B( h5 [% t
  14. create expression and delete it8 E4 l: L6 l  w' }3 d3 N, G, L$ l
  15. */7 V, p4 k9 V3 @& i4 {
  16. // create expression+ K, w! p3 ~$ b
  17. char *exp_str,*str,*value;" M; ]* C  V, f% e; D) I. z# O
  18. exp_str = "new_exp= 100";
    ' J* s  s! M! i) w1 H+ @2 ^+ Z
  19. tag_t new_exp,old_exp_tag;
    # F/ P0 @. F3 C, _8 P
  20. char *str_exp,*str_old_exp;
    3 [) [  ?/ l! ]: B* f0 K
  21. int nums;
    # i4 i) K; K" Q) \, S% b
  22. tag_t *exps;0 g! z& V4 q9 K( @2 {
  23. // before create the new expression, we need check if the expressions have been created or not
    ) c5 s& n3 O; a! W3 M
  24. // if having, we delete it
    8 M8 B6 a. s. J2 ~8 T
  25. tag_t part= UF_PART_ask_display_part();9 }& v/ u0 o9 {" C/ p& C  A
  26. UF_MODL_ask_exps_of_part(part,&nums,&exps);7 s) D" I# `% S) l
  27. UF_UI_open_listing_window();
      j! U5 Q: h7 U! _8 q; F2 m
  28. if(nums != 0 )' Y4 c+ F' i/ V. t4 F) _
  29. {0 Z* l- l: o, l+ ~
  30.   for(int i = 0 ; i < nums; i++)) h) h. n/ o3 f; U5 U  t5 K$ f
  31.   {1 y7 `; F; A, _4 v$ \# \+ p
  32.    UF_MODL_ask_exp_tag_string(exps[i],&str_old_exp);
    + j  D' _* b* w; s0 o2 m
  33.    UF_MODL_dissect_exp_string(str_old_exp,&str,&value,&old_exp_tag);
    " ?- x% R3 O1 o+ `; G3 Y0 W4 x, y3 Z
  34.    if(!strcmp(str,"new_exp")). t5 L( N* ?; w- ~  y. F
  35.    {
    1 q' s3 z& ~  X1 L& ^% r3 y
  36.      //UF_UI_write_listing_window("we find the alreay expressions ==> new_exp and delete it \n");
    + q) }; }8 M3 t9 l$ [
  37.      //delete expression
    $ S1 C% H/ W1 F* c4 `
  38.      UF_MODL_delete_exp(str);+ f+ V& B! \1 Z6 A, Y
  39.      UF_MODL_update();
    8 |9 R" V! u# a' z3 ^' z$ o. Y9 m
  40.      break;
    * r, s8 E0 J8 V* X
  41.    }5 W5 ^8 ]) y) h4 n2 U! U
  42.   }
    9 G' ]; ~( e0 n2 N9 Y" w
  43. }7 M1 e5 x( `2 Y3 y8 Q
  44. //UF_UI_write_listing_window("we can not find the expression ==> new_exp and create it \n");
    , K, H* F6 E8 g0 T# O
  45. UF_MODL_create_exp_tag(exp_str,&new_exp);+ H" {. C  `  E7 Y
  46. UF_UI_write_listing_window("The new created expression is : \n");
    0 h3 I+ H# F( Q6 J% O$ X& C$ A
  47. UF_MODL_ask_exp_tag_string(new_exp,&str_exp);
    : H! }7 [. r0 V$ v
  48. UF_UI_write_listing_window(str_exp);
    7 F" R1 c# C' i4 O
  49. UF_free(str_exp);% B" U- o; a) g
  50. UF_free(str);+ n3 j% {% W, j( l4 j! b/ c3 T: o  u
  51. UF_free(value);  t% i, o1 d% J) g" a
  52. UF_UI_write_listing_window("\n");</p><p>}</p>
复制代码

# o9 [7 Z+ h( R
上海点团信息科技有限公司,承接UG NX,CATIA,CREO,Solidworks 等CAx软件,Teamcenter,3D Experience等PLM软件,工业4.0数字化软件的实施\二次开发\培训相关业务,详情QQ 939801026 Tel 18301858168 网址 doTeam.tech
回复

使用道具 举报

发表回复

您需要登录后才可以回帖 登录 | 注册

返回列表 本版积分规则

  • 发布新帖

  • 在线客服

  • 微信

  • 客户端

  • 返回顶部

  • x
    温馨提示

    本网站(plmhome.com)为PLM之家工业软件学习官网站

    展示的视频材料全部免费,需要高清和特殊技术支持请联系 QQ: 939801026

    PLM之家NX CAM二次开发专题模块培训报名开始啦

    我知道了