PLM之家PLMHome-工业软件践行者

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

[复制链接]

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

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

admin 楼主

2013-11-27 10:03:27

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

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

x
NX二次开发中有关表达式的操作代码分享
2 K3 v1 D4 u. e5 T9 k; b! v  ]# K
# Y" k( d( ^* L; c6 g+ H5 o# x& [9 ]

  1. * X" m2 n- O& }4 O9 s
  2. <p>static void do_UGopen_api(void)! u8 f1 w" z# g8 h
  3. {4 j' J7 F' e* ~) c% \, d6 s
  4. // create block 1  M, Y* h: `9 F- \0 D
  5. double coner[3] = {0,0,0};
    ' [; Q. b3 u" d& x* i
  6. char *edges[3] = {"l=100","w=100","h=20"};: o8 B% ^: a0 A" R, d- H1 A
  7. tag_t blk_tag;7 \5 J& d" Z* C) i
  8. UF_MODL_create_block1(UF_NULLSIGN,coner,edges,&blk_tag);2 f* O2 H3 B  j# m4 ^7 G* E
  9. // create a hole
    + K* S! V4 j1 W0 }+ @
  10. double dir[3] = {0,0,1};
    & j$ {; j# x9 z( q: A5 F( t
  11. double coner1[3] = {50,50,0};3 W- L+ X$ C1 ]! u' r
  12. tag_t cyl_tag;. a" }6 U1 R# H2 q
  13. UF_MODL_create_cyl1(UF_POSITIVE,coner1,"h+30","50",dir,&cyl_tag);</p><p> /*
    2 k4 g& r' V  o* {' ^- x+ ?
  14. create expression and delete it- ]( C+ i3 R' V+ `
  15. */
    ; [1 ^: I1 `) e
  16. // create expression
    1 S# r5 P$ V' O4 A1 \, r
  17. char *exp_str,*str,*value;
    , F( e7 y( F. z# {& o4 g" F4 ~
  18. exp_str = "new_exp= 100";
    4 q  @; l( c+ o9 b& h/ h: z7 j$ f
  19. tag_t new_exp,old_exp_tag;
    , e- D* D+ d( Q; C; b0 I( a) D
  20. char *str_exp,*str_old_exp;. O0 X! V6 N8 Y
  21. int nums;
    2 ?8 Z: P/ L9 E! G0 ^! P" i
  22. tag_t *exps;5 b0 Y# c: c, s) y) x
  23. // before create the new expression, we need check if the expressions have been created or not
    5 ]8 T7 i3 q( W+ x# X/ x/ ^3 ^
  24. // if having, we delete it! L$ T. _, D$ ^. T/ S4 f
  25. tag_t part= UF_PART_ask_display_part();# p. `% _  |/ m' T
  26. UF_MODL_ask_exps_of_part(part,&nums,&exps);
    8 n& m7 ?% ?+ I6 D! w8 m  ~" L# z
  27. UF_UI_open_listing_window();
      @. v& |4 o: t, ?; J0 i
  28. if(nums != 0 ): U# |7 v* j  s  T0 @$ P, l* F- ~
  29. {
      E% D" Q% V  b  p# P2 o
  30.   for(int i = 0 ; i < nums; i++)( R, O3 Z$ h! H4 \, W
  31.   {
    / I( a2 I# p( K2 ]7 k
  32.    UF_MODL_ask_exp_tag_string(exps[i],&str_old_exp);& H& k( H3 u. X0 N
  33.    UF_MODL_dissect_exp_string(str_old_exp,&str,&value,&old_exp_tag);
    ! A; {, L- y& t
  34.    if(!strcmp(str,"new_exp"))$ b# x6 W$ l4 d  ]2 ?
  35.    {
    3 W/ e) o8 @! y  u) J3 u
  36.      //UF_UI_write_listing_window("we find the alreay expressions ==> new_exp and delete it \n");- X& m6 f' ?# F" {" W
  37.      //delete expression
    # I$ p, `3 ]5 q2 }% ^" i
  38.      UF_MODL_delete_exp(str);
    8 n! `! w) q3 Y. p/ ?) b, \+ _) f
  39.      UF_MODL_update();
    2 K) {' J7 m! _' f5 I
  40.      break;
    ! _# \0 H, U4 W6 k1 K* U/ K
  41.    }% S9 f; T0 k; \: h! z& I# o' f3 B
  42.   }
    ; j: G6 `2 F3 }( s6 B
  43. }1 W0 m2 ]  X" ]! j' p! f1 j  L5 G
  44. //UF_UI_write_listing_window("we can not find the expression ==> new_exp and create it \n");
    ( h9 Q2 T$ i) r  f
  45. UF_MODL_create_exp_tag(exp_str,&new_exp);0 b6 T0 o2 @2 y# ]
  46. UF_UI_write_listing_window("The new created expression is : \n");1 w% U6 I4 G  r9 l0 r6 q+ m# q
  47. UF_MODL_ask_exp_tag_string(new_exp,&str_exp);
    * P5 w. e) D1 a/ J8 p. F
  48. UF_UI_write_listing_window(str_exp);" j! O! Y: V5 X% ]' Q% _, C6 S
  49. UF_free(str_exp);
    , o* x6 A$ B% L$ l6 |( y
  50. UF_free(str);
    / M/ ]1 I  H; X* t& K' O8 ^) H
  51. UF_free(value);# N' U8 e; M; O9 J/ E" D
  52. UF_UI_write_listing_window("\n");</p><p>}</p>
复制代码

7 {& u* F' |+ s9 c. X+ H
上海点团信息科技有限公司,承接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二次开发专题模块培训报名开始啦

    我知道了