查看: 5181|回复: 0

teamcenter ITK二次开发源码分享: 创建一个工作流

[复制链接]

6

主题

4

回帖

60

积分

管理员

积分
60
发表于 2014-1-15 19:30:29 | 显示全部楼层 |阅读模式

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

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

×
  X8 x# [: k  h" V5 ]; I$ \
Teamcenter ITK二次开发源码分享: 创建一个工作流6 `; _: _& `& I0 q

: j% L7 H0 t( d; R& ?! q
  1. /*HEAD CREATE_A_PROCESS CCC ITK */) j  s0 c! {2 E& h& U
  2. #include <stdlib.h>
    ' U# F8 p3 L; R  x" z4 `  N
  3. #include <TCcore/aom.h>  [! f* D4 ~3 X
  4. #include <tc/emh.h># e  A/ j. X& r. G
  5. #include <epm/epm.h>& Y$ {& Y& c& p, B7 o
  6. #include <tc/tc.h>
    1 P$ \' u- l- I0 ~- Z
  7. #include <sa/tcfile.h>
    - f( W* o; }. T3 b
  8. #include <itk/mem.h>
    % O4 G8 W4 x. O5 g/ I

  9. - C" b! {# q$ L. [7 n9 h
  10. #define EXIT_FAILURE 1
    9 h1 ]' x+ q" ^- Q+ [
  11. #define ERROR_CHECK(X) (report_error( __FILE__, __LINE__, #X, (X)))( h- I7 Q7 v5 b( M4 Y' E! G* B
  12. static void report_error( char *file, int line, char *function, int return_code), `; u  i/ E* ?7 g* q
  13. {& n/ ~$ A  k+ l, {# s- t6 N
  14.     if (return_code != ITK_ok). [8 [2 ^% W! X2 Q4 ?# k
  15.     {
    $ B: ^, H8 J, r  \/ H- ^
  16.         char *error_message_string;7 s* g# l2 c1 |! M. [% j( I6 ^" c
  17.         EMH_get_error_string (NULLTAG, return_code, &error_message_string);
    - U9 D, W. W" z3 g! [) x7 x3 C
  18.         printf ("ERROR: %d ERROR MSG: %s.\n", return_code, error_message_string);
    6 V0 p1 o' _& g6 f2 t  k  X. D
  19.         printf ("FUNCTION: %s\nFILE: %s LINE: %d\n", function, file, line);
    6 }: P" _9 c7 I  |2 `5 Y' T- [
  20.         if(error_message_string) MEM_free(error_message_string);1 Z' v( P7 c  n2 g
  21.         printf("\nExiting program!\n");# O8 b1 P7 w- S7 ?; _2 L+ }
  22.         exit (EXIT_FAILURE);   
    * ], t) O7 o+ k2 Q% ?
  23.     }
    7 u2 o, a; `! w8 d" q: Z' M3 F3 o
  24. }8 S: |& T9 [) W+ o

  25. ; _7 h6 m2 X5 |
  26. #define EXIT_IF_NULL(X) (check_value(#X, (X)))/ Z! m, ?" `1 f  @
  27. static void check_value( char *function, int value )
    , m9 _% S6 R3 K3 I) X: V
  28. {
    . ?! Z! E. H, j3 M. y
  29.     if (value == 0)6 U0 I; {7 ?- G* `
  30.     {# |1 q9 |! R8 S  z& m/ H& @" E
  31.         printf ("\t%s is NULL\n", function);
    ) g/ `* n, h% b' ~8 S, T
  32.         printf("\nExiting program!\n");
    - g9 N8 P2 ~- q3 [( C
  33.         exit (EXIT_FAILURE);    ! J0 B" Q$ E2 K
  34.     }
    + e& I1 x& z) i
  35. }; w8 @4 {, ]: m0 t: n  M
  36. ) h. s) {& V; f& J7 ~5 f, w2 }! s
  37. 1 Q( G3 E% _+ O( y0 |8 f% N6 o# c
  38. static void do_it(void)# k+ {+ q% O2 g4 T" a
  39. {7 L4 g, |' K, H) Y, F
  40.     int
    2 M# `. a3 L& X
  41.         attach_types[1] = {1};, }0 L7 |9 G, k3 q$ c
  42.     tag_t
    # k& S( J1 \$ ]
  43.         rev = NULLTAG, / e; W: c) P: w; f
  44.         process_template = NULLTAG,
    - q5 M( `" c0 S! S
  45.         process = NULLTAG;; ]1 G9 ?9 d( c# r  a) M

  46. 8 x6 u3 b8 q' R' b3 o) b/ W
  47.     ERROR_CHECK( ITEM_find_rev("000206", "A", &rev) );
    3 O) y2 G- m1 V8 H
  48.     EXIT_IF_NULL( rev );
    4 s+ {, L9 l7 O" ^+ Z& ^

  49. $ n9 w$ Y. N$ Z1 M6 |! U( e
  50.     ERROR_CHECK( EPM_find_process_template("oneStepWithStatus", &process_template) ); - B  f- R# [' W5 w/ Q+ h
  51.     EXIT_IF_NULL( process_template );
    : r( K/ K  E3 u. n1 X+ d; F& |

  52. 7 O, d6 ^0 O1 ?/ g

  53. ! R9 H5 x3 k3 x0 I
  54.     ERROR_CHECK( EPM_create_process("5421377", "desc", process_template, 1, &rev,
    4 }1 Q5 h1 m: q6 |+ F- W
  55.         attach_types, &process) );
    # }+ t* f. V4 |* X, P

  56. 1 g" M* q1 g4 P7 l0 n
  57.     EXIT_IF_NULL( process );
    / P3 Z8 Y% X0 t: i/ K
  58. }  U. G4 w3 e' J
  59. ! C  t" k. L7 i/ A6 L: \4 r
  60. int ITK_user_main(int argc, char* argv[])! k9 `$ `8 ]9 Y0 n  A, o/ _
  61. {5 I  Z/ k  t: p3 D
  62.     int
    & ^% p6 }7 g/ u* P( x
  63.         status = 0; " |" r. ]' T) w8 V
  64.    0 M& @4 M/ O+ [- w1 k5 {1 o
  65.     ITK_initialize_text_services( ITK_BATCH_TEXT_MODE );$ h  M% H$ ^" e
  66.     status = ITK_auto_login();
    / \/ k) m3 u; ?% L3 S
  67.    & h4 W7 r0 k. D" ~
  68.     if (  (status != ITK_ok)) printf("\nLogin Failed!\n\n");
    / p0 `4 j, A+ T8 I1 H8 P# i& c, }8 v
  69.     else' g& L$ j( O8 T* {' D
  70.     {
    7 |/ \2 D& Q( {/ f
  71.         printf("\nLogin successful!\n\n");
    9 `9 r% u( |. L& k
  72.         ITK_set_journalling(TRUE);
    & b: }2 y% U3 t( W7 `
  73.         do_it();
    ) p, ]- F4 m2 u: j9 }/ H
  74.     }  v1 m) [' H; H. M3 B8 E
  75.     ITK_exit_module(TRUE);" w; V& R& b! \. [
  76.     return status;
    - J0 W9 {& }: a& q: g+ Q- z
  77. }
复制代码
& p$ `0 M8 A' n- V9 v, P" E

6 a/ ]% i" L9 {' B% O. h$ {: O9 ?3 U. G; W# t& C" j' n  M: F6 c
上海点团信息科技有限公司,承接UG NX,CATIA,CREO,Solidworks 等CAx软件,Teamcenter,3D Experience等PLM软件,工业4.0数字化软件的实施\二次开发\培训相关业务,详情QQ 939801026 Tel 18301858168 网址 www.doteam.tech
回复

使用道具 举报

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

本版积分规则

在本版发帖
关注公众号
QQ客服返回顶部