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

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

[复制链接]

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

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

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

x
! I; f. Z1 ^( B* f) D3 p: k
Teamcenter ITK二次开发源码分享:创建测量单位unit of measures
7 @- U5 Z" x- B. O7 B, Z2 w9 J
" _2 U! ?+ L. `
  1. #include <stdlib.h>! u* r2 c, X& Q3 h
  2. #include <TC/tc.h>- s7 ~) `5 {; X% j# m% t) b: r" Y
  3. #include <sa/tcfile.h>2 |1 a- `/ M  d" ~% a* }8 P
  4. #include <tccore/workspaceobject.h>& o5 |% ~: a- u! X9 ^' a' E
  5. #include <ae/ae.h>
    ! X, L" z; [/ p, U9 N/ G, A: W
  6. #include <tccore/item.h>" b! M1 q7 Q7 v3 y* ~( K
  7. " H4 n7 o* z7 z4 {4 z8 }- u' t& e& v
  8. #define ITK_CALL(x) {           \0 C5 s2 ~% f) e, z. P: {: {/ U
  9.     int stat;                     \
    . a4 r9 `2 G4 V6 T' q
  10.     char *err_string;             \  s" u6 l- f$ \5 p
  11.     if( (stat = (x)) != ITK_ok)   \
    5 n* L; D4 Q# d& _5 F( X+ _
  12.     {                             \* `3 Z6 |* }! `2 L9 a0 |
  13.     EMH_get_error_string (NULLTAG, stat, &err_string);                 \  B: I# K1 _: w: e  E
  14.     printf ("ERROR: %d ERROR MSG: %s.\n", stat, err_string);           \+ U' w6 {! b2 X" a& l7 ~* X
  15.     printf ("FUNCTION: %s\nFILE: %s LINE: %d\n",#x, __FILE__, __LINE__); \& V. }( E( }1 Z5 v: S
  16.     if(err_string) MEM_free(err_string);                                \3 [1 m, @+ y: B2 _$ ?, ]6 i$ K
  17.     exit (EXIT_FAILURE);                                                   \7 w# \' k" a: P
  18.     }                                                                    \) Q0 e  Y3 Q& [; e* @7 z. Q3 e' Q
  19. }
    8 Q+ U. s$ Q. T, S
  20. #define EXIT_FAILURE 1 ( u5 y# n& V# l! R4 z2 Z2 h4 \
  21.         
    : X9 l0 p; Q; Z& n8 ~/ t
  22. static void do_it(void)4 ]1 a! i. q5 H! j8 R, n0 e9 n" X
  23. {) g5 Z3 l0 P& Q7 h/ m; t9 I+ G
  24.     int
    6 o& _9 ^( Y1 a1 c- ?
  25.         n_uom,
    ( p- g! b3 w4 \  x
  26.         ii;
    9 ]8 _: F& ~5 d$ I0 G, @0 m* q
  27.     char8 ]" ~7 d+ }# Y" n4 h: ?: U1 `( `- v& E. {) {
  28.         *name;
    9 `3 K$ ~. {  Z( p
  29.     tag_t/ {# M6 f. _* K% q. c3 T
  30.         *uoms,* S: y# `* L, _+ @+ ?
  31.         new_uom;! z# P3 K, y, B* A
  32.     4 X5 k6 c; w2 p$ I- `$ v
  33.     printf("Before UOM was created...\n");    : J/ q# Q, T- x$ v0 Q/ Z9 Z
  34.     ITK_CALL(UOM_extent(&n_uom, &uoms));
    - @8 q9 I' n# o3 R6 h2 I
  35.     for (ii = 0; ii < n_uom; ii++)8 f$ w% |. s0 H0 u
  36.     {
    $ ?$ `7 F: x9 {; s% z
  37.         ITK_CALL(AOM_ask_name(uoms[ii], &name));# ?( q) Y) `% v
  38.         printf("\t%s\n", name);
      r; ^0 e7 Q: s
  39.         if (name) MEM_free(name);8 j4 Z9 d* R4 q  o$ t  c
  40.     }( i0 u6 W6 x- R" G' i& S. E  e( h- p
  41.     if (uoms) MEM_free(uoms);( q! E) s. x2 E
  42.     ) S8 ~7 h2 t6 {- |% Z: p
  43.     ITK_CALL(UOM_create("inches", "in", &new_uom));. A( t+ f5 q7 v- f* Y3 O8 d0 ^1 e: c
  44.     ITK_CALL(AOM_save(new_uom));, B( {) U  s/ s5 W; |5 Q9 D# H
  45.     6 q& c' X- _$ m: D  R# M. O# j
  46.     printf("\nAfter UOM was created...\n");   
    ' o) [: E. V6 Q) O
  47.     ITK_CALL(UOM_extent(&n_uom, &uoms));( @* J0 L4 P7 M  Z9 T* K
  48.     for (ii = 0; ii < n_uom; ii++)
    % E+ w9 y3 `. _% `
  49.     {
    8 T! \/ T6 n  ^& }% X
  50.         ITK_CALL(AOM_ask_name(uoms[ii], &name))
    - q+ {' K! \) y2 H
  51.         printf("\t%s\n", name);" n! L& o$ F; H/ f3 B" ?4 n" t
  52.         if (name) MEM_free(name);( j* s0 f" y$ V* I8 w. b" z5 `
  53.     }
    8 L3 o- h2 U7 h' \+ ^
  54.     if (uoms) MEM_free(uoms);/ R% K3 N4 V" U1 c) ~! G' P  d" _
  55. }
    2 [3 X+ f0 @  n  ~6 `7 M4 [1 J- m
  56. $ A2 Q: e0 i! y3 k# ^$ q! S* T8 ]
  57. int ITK_user_main(int argc, char* argv[]), U+ F% B2 |8 o0 U* f1 h! E
  58. {
    % y& a9 \$ z& S5 ^% W( ]! ?* r! ]; Z
  59.     int
    8 ~/ L+ Y  J( X
  60.         status = 0;
    % P& _. {5 y% t: Y4 `) a
  61.     char
    4 s! |$ c) ^' x* c5 s0 V( G$ D
  62.         *message;
    . y6 n' o( E9 V: k
  63.    
    , c) l: b- j6 W% c" b& @& H# o
  64.     ITK_initialize_text_services( 0 );9 |' D5 c% V# O5 {0 g( j
  65.     status = ITK_auto_login();
    3 Y8 G1 S3 E( q3 h1 \# }
  66.    5 L8 B. w5 D+ m
  67.     if (  (status != ITK_ok)) printf("iMAN login NOT successful.\n");
    8 R, T4 h$ N! D! @  t5 y" M# b4 C
  68.     else8 p" l: v* x# L/ k, P. K! P
  69.     {' Q2 d# L4 M3 n% I/ P
  70.         printf("iMAN login successful.\n");, v3 X& _! x- @$ c6 x  k3 h! M
  71.         ITK_set_journalling(TRUE);
    : x8 W7 T% a8 s$ \! y
  72.         do_it();2 \$ b2 t) n: ^+ i
  73.     }
    9 J" m9 @- ?- N8 S. M6 ]' }/ P
  74.     ITK_exit_module(TRUE);0 V, O# L, y5 R- G
  75.     return status;8 p0 Y8 N  ?; o1 I0 Z) X9 {
  76. }
复制代码

2 ~% D+ l$ t2 |9 X8 c0 c5 i# R
1 F( h* D0 O6 d1 e
0 T. S# h3 a1 F: K
上海点团信息科技有限公司,承接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二次开发专题模块培训报名开始啦

    我知道了