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

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

[复制链接]

2014-1-15 19:30:29 5023 0

admin 发表于 2014-1-15 19:30:29 |阅读模式

admin 楼主

2014-1-15 19:30:29

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

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

x

* R" p) [) `% f* @5 b5 L5 o/ ZTeamcenter ITK二次开发源码分享: 创建一个工作流
- C4 H/ F; \/ Z! l( z4 f- K. F: J- s, c+ I1 P
  1. /*HEAD CREATE_A_PROCESS CCC ITK */* {, ?2 h) |- I) ^  ]
  2. #include <stdlib.h>
    - l: }0 v* @: H. p
  3. #include <TCcore/aom.h>7 K, x* {0 X2 G  ~
  4. #include <tc/emh.h>
    ( _6 i; P" ?& f2 v$ y6 B
  5. #include <epm/epm.h>
    & i, W4 a; @; \4 N
  6. #include <tc/tc.h>
    ! f% Q9 }9 [4 d7 h9 u6 B( y5 B8 i
  7. #include <sa/tcfile.h>: K; ~/ [: u2 C
  8. #include <itk/mem.h>- v- x* U& V" z, z8 H
  9. + W0 N& \+ {+ ^6 j* j
  10. #define EXIT_FAILURE 1
    ! c/ r; z- T, _1 w; J# m" b2 g
  11. #define ERROR_CHECK(X) (report_error( __FILE__, __LINE__, #X, (X)))0 q7 F5 F) R" w* ~# v
  12. static void report_error( char *file, int line, char *function, int return_code)9 K6 _4 G' N: m" C1 n/ E
  13. {7 q& I8 w5 X- D( U7 G5 J
  14.     if (return_code != ITK_ok)
    ( _, @% n8 W3 J' f
  15.     {0 k3 e& s4 ?' W. A1 l
  16.         char *error_message_string;) w6 F, O: C# Y2 o6 C' A
  17.         EMH_get_error_string (NULLTAG, return_code, &error_message_string);
    % Z% @. x5 v, i! I
  18.         printf ("ERROR: %d ERROR MSG: %s.\n", return_code, error_message_string);8 ~" \# ?6 I# B. `& R7 \" {
  19.         printf ("FUNCTION: %s\nFILE: %s LINE: %d\n", function, file, line);! M6 D0 y8 B8 K" ~& L+ F
  20.         if(error_message_string) MEM_free(error_message_string);+ |& \. A5 E% }4 }8 l+ M8 a
  21.         printf("\nExiting program!\n");
    , x% y, R0 k8 F  }  l5 Z# r9 m# q$ p
  22.         exit (EXIT_FAILURE);    ) W$ d# B9 e9 h+ ^: u
  23.     }+ ^: b* q+ w& B  w& v/ Y% q6 b  ?
  24. }: ?( J0 l5 h5 \; J  ?" W1 H
  25. ) P8 ?4 _1 h5 u* I7 F( a, C  c& O
  26. #define EXIT_IF_NULL(X) (check_value(#X, (X)))9 d7 q% Y/ k0 }* T) h3 p. a# S3 [& A
  27. static void check_value( char *function, int value )
    ! g; W8 E( m. U& d
  28. {' W, w! [6 E4 q
  29.     if (value == 0)
    6 a9 q2 r; p0 c/ U  r
  30.     {5 X4 I7 e$ @# U& h
  31.         printf ("\t%s is NULL\n", function);
    / b9 g3 K! {0 r1 Y7 W
  32.         printf("\nExiting program!\n");! p# W- w& z+ \* p) f+ b; z* j8 ]
  33.         exit (EXIT_FAILURE);    : x- Y  Q$ @4 t* H9 O' c
  34.     }
    4 S5 j$ y. u  P! l7 b1 G
  35. }2 q& Z9 N( P! P' N3 U2 a. ]0 x

  36. ; C: V& {/ e  [: U
  37. ) ~# a2 t% l7 O: H! Q4 h
  38. static void do_it(void)% X8 M3 S1 Q# S' J* k9 z+ o. d
  39. {
    , L% C3 B1 ~1 g9 X. N) e% k! _
  40.     int
    / a3 Y5 Y+ Q( ^* W% d7 a3 n
  41.         attach_types[1] = {1};) J% q& o9 W6 e+ f# r) Y
  42.     tag_t ; E# c" `7 {3 E' M0 n4 |
  43.         rev = NULLTAG,
    " k! ?7 P+ g  D* T; r
  44.         process_template = NULLTAG,
    ) }) T1 @4 h) i, ~$ @
  45.         process = NULLTAG;
    4 ]( x  L  h6 R  q, c- j* o

  46. ! q' p8 d+ u& b9 T. N9 @. v4 ]
  47.     ERROR_CHECK( ITEM_find_rev("000206", "A", &rev) );
    0 i6 [# ]7 r8 [$ ^+ Z9 M; k
  48.     EXIT_IF_NULL( rev );
    " X! _. t4 [- ~. Z7 a" D

  49. ; V' _8 A1 `0 ]4 M. C! S" e% H9 U
  50.     ERROR_CHECK( EPM_find_process_template("oneStepWithStatus", &process_template) ); 4 \: D: w5 L0 V5 q9 x& w1 l  h7 g" _& ~
  51.     EXIT_IF_NULL( process_template );* a" z6 x' R, q2 r+ B5 a$ D
  52. ! o, b: n1 o! L

  53. 2 N, B2 Z$ Y9 Q+ w3 j7 h; K. ?
  54.     ERROR_CHECK( EPM_create_process("5421377", "desc", process_template, 1, &rev,
    4 T  c" c3 s5 e, t. V
  55.         attach_types, &process) );% K: o, q( q1 a2 M

  56. 5 f( }3 x2 ^- Y5 M5 U* s+ ]7 [; ]
  57.     EXIT_IF_NULL( process );; f  j. F, k: V8 c
  58. }
    ! S( P* m9 X' v2 Q% C8 u$ D
  59. - E5 N/ f2 r" z- d; d* Q. f6 a" `
  60. int ITK_user_main(int argc, char* argv[])
    / k' H8 R) f/ n. S4 O' O/ A& v
  61. {
    - J7 `! ^' Z* k, g. K. ~: j3 r0 ~
  62.     int4 U; t4 n* i' x1 E2 r
  63.         status = 0; 7 f* n2 T. _0 L! w1 }7 {/ {9 J( y
  64.    
    ! [) V9 m0 o9 h5 K
  65.     ITK_initialize_text_services( ITK_BATCH_TEXT_MODE );  Z, [3 s7 i6 f1 u$ \
  66.     status = ITK_auto_login();
    . j9 L( @3 k7 N& F. y
  67.    
    . R1 X  ^% g) U0 j3 [8 |6 v
  68.     if (  (status != ITK_ok)) printf("\nLogin Failed!\n\n");4 }0 i* D8 X; b! z
  69.     else
    : Y1 q1 }# _: P3 L3 X) Y( _$ O
  70.     {
    6 L; V. s% Z( K4 \
  71.         printf("\nLogin successful!\n\n");
    ' r: u8 Z  x& u$ F. \6 I3 K/ \
  72.         ITK_set_journalling(TRUE);, o% C7 m9 f! _' I/ j# Y
  73.         do_it();
    6 R1 m- w, e; @9 |) b
  74.     }
    % y5 b8 ]6 k6 S! W7 K
  75.     ITK_exit_module(TRUE);! E! H, z7 I  N# ?& H
  76.     return status;7 Y& N- }* }' x( ^8 u+ g
  77. }
复制代码
1 Z: W- |( V9 X0 N1 X

9 s6 V& N5 {" B" y# r
6 P4 \  J* `* h+ {! s
上海点团信息科技有限公司,承接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二次开发专题模块培训报名开始啦

    我知道了