|
|
请使用QQ关联注册PLM之家,学习更多关于内容,更多精彩原创视频供你学习!
您需要 登录 才可以下载或查看,没有账号?注册
x
2 }3 b& o. a* j, O7 h* BTeamcenter ITK二次开发源码分享: 创建一个工作流6 T ~% ~! c- m8 {' ^
* B2 s; L9 @7 \ J+ M! M ~% [- /*HEAD CREATE_A_PROCESS CCC ITK */
2 j! o4 `( e/ g+ s8 D - #include <stdlib.h>/ l6 v9 ~0 i. f; T1 H$ }5 ^8 X3 M
- #include <TCcore/aom.h>
7 x% }( i$ r- \1 I - #include <tc/emh.h>
' [. l. A$ a1 V6 r- x1 S - #include <epm/epm.h>
4 `7 Z* V8 u- g5 z9 C, D# P: n! K. W - #include <tc/tc.h>1 Y& U; f6 Q- ~7 Y( W3 V% v
- #include <sa/tcfile.h>( d! S/ @) c- a- s. j* s/ f
- #include <itk/mem.h>3 W" z2 ^ l- G2 y+ M
- * g7 a9 A8 h6 H/ U$ L/ e! ~
- #define EXIT_FAILURE 1
" b4 `+ j2 ~) x1 M, i - #define ERROR_CHECK(X) (report_error( __FILE__, __LINE__, #X, (X)))
* m- k; M; C; N- P- l/ J0 ]$ k2 _ - static void report_error( char *file, int line, char *function, int return_code)* q8 g. D3 ?' V1 Z7 T- c) ~& \
- {
) x$ h$ _ p d, J% S1 D! K9 e - if (return_code != ITK_ok)3 C; h! x! n$ q q2 D% A& M. \: a
- {+ ?) P1 F/ O! [
- char *error_message_string;" i# \/ N2 Y4 b1 m5 G1 M- Q$ B
- EMH_get_error_string (NULLTAG, return_code, &error_message_string);
" C/ Y% q" |$ ]2 [ - printf ("ERROR: %d ERROR MSG: %s.\n", return_code, error_message_string);4 D8 ]7 T0 H5 A. p
- printf ("FUNCTION: %s\nFILE: %s LINE: %d\n", function, file, line);
' ~% _, V' q: U% T - if(error_message_string) MEM_free(error_message_string);
9 P7 U9 [7 J+ L( R/ T8 i - printf("\nExiting program!\n");" `$ X( T! h8 _! a/ x
- exit (EXIT_FAILURE);
s' {) j; {7 c8 d$ r& ^2 i6 m0 n - }+ Y% E! Y w4 t, o% c7 J
- }1 N3 c7 m5 \4 J" z3 d8 n0 v, e. o
0 {' {! p8 U I! f% b$ D: T- #define EXIT_IF_NULL(X) (check_value(#X, (X)))
0 d. B2 i6 e8 h" a, k - static void check_value( char *function, int value )
9 N7 Y' K5 q# I& T! F* a# n - {
- L" J* w5 s# y) R* J - if (value == 0)
/ B8 f; F" e5 F2 w7 @/ D/ v - {
5 G/ ~* ?. |3 e' G, h# J/ w - printf ("\t%s is NULL\n", function);
$ _6 i% F4 x) K7 V2 c9 k' H4 G - printf("\nExiting program!\n");
& n2 p1 n4 p. o+ H, N - exit (EXIT_FAILURE);
: Z. O$ i p/ w W; m2 R - }5 e! [, O p( o7 t
- }+ K9 {2 ]; ?% D( ?8 ?3 K
6 c7 ?" J% ?6 A% \/ A& _& Z& l
" n9 f" g4 n2 `5 Z; [& i# D/ G5 ]- static void do_it(void)2 a( j4 o* Z8 t) s; _
- {( a% u3 A4 N8 v7 W
- int 1 T1 @7 @; x! L4 ?0 v! E
- attach_types[1] = {1};
+ x7 @: ~/ Q# G/ G. r4 Z - tag_t + P. S) d6 h/ n$ e) J
- rev = NULLTAG,
0 D3 c/ I6 P3 a7 I - process_template = NULLTAG, + L% M, Q7 F/ ?6 u
- process = NULLTAG;
( G0 o7 _, `8 y2 m4 N" `
1 ]) b! F+ D4 f* a$ L% y. }3 w- ERROR_CHECK( ITEM_find_rev("000206", "A", &rev) );
^; {' m$ t& w7 ^$ E - EXIT_IF_NULL( rev );; E; [8 X- T3 H* [' {
p6 r! h% j- r! Z- ERROR_CHECK( EPM_find_process_template("oneStepWithStatus", &process_template) );
0 v1 |' @8 W- f: t - EXIT_IF_NULL( process_template );
/ M$ m& c1 ~: V) O
: {9 [/ T3 }) S( G. B- v
* g- x0 g% a8 L) w, `- ERROR_CHECK( EPM_create_process("5421377", "desc", process_template, 1, &rev, 3 ^! D$ }6 L% k( |6 u
- attach_types, &process) );4 N, s- T+ F* M+ I$ T
^. o9 Y7 l/ c- EXIT_IF_NULL( process );
( n; X( u; |% `8 @8 p: c. R6 | - }
' A* G/ f( ~$ F2 }) s$ X0 V9 K - " A9 C5 {" N3 @1 d& e
- int ITK_user_main(int argc, char* argv[])
' h: C( d7 @) p: I3 R9 n1 \ - {# z6 q/ h& ]8 q) s! y
- int
9 V& A9 x( T! `# l& Y0 C - status = 0; ) r: `6 W- q/ H1 b
- ; Y8 q2 p5 v, U
- ITK_initialize_text_services( ITK_BATCH_TEXT_MODE );1 i& D" }& u+ n. d; g" y& u* z
- status = ITK_auto_login(); Z3 j0 z _* k
-
9 e" k9 r- e. d4 [- B; {1 v8 ] - if ( (status != ITK_ok)) printf("\nLogin Failed!\n\n");1 w' Y4 N7 m$ G1 _4 v
- else
0 N) M" V9 u( W1 X - {
, }7 B. k0 c' X% g& I. I - printf("\nLogin successful!\n\n");
8 ]* X3 j' l$ n. h0 v: y; f - ITK_set_journalling(TRUE);% X. e) T2 z" z1 e
- do_it();3 f' N' C% O# D* A
- }: U+ q C% q ^7 k: S" ~9 f
- ITK_exit_module(TRUE);
" ~8 ?0 f% y3 a! j - return status;8 G8 B- H1 I) t* O9 j
- }
复制代码 r. P# P5 ?! `& X" m2 |- Q
+ K1 D0 T! o1 W. W2 H7 r. ~: M6 u) ]- X+ l
|
|