PLM之家PLMHome-工业软件与AI结合践行者

Teamcenter ITK二次开发源码分享:创建测量单位unit of measures

[复制链接]

2014-1-15 19:39:16 5480 0

admin 发表于 2014-1-15 19:39:16 |阅读模式

admin 楼主

2014-1-15 19:39:16

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

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

x
) w9 ~( l1 L$ h! S* w
Teamcenter ITK二次开发源码分享:创建测量单位unit of measures
! E( _+ S7 Q7 R* B. z% @  V: ]# \4 ^$ g9 V
  1. #include <stdlib.h>
    , U9 }! }! r1 `" t) F- e+ x. g; _1 U
  2. #include <TC/tc.h>
    ! n9 P; C8 ?" d; L# w
  3. #include <sa/tcfile.h>8 z$ u, E3 B* t6 y* E! }( E
  4. #include <tccore/workspaceobject.h>
    % w0 s/ ^! R6 [! T% `
  5. #include <ae/ae.h>5 W# B* L) T; z  Y* ]
  6. #include <tccore/item.h>
      u! v5 S" m0 k$ B/ O
  7. # J( g1 v0 h5 f0 {; H
  8. #define ITK_CALL(x) {           \
    / z8 I+ E" R- M% D' a
  9.     int stat;                     \- r/ n. g9 W: K  q5 Z6 ?# R
  10.     char *err_string;             \
    / r. S7 h( K/ Q
  11.     if( (stat = (x)) != ITK_ok)   \  i7 `# \& S' ~7 \
  12.     {                             \( M: B; l, I# U% y* T% g5 H' b0 A
  13.     EMH_get_error_string (NULLTAG, stat, &err_string);                 \5 v" ?" @" O- B
  14.     printf ("ERROR: %d ERROR MSG: %s.\n", stat, err_string);           \4 d  c6 y+ c. Q9 {
  15.     printf ("FUNCTION: %s\nFILE: %s LINE: %d\n",#x, __FILE__, __LINE__); \
    - e; q( O% d8 s' H0 R9 I7 V, n5 v
  16.     if(err_string) MEM_free(err_string);                                \% F8 C; {  Q! B3 R; r. G1 N8 X
  17.     exit (EXIT_FAILURE);                                                   \
    # j% |& N$ R1 ^+ M
  18.     }                                                                    \7 m5 [6 p( |( S) d3 ?. x- F
  19. }
    * s( ]7 r. m# x. g
  20. #define EXIT_FAILURE 1 ' I& X! U  v" O. `. P: B, @+ c; |
  21.         8 b9 l- U) Y/ r6 w
  22. static void do_it(void)
    ' S) {  L$ A4 N' o: z3 [! Y
  23. {
      T, g3 B3 I7 b
  24.     int! Y4 ^# H6 t# ]; G' `6 j/ X
  25.         n_uom,
    ) c4 c+ U* q- g0 g3 i4 @
  26.         ii;
    - i3 }0 t! B- k: i' f
  27.     char( M: G/ I$ U6 w+ r9 W
  28.         *name;
    " v0 {. m# |) {9 L4 p, c! G" _; x) J
  29.     tag_t& P8 E0 v6 c; u3 r
  30.         *uoms,2 P2 P3 V. U5 d0 Q# x/ l
  31.         new_uom;
    8 |( ^  h& S! D. O  o) t! R4 B
  32.    
    ; j  y# W. G+ P, W
  33.     printf("Before UOM was created...\n");    5 d( ]* i  h$ N; S" I
  34.     ITK_CALL(UOM_extent(&n_uom, &uoms));
    : g0 v: m9 U5 i) r- j9 |8 N7 l6 G7 l
  35.     for (ii = 0; ii < n_uom; ii++)& }  j2 {' R: U+ ~& C6 ^
  36.     {- A6 O% Y" Z# U) b4 O
  37.         ITK_CALL(AOM_ask_name(uoms[ii], &name));- X5 U% M! D3 |9 y6 C8 l' w/ }* ?
  38.         printf("\t%s\n", name);- I: x& d: s6 ?1 o; L# I
  39.         if (name) MEM_free(name);
    " h  M: t9 A, e1 C) }
  40.     }! A* ]0 Z- E# z) c+ H# p. E
  41.     if (uoms) MEM_free(uoms);
    2 x1 o$ s( n& l4 B- e
  42.    
    " }0 a7 h2 f; j$ |2 \- E
  43.     ITK_CALL(UOM_create("inches", "in", &new_uom));3 O) s  h% I1 ?( e4 \" f
  44.     ITK_CALL(AOM_save(new_uom));8 S) _9 }/ K# D3 m
  45.     ' e, M3 H+ n4 d! m( v9 }
  46.     printf("\nAfter UOM was created...\n");   6 }4 Z* c# s4 l2 P
  47.     ITK_CALL(UOM_extent(&n_uom, &uoms));% J+ b* [! Q  A: h  E" B. u* w
  48.     for (ii = 0; ii < n_uom; ii++)
    6 i3 V& S/ B* h# L, g
  49.     {/ e1 D& ~! y) k3 s
  50.         ITK_CALL(AOM_ask_name(uoms[ii], &name)); P4 `# R7 B2 O! u: V
  51.         printf("\t%s\n", name);
    . I' |* f  f9 V' D3 O3 V* \
  52.         if (name) MEM_free(name);7 G( s: u2 Y. j/ v* t, f
  53.     }8 T% _: `0 t; O" P3 c
  54.     if (uoms) MEM_free(uoms);
    . a4 `" |0 X0 x0 `& N
  55. }7 c7 B7 m% ^5 M2 b

  56. 7 Z' w5 U4 J4 I' U6 J( n
  57. int ITK_user_main(int argc, char* argv[])
    , ~8 D  }' Z& W6 w/ f4 ?
  58. {0 }. M8 d2 |7 v/ C. P/ r
  59.     int6 k# P" n7 m3 z2 @# c
  60.         status = 0; $ g1 O! E2 J, d6 Y
  61.     char9 J, V7 C$ H' v
  62.         *message;1 E3 w" P. [' p4 g
  63.    
    7 H8 c$ {( {" c
  64.     ITK_initialize_text_services( 0 );' B( P6 e) t* M: `2 e
  65.     status = ITK_auto_login();
    ! e5 ~& B  t0 c# b; J* f
  66.    # C" ^- s  ?6 M. S. `% A! ~( T
  67.     if (  (status != ITK_ok)) printf("iMAN login NOT successful.\n");
    % m( U  ]* p. s2 P1 P& u0 M( y
  68.     else" e, S0 d) s$ W9 y
  69.     {
    , j6 k- U$ g# O: T: J& @
  70.         printf("iMAN login successful.\n");  Y% }  T7 e. Z: e: Q0 \6 G
  71.         ITK_set_journalling(TRUE);
    2 \4 `: t4 S" I2 z% q
  72.         do_it();
    9 [5 `7 y5 f3 o1 _. }6 Q" q. |
  73.     }
    9 l0 P) R  B- b. `
  74.     ITK_exit_module(TRUE);! a1 L1 z8 W$ H& s  t) L
  75.     return status;
    : g, z6 F& e7 O2 Q, U& J* I2 n
  76. }
复制代码

! R/ q+ W: O: p. q; t& n3 V$ [0 y9 l, o6 K) M" @. u2 |  ~

' K+ i; _1 J4 T9 J( l: F- |! e5 G
上海点团信息科技有限公司,承接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二次开发专题模块培训报名开始啦

    我知道了