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

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

[复制链接]

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

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

admin 楼主

2014-1-15 19:39:16

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

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

x

+ U; H, e/ b1 g; {Teamcenter ITK二次开发源码分享:创建测量单位unit of measures! p4 S* Z6 H3 ?& P- G9 \
# [; A0 v9 q: M1 j
  1. #include <stdlib.h>! e% u; D( ?5 W$ F- R
  2. #include <TC/tc.h>
    + w2 W" r- z9 K7 V8 f2 `2 R
  3. #include <sa/tcfile.h>' }' S7 _* u! Q7 c& ~! r$ W$ b
  4. #include <tccore/workspaceobject.h>
    * _) F; d! I; j+ M3 V
  5. #include <ae/ae.h>6 G% u' S0 E' q
  6. #include <tccore/item.h>: N  j* n/ R7 t- X* B* |

  7. - Y# Z3 ~: ?# Y9 m+ u' d5 j
  8. #define ITK_CALL(x) {           \
    - N5 Y8 y7 M% ^; A  _
  9.     int stat;                     \
    1 N% c0 W0 p/ V! w& u% t) T
  10.     char *err_string;             \
    . S* A/ N/ v, l" Y. O
  11.     if( (stat = (x)) != ITK_ok)   \  K1 n+ m# r1 D( ]; K$ n- {/ r
  12.     {                             \
    5 ^0 L! W& {+ g' _* [
  13.     EMH_get_error_string (NULLTAG, stat, &err_string);                 \
    , ?8 ^3 G- n3 @; ~5 R# }, o! K0 z
  14.     printf ("ERROR: %d ERROR MSG: %s.\n", stat, err_string);           \9 G7 Q1 Z5 c: b3 T
  15.     printf ("FUNCTION: %s\nFILE: %s LINE: %d\n",#x, __FILE__, __LINE__); \
    $ I' r1 z& v/ U* I5 G& ^+ E  X8 @
  16.     if(err_string) MEM_free(err_string);                                \
    + S# a! u# a2 m/ S8 _& K, j
  17.     exit (EXIT_FAILURE);                                                   \  Y0 F" S1 W7 h0 z7 V4 c( f
  18.     }                                                                    \
    6 R8 J: D! \$ n: A% ?3 u( \
  19. }
    4 l' e# Q' g7 q, r
  20. #define EXIT_FAILURE 1 4 y9 i! ]1 p- M  o5 j
  21.         
    $ I; P  A7 n. }. |5 B* ^
  22. static void do_it(void)
    6 Q- R0 B7 s0 Q  S" Y+ G) Y
  23. {& }# D4 D% E( f2 f
  24.     int
    # m6 ?- v2 V' k% r! D0 |) ~- F
  25.         n_uom,
    ; m& J. y2 S0 V5 A; e/ ^
  26.         ii;8 R+ Z+ q6 H7 q. ?4 f
  27.     char
    7 I% B9 O8 V# ]9 l
  28.         *name;
    + U1 U+ I2 n' T8 s8 Z/ K' c+ s* u
  29.     tag_t
    ; `5 D7 v" C% |9 [
  30.         *uoms,5 u1 l" V) v! d; w: c# I2 a
  31.         new_uom;
    5 D* A; u9 q: F( e) {% ~
  32.    
    1 z' c6 y, _6 k* S( a9 J
  33.     printf("Before UOM was created...\n");    3 L" d6 S# ~0 P  ?# ^) \: C
  34.     ITK_CALL(UOM_extent(&n_uom, &uoms));$ n3 P! {+ D9 S% Q
  35.     for (ii = 0; ii < n_uom; ii++)
    & r4 l( Y/ R6 }! N, N1 |+ |
  36.     {* W9 t( j6 |- Y3 G7 f5 r
  37.         ITK_CALL(AOM_ask_name(uoms[ii], &name));- C. l- O$ \5 y! t7 j6 _( {
  38.         printf("\t%s\n", name);
    ) N$ g+ Q/ h  a4 X. v, c3 h
  39.         if (name) MEM_free(name);
    4 y* X' }6 t1 y' t* J) W
  40.     }
    4 g: Q: @; ?( q& R  k
  41.     if (uoms) MEM_free(uoms);
    / O- u$ P8 l  g! ^" Q
  42.    
    9 @. U' B. P" C, s! O2 z% c
  43.     ITK_CALL(UOM_create("inches", "in", &new_uom));
    1 q/ w+ V, G3 I1 k) T& c1 x
  44.     ITK_CALL(AOM_save(new_uom));9 U8 E* W% h* F
  45.       I( D) @) |3 t( A6 C; V
  46.     printf("\nAfter UOM was created...\n");   9 Q% H. u0 e8 }+ d
  47.     ITK_CALL(UOM_extent(&n_uom, &uoms));
    6 V! z/ G3 E/ c7 N" U, E' B3 b
  48.     for (ii = 0; ii < n_uom; ii++)! L/ Y. G- B7 U: X1 R# |$ ~# y1 j% U
  49.     {* E0 T: P+ b" _
  50.         ITK_CALL(AOM_ask_name(uoms[ii], &name))
    $ u4 h! h) ]9 i) R' j% R
  51.         printf("\t%s\n", name);
    1 \* I/ y0 j# T2 n7 |# w  C
  52.         if (name) MEM_free(name);( l/ u: C1 j2 g
  53.     }
    ' u' C8 c: J. L  F& ]# V) J4 a$ s- b
  54.     if (uoms) MEM_free(uoms);
    4 M" v% {4 n8 D2 g' Y
  55. }
    " R% w8 G: `0 z; H
  56. / f6 Q+ U/ `+ h; H0 ]$ K
  57. int ITK_user_main(int argc, char* argv[])
    : |  {" t$ W" a6 M% y8 }$ m* Y$ j# }; G" p
  58. {
    1 `  v- }# h! s0 o0 O$ ^9 w+ k
  59.     int
    1 J. d- C5 R# U  |- S+ \
  60.         status = 0;
    2 v% k% \% [. A3 @
  61.     char
    3 Z2 I" z; B/ E! [# e) ^2 p0 j, R
  62.         *message;
    ( d) O7 O6 e. C5 q+ Z" ]. i" t
  63.     ( W1 q4 D8 e; r2 ^
  64.     ITK_initialize_text_services( 0 );: v4 p% ^1 \8 `8 E9 J! r& H
  65.     status = ITK_auto_login();
    1 B0 D) Y, o. l! p' w* a) g
  66.    * k2 u# p" C, T) m" A. F8 L& f5 W: n
  67.     if (  (status != ITK_ok)) printf("iMAN login NOT successful.\n");% K7 d2 n" C8 g! }! S+ ~
  68.     else
    ; b5 m3 L7 s+ S9 @- Y  v+ h% @3 u2 v
  69.     {
    9 b8 w' L& O1 h  v& t3 X
  70.         printf("iMAN login successful.\n");
    6 f% S9 h$ f+ N& x
  71.         ITK_set_journalling(TRUE);
    ) @8 A; Q4 o& C. h+ y+ l
  72.         do_it();: I# {, x# Q) w9 }! i- t$ e2 t
  73.     }
    3 ^% ~: M; ]; |& v3 y  m
  74.     ITK_exit_module(TRUE);
    2 O: F& r2 x3 N3 B6 D
  75.     return status;
      \$ P6 o* x8 B3 K  \' l
  76. }
复制代码

$ P  z+ C6 ~, g0 z6 a1 E% t) Y; y% h, j( H. r) O

  I% g. Q' v# Z8 t1 B* j$ _8 ?
上海点团信息科技有限公司,承接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二次开发专题模块培训报名开始啦

    我知道了