PLM之家PLMHome-国产软件践行者

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

[复制链接]

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

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

admin 楼主

2014-1-15 19:30:29

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

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

x
( T1 b2 S3 ~4 Q/ T
Teamcenter ITK二次开发源码分享: 创建一个工作流
; z. S0 ^% o! Y; a9 o( l' U
7 A; C9 S5 \7 n  D0 D3 Q- {6 b3 Q. S
  1. /*HEAD CREATE_A_PROCESS CCC ITK */
    ! ~' L0 H3 _; o# z+ d& j
  2. #include <stdlib.h>9 z  Z' l) r( @7 T: U
  3. #include <TCcore/aom.h>
    ; \, S0 [1 ?9 _% p  a; T9 x: c" Y3 Z
  4. #include <tc/emh.h>( M3 f& d+ D+ h( \
  5. #include <epm/epm.h>" i4 V) q9 A- ]$ [, u7 y
  6. #include <tc/tc.h>
    . i8 V" y: |" k5 c
  7. #include <sa/tcfile.h># g4 y, B; q1 p& K! F' x* v
  8. #include <itk/mem.h>
    " Z  E) B* U9 D& c% l, F) h. Z
  9. 2 U8 ^0 [& Q1 d) K6 ]6 ]
  10. #define EXIT_FAILURE 1 - [% B2 M6 [# U
  11. #define ERROR_CHECK(X) (report_error( __FILE__, __LINE__, #X, (X)))% [- G9 ]% W4 t
  12. static void report_error( char *file, int line, char *function, int return_code)1 T! ?) C, b# {5 d0 y
  13. {
    0 B7 |) u  {) d1 L; t1 D
  14.     if (return_code != ITK_ok)
    3 u; F9 [6 y0 v, }  p0 [8 h
  15.     {1 q* ?# I- m8 `
  16.         char *error_message_string;
    8 S; Q- l( u! W: ?3 A2 [
  17.         EMH_get_error_string (NULLTAG, return_code, &error_message_string);
    $ |: F( C6 V+ {3 q- b; K
  18.         printf ("ERROR: %d ERROR MSG: %s.\n", return_code, error_message_string);  p2 Z3 W4 R( Y& n
  19.         printf ("FUNCTION: %s\nFILE: %s LINE: %d\n", function, file, line);
    " s4 K7 q9 N1 P
  20.         if(error_message_string) MEM_free(error_message_string);
    ) g% ^9 M0 W; A% \9 F  i
  21.         printf("\nExiting program!\n");% p3 J9 Z% p0 Z" o- ]! w
  22.         exit (EXIT_FAILURE);   
    " e) }+ S5 ?7 W6 b
  23.     }4 N7 k5 J, V6 z9 o+ N+ E
  24. }7 ~& P3 o& f; y' I9 v" \7 P

  25. . w7 `$ |1 l6 f. `9 k
  26. #define EXIT_IF_NULL(X) (check_value(#X, (X)))
    + x- m, c& m/ H& ~& g
  27. static void check_value( char *function, int value ): G$ o4 J2 q% @  g: C9 i- r% y1 F
  28. {* y) o6 {) ~) X0 @! @7 F# K
  29.     if (value == 0): v! M" Y! s' F/ h% a
  30.     {, b* r$ G5 t; B0 q- {# ~5 n7 ~" E
  31.         printf ("\t%s is NULL\n", function);/ P1 k8 x/ \7 J, B9 q
  32.         printf("\nExiting program!\n");$ p8 P. o7 {. C3 o; _
  33.         exit (EXIT_FAILURE);    ) d7 I* l. B. G4 t: Y4 U$ c
  34.     }
    6 O8 A% _: V2 I! [
  35. }
    % ]2 M% G6 I* V
  36. ) P- Q: F6 Y7 ~: w

  37. 9 ~% F' B4 M: x/ e
  38. static void do_it(void)
    . n, f$ Z( q, P
  39. {
    ! E2 s  K5 o& [. _( \7 |7 y
  40.     int
    " C0 y2 X8 W& H! B( h
  41.         attach_types[1] = {1};3 w7 M, Z* j0 v" o$ x$ ]
  42.     tag_t
    : g5 e. I0 C* O& y0 f! F
  43.         rev = NULLTAG, 4 A. r7 {. b" t- `2 F; ]
  44.         process_template = NULLTAG,   S8 A! x/ y" R) a
  45.         process = NULLTAG;
    * e- m' S8 a2 {. _0 F

  46. * k  z1 l  ^( N8 n
  47.     ERROR_CHECK( ITEM_find_rev("000206", "A", &rev) );) P1 Y: ?. T4 x4 S' N0 m! ?' U+ m
  48.     EXIT_IF_NULL( rev );
    " Q7 W, C+ r3 ~4 u/ Y+ h& c8 `
  49. ) ]- [8 T) c; T& a; z
  50.     ERROR_CHECK( EPM_find_process_template("oneStepWithStatus", &process_template) ); 4 x* b$ K# d5 H- p: [7 J9 x
  51.     EXIT_IF_NULL( process_template );
    ! l6 S5 V6 \  |/ A# g' t
  52. ) ]! \- G; _. S  X8 Z" G- l

  53. . y- V) b: r9 a/ f- `. ^8 P
  54.     ERROR_CHECK( EPM_create_process("5421377", "desc", process_template, 1, &rev, $ O3 \* O" [% d
  55.         attach_types, &process) );* l% ?4 u$ z4 p
  56. 7 M' p% v+ Q) ]
  57.     EXIT_IF_NULL( process );8 g  `; |' R1 L# `' M- @* r, y
  58. }
    ; a( S2 F5 V5 h5 t
  59. ! k7 J' Y( S, R9 x4 ^
  60. int ITK_user_main(int argc, char* argv[])
    $ q8 S' p# W5 \+ E; E
  61. {+ L$ L6 n  X* p
  62.     int5 N+ P) @; J5 {3 Q
  63.         status = 0; ! {9 `7 ?- Q' p- D1 G- ?+ y
  64.      N" g  x* ^  `2 H
  65.     ITK_initialize_text_services( ITK_BATCH_TEXT_MODE );
    , F2 J  D. O! [! L
  66.     status = ITK_auto_login();
    - o/ b$ y+ U! r( k; ^5 X
  67.    
    * K, d) m% ~2 C3 X# J
  68.     if (  (status != ITK_ok)) printf("\nLogin Failed!\n\n");# _$ M, c1 A/ j
  69.     else
    0 M1 [5 z. f+ p9 g
  70.     {
    & ]8 W# `- F' ^5 q0 G! V. u7 W
  71.         printf("\nLogin successful!\n\n");3 _' `& ]- o) b% w  I+ u9 K- u
  72.         ITK_set_journalling(TRUE);
    3 A$ j' o1 e  B3 p
  73.         do_it();' m1 b/ r& p3 o+ Y4 C$ N
  74.     }7 Y( I$ }9 f4 n0 f" e8 B1 ?$ w
  75.     ITK_exit_module(TRUE);& J  {3 F! U' Q+ \
  76.     return status;
    # Z2 U1 y7 q7 Z# Z2 T
  77. }
复制代码

6 O' U, v$ {9 M5 h/ q6 o2 r9 D0 @% L9 Z
  H4 X" P1 ^) g9 r
上海点团信息科技有限公司,承接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二次开发专题模块培训报名开始啦

    我知道了