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

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

[复制链接]

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

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

admin 楼主

2014-1-15 19:30:29

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

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

x
  {( K; {8 P8 {* X
Teamcenter ITK二次开发源码分享: 创建一个工作流
; z/ m& [( ]  \9 {! O
5 B; u/ B: f0 h! v% V
  1. /*HEAD CREATE_A_PROCESS CCC ITK */
    , R# q. p1 `4 \( z$ N% N( M# F
  2. #include <stdlib.h>
    4 z0 V. [' r- \; q
  3. #include <TCcore/aom.h>
    / [2 m$ B0 A7 `& O! t) l" g, u( ]# Y# e( r
  4. #include <tc/emh.h>2 k! D' d8 r/ Z
  5. #include <epm/epm.h>
    ! D+ b% \& @% w) U. c. ?! s
  6. #include <tc/tc.h>
      d. ~8 u7 c5 Z1 |; ^4 T  [
  7. #include <sa/tcfile.h>
    # u# y5 T! I; u+ M; {, d
  8. #include <itk/mem.h>5 E/ |  R0 O6 K, C% U# E
  9. + D1 t) k# l  w: n% k( K
  10. #define EXIT_FAILURE 1
    8 ^( j2 M- w# M( u; e
  11. #define ERROR_CHECK(X) (report_error( __FILE__, __LINE__, #X, (X)))
    ) Z/ t" E& {, V
  12. static void report_error( char *file, int line, char *function, int return_code)
    2 D; `6 J! m( P$ o+ z
  13. {
    $ i2 d( n! v* B
  14.     if (return_code != ITK_ok)
    5 ?3 `% a' t: O' |
  15.     {; y$ _$ i; f% L% G. F& n
  16.         char *error_message_string;, s% q$ O' O- f# \
  17.         EMH_get_error_string (NULLTAG, return_code, &error_message_string);
    2 d( @: {. t/ m6 C3 \8 l1 I6 y6 V
  18.         printf ("ERROR: %d ERROR MSG: %s.\n", return_code, error_message_string);  q% h+ \% j. b  R
  19.         printf ("FUNCTION: %s\nFILE: %s LINE: %d\n", function, file, line);
    2 \* E( P  ^- }) E3 r
  20.         if(error_message_string) MEM_free(error_message_string);
    ' W  ^9 j9 e$ a) L5 z
  21.         printf("\nExiting program!\n");, x2 g; f# z8 y( m7 D
  22.         exit (EXIT_FAILURE);    & r5 g5 r/ E" K- ~% h8 D
  23.     }
    # w9 r2 z; }4 d+ Y* g
  24. }
    3 Y( c1 T2 i# A6 Y

  25. , n) C) z- I8 k5 i) Q& N3 g
  26. #define EXIT_IF_NULL(X) (check_value(#X, (X)))
    1 J. X. Q. X  y& p7 T) j
  27. static void check_value( char *function, int value )
    9 T- O5 }+ g+ f( \) H! ]
  28. {
    : E$ `8 X7 t" T8 o+ n% n
  29.     if (value == 0)
    3 h& k. S! w3 I6 g1 G- }
  30.     {- ?; J  U) U4 S; i$ f# {+ k
  31.         printf ("\t%s is NULL\n", function);) A2 Q: T# Y3 S4 o- m
  32.         printf("\nExiting program!\n");  q2 L* U  e1 @9 ~- c4 H: p7 L
  33.         exit (EXIT_FAILURE);   
    0 n, v5 x( w9 z' }5 _
  34.     }; a  B' d& o! Z, m7 T
  35. }
    # M& l2 k3 M7 p  A* s; _

  36. 5 T- r, ~- k& m+ r) ]
  37. % M1 Q, x% g6 H' i
  38. static void do_it(void)
    2 Z3 _4 x6 [; f2 ~& T, X4 x
  39. {
    ) y: s! S0 }  W% f& {5 X; C- J8 h
  40.     int % {, Z$ S9 H2 [- V  d+ e
  41.         attach_types[1] = {1};
    0 h+ D- a% E; H6 E6 d. R0 v+ K
  42.     tag_t
    , }9 R8 C! ^1 D7 l1 D. U
  43.         rev = NULLTAG,
    . }1 Q+ W) t4 K; {8 Q5 @
  44.         process_template = NULLTAG,
    # K: H1 d( k8 g
  45.         process = NULLTAG;
    & R& }+ T+ }$ s/ H) w
  46. ) u3 v& C- U; m' S" Y" h3 D9 V
  47.     ERROR_CHECK( ITEM_find_rev("000206", "A", &rev) );3 p. u" M6 d. k/ }9 Z7 L
  48.     EXIT_IF_NULL( rev );4 |& p$ x$ h# ~1 A5 T

  49. - [( v, ]! n5 C& @& Z6 J
  50.     ERROR_CHECK( EPM_find_process_template("oneStepWithStatus", &process_template) );
    $ ]8 Q% ]3 \7 m; K
  51.     EXIT_IF_NULL( process_template );
    7 F+ a6 J3 m; |* q5 d" F, M

  52. 3 j+ n& {& }, ~4 |

  53. - t& t6 O5 F$ }% y9 g0 S
  54.     ERROR_CHECK( EPM_create_process("5421377", "desc", process_template, 1, &rev,
    + w# f0 y; ~* z- l6 R; d
  55.         attach_types, &process) );
    " }0 Z  W8 `5 t
  56. 8 \7 c0 s! ~1 R. r* K
  57.     EXIT_IF_NULL( process );
    / M8 ^* @# d" P6 f: c6 e; J" ?7 u
  58. }7 m# F% [- p2 Z; h/ Y) C

  59. " P! i9 ]  w/ Y; ]
  60. int ITK_user_main(int argc, char* argv[])8 Z/ ]. |6 w9 @% }. w- t) u) U( i5 @
  61. {
    ( o+ G4 L  B  I: ~
  62.     int
    - P# F+ o$ e8 c7 V, y9 N
  63.         status = 0; ( J& Q) }4 r" M1 t; `3 _
  64.    2 S: X1 {2 X! l  {) J
  65.     ITK_initialize_text_services( ITK_BATCH_TEXT_MODE );! r2 l+ `$ r! w
  66.     status = ITK_auto_login();; C# b  C3 [/ k- Z- l
  67.    ) S+ r; Q, h7 i# r- v
  68.     if (  (status != ITK_ok)) printf("\nLogin Failed!\n\n");
      L) {5 w# \( M3 z4 U; x; T
  69.     else- ^# |. y4 ~1 `$ @
  70.     {
    ( O& ]: }: D9 j4 e+ w: P5 h. v
  71.         printf("\nLogin successful!\n\n");3 l) R/ _! B  o" w4 J( r' ]
  72.         ITK_set_journalling(TRUE);
    8 q% m5 N# w) H4 T5 U* ?, |; g
  73.         do_it();" J- z# ?: D4 D' U# E
  74.     }
    ) A) b0 n. S! Y, a. [
  75.     ITK_exit_module(TRUE);! s( R/ |& y9 _1 m" v
  76.     return status;
    ; s" c( W+ V. o0 S/ p/ Y- Q
  77. }
复制代码
4 h4 h- V; O3 n5 P6 t9 \8 F

: }  ]$ P/ R2 H  ?" l0 T+ ?  z, c
! U9 P' {- e' i5 E
上海点团信息科技有限公司,承接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二次开发专题模块培训报名开始啦

    我知道了