查看: 5317|回复: 0

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

[复制链接]

2477

主题

1280

回帖

8万

积分

管理员

PLM之家站长

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

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

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

×

" |& y  z" }+ [1 Z2 y4 NTeamcenter ITK二次开发源码分享: 创建一个工作流7 f1 y4 p0 Q2 Y- o$ H& }; g( B) ^8 R
* l$ @) J6 z. {: ?( `7 R
  1. /*HEAD CREATE_A_PROCESS CCC ITK */, @- B' r% L1 [% H8 }7 y% x+ x9 I
  2. #include <stdlib.h>
    # {$ F: S- z- Y& x5 \4 [" ?) i
  3. #include <TCcore/aom.h>
    $ f! V& R. [- h* \
  4. #include <tc/emh.h>
    ( v8 }' R5 _  O2 I4 L) R
  5. #include <epm/epm.h>
    0 N) \3 ~1 j2 j5 m
  6. #include <tc/tc.h>
    : V; T# O9 q$ G) x  R( a7 z
  7. #include <sa/tcfile.h>
    ; Q/ N$ ?3 Z4 \+ J
  8. #include <itk/mem.h>
    - u* s5 g5 O5 l$ P

  9. . B, z& ]9 u: `( h& F
  10. #define EXIT_FAILURE 1 9 Z4 Y- {% E& T" t' [
  11. #define ERROR_CHECK(X) (report_error( __FILE__, __LINE__, #X, (X)))
    ) n; r5 `3 s% x. F0 n
  12. static void report_error( char *file, int line, char *function, int return_code)# o- C7 M6 q! }7 D
  13. {
    . H  X- A# j0 q9 j& b
  14.     if (return_code != ITK_ok)
    1 G/ s7 f0 A$ G2 [1 Z
  15.     {5 O! Y% }; T1 X
  16.         char *error_message_string;8 ?! z" ^) q- G7 i+ m
  17.         EMH_get_error_string (NULLTAG, return_code, &error_message_string);( J1 a5 G0 g6 I- x
  18.         printf ("ERROR: %d ERROR MSG: %s.\n", return_code, error_message_string);/ m" p% O  R- o
  19.         printf ("FUNCTION: %s\nFILE: %s LINE: %d\n", function, file, line);& V, z" a- c4 y" ?
  20.         if(error_message_string) MEM_free(error_message_string);+ v+ |. {8 m/ H) U# S  w# Z
  21.         printf("\nExiting program!\n");
    9 ]6 G, [- d# Y! r0 p, {
  22.         exit (EXIT_FAILURE);   
    9 g- K1 j8 _8 [8 l
  23.     }
    , Y: ~$ y# M6 A
  24. }
    9 y$ A2 N6 {3 h- j

  25. , ~9 t% V" I9 y0 |* S
  26. #define EXIT_IF_NULL(X) (check_value(#X, (X)))
    4 r6 v0 v& @- P- |  h
  27. static void check_value( char *function, int value )
    # ^0 U0 M" l) O! F& h$ w0 ?( X+ O
  28. {
    3 t- u+ R; x& r, E; W  |
  29.     if (value == 0)
    . \. ]5 R6 x9 A; K6 u# {
  30.     {4 @* h. R& i/ Y$ S4 ?; w
  31.         printf ("\t%s is NULL\n", function);
    ) l! c" v3 \" H
  32.         printf("\nExiting program!\n");" f1 |) m, u( H; @) D6 ]$ l) {# z
  33.         exit (EXIT_FAILURE);   
    7 G7 L) A0 Q& G4 {, ^, P6 A: m. K
  34.     }" f7 o: E) o! \$ `
  35. }
    6 f% u: c1 e. A6 v, j" z8 {

  36.   ~. T+ q* a* a- K8 l

  37. ; o) o: I- t0 G" J* ~0 E! a
  38. static void do_it(void)0 g1 U7 F+ O$ P4 n+ E6 ]
  39. {+ h8 G0 D8 `# \! K# `3 I/ j
  40.     int
    ! i# s. W, V; G( u! f* O
  41.         attach_types[1] = {1};
    4 c% [9 Q' C$ I$ S0 q' k4 f0 n- Y
  42.     tag_t
    6 H& m- O- Y, Z9 H* a" K
  43.         rev = NULLTAG, : y; p, k6 h$ L1 L% N6 B5 Q" s
  44.         process_template = NULLTAG,
    3 x  l) V) ]2 Z. {  q- S# q
  45.         process = NULLTAG;
    & f: o' J3 S# V3 W$ ]

  46. / q3 s1 g; a. p& v
  47.     ERROR_CHECK( ITEM_find_rev("000206", "A", &rev) );* D; L7 U. o' _$ d3 M
  48.     EXIT_IF_NULL( rev );5 o& V4 V9 E$ E9 b6 n8 P

  49. , Z2 h# O7 u7 Y$ b5 D2 v- n( {  b
  50.     ERROR_CHECK( EPM_find_process_template("oneStepWithStatus", &process_template) ); " S8 y7 F+ [  R2 N  G- e  P
  51.     EXIT_IF_NULL( process_template );
    / x0 T1 S& f, ~. O5 U

  52. ; n8 v+ _5 B' T( y  I1 o, H
  53. 6 @" \- p9 v9 g! J4 _1 v) V" J6 |
  54.     ERROR_CHECK( EPM_create_process("5421377", "desc", process_template, 1, &rev, 6 l2 l6 ~; j8 J9 {6 P' c7 U3 s
  55.         attach_types, &process) );5 o  @( S3 t. {- u7 x
  56. : A; M% S3 ~& i5 O
  57.     EXIT_IF_NULL( process );" e8 z8 [9 d% i$ N
  58. }
    . x. u7 K! c4 ~( B+ [3 ]' P
  59. & r0 g1 ~% A3 c, A
  60. int ITK_user_main(int argc, char* argv[])
    ' E& s0 @" Y: x, a0 L3 i6 ?
  61. {+ R$ F0 ]+ p  R& Z
  62.     int
    7 l; B2 H! K/ o
  63.         status = 0;
    7 A# w( i0 a0 z5 c' R' D( w
  64.    7 O# M, X5 S4 ]: d8 j. H
  65.     ITK_initialize_text_services( ITK_BATCH_TEXT_MODE );9 s) T& w% C0 D/ `0 o2 y. S  P
  66.     status = ITK_auto_login();0 f5 S1 q+ R  j7 J# j' I7 u
  67.    ! K3 f" X$ B: c* N+ k! k- n
  68.     if (  (status != ITK_ok)) printf("\nLogin Failed!\n\n");
    $ g9 |2 i, D) J8 b' \, Q" u: L
  69.     else. f. ]) r; ], @" X, ?
  70.     {) }2 y! h. x( B( E2 h6 L
  71.         printf("\nLogin successful!\n\n");
    . s5 |# q7 L0 W, E  p
  72.         ITK_set_journalling(TRUE);5 x! t8 V" E( A2 S
  73.         do_it();
    + X- c5 w1 Q" h$ X# k8 a9 `
  74.     }9 i  s' l" Z6 R6 e/ _
  75.     ITK_exit_module(TRUE);2 i# ^5 y/ Y( D: }
  76.     return status;
    " f3 u) [; [" g
  77. }
复制代码

9 J% t) i& s% w( E* Z; A7 g7 Y0 _6 q; f' e9 L" v+ S+ c
+ u2 n5 U7 B( ~+ P* r
上海点团信息科技有限公司,承接UG NX,CATIA,CREO,Solidworks 等CAx软件,Teamcenter,3D Experience等PLM软件,工业4.0数字化软件的实施\二次开发\培训相关业务,详情QQ 939801026 Tel 18301858168 网址 doTeam.tech
回复

使用道具 举报

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

本版积分规则

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