|
请使用QQ关联注册PLM之家,学习更多关于内容,更多精彩原创视频供你学习!
您需要 登录 才可以下载或查看,没有账号?注册
x
D4 P1 n" B3 C5 y0 r, M' rTeamcenter ITK二次开发源码分享: 创建一个工作流5 C+ V5 H- R( D
! Y. @% E! D/ T! S$ r- }- H
- /*HEAD CREATE_A_PROCESS CCC ITK */
" P! c. e9 q( \, l, O' D - #include <stdlib.h>
7 h l4 z9 |. _5 S - #include <TCcore/aom.h>7 J0 i2 [9 X; ]3 ~3 B9 i
- #include <tc/emh.h>
- K6 L. n3 | e: x0 ?8 q2 ? N - #include <epm/epm.h>
$ |1 @; z( x* O+ O5 N! h/ v b - #include <tc/tc.h>
0 q' f0 [. A2 C, [) `( { - #include <sa/tcfile.h>% D4 E9 t/ s) `4 v1 L5 k" ^9 V4 ~
- #include <itk/mem.h>
6 _- M; G* u5 A: F2 i: i) v - ! W* w: y* _5 O4 e
- #define EXIT_FAILURE 1 7 \7 S) c; S, I% U
- #define ERROR_CHECK(X) (report_error( __FILE__, __LINE__, #X, (X)))8 ~1 h1 J" a# E) n! I0 j
- static void report_error( char *file, int line, char *function, int return_code)' t3 ]3 ]+ U% q
- {2 ^2 C$ l0 r+ _) f0 F3 [
- if (return_code != ITK_ok)( B$ `3 c6 U: A
- {! z3 r* x8 w7 z8 ~3 v I
- char *error_message_string;* Q$ t' C9 i. D- Q) d( Y& W
- EMH_get_error_string (NULLTAG, return_code, &error_message_string);
2 y' h. A& G: R: m8 m - printf ("ERROR: %d ERROR MSG: %s.\n", return_code, error_message_string);
$ J& Q8 }" E- Q: Y - printf ("FUNCTION: %s\nFILE: %s LINE: %d\n", function, file, line);
( Y" G6 I" i9 t9 n* @# G - if(error_message_string) MEM_free(error_message_string);/ \/ d! }7 u5 |* O
- printf("\nExiting program!\n");+ q: U& c1 K) F) V
- exit (EXIT_FAILURE); 7 x8 L# V3 A- @- }' W; Z
- }4 K) F [! W( Y
- }
* ?; w h1 J( a* {* r2 O" J3 {
& }, d. m8 D$ Z/ F+ T2 K$ s- #define EXIT_IF_NULL(X) (check_value(#X, (X)))
& d' w7 Y' F/ d8 j7 d) n |: y! B - static void check_value( char *function, int value )2 g: X$ f. p2 M ]9 J, w
- {
7 w; d" ~: H/ _8 k; D - if (value == 0)
6 b- n: a2 Y2 E# @: ~% h - {! u3 W) m* K4 b' k. H% L+ A
- printf ("\t%s is NULL\n", function);
4 l' ?4 ?7 ]+ r. B - printf("\nExiting program!\n");
1 F1 ^2 A8 z: J$ W( S5 t9 U - exit (EXIT_FAILURE);
) e; K* D* R) w# X+ j M! S - }; X) b8 L* w* ~( G
- }
3 ]+ m, H) ]" |& j) I - " {; i, q0 U4 o- y* p
- D- @9 _' B' T$ `
- static void do_it(void)1 ?5 B( i5 p6 w1 T( f+ \
- {
$ k5 `2 j7 K( T - int . @6 V1 Q7 K! Y2 C- C
- attach_types[1] = {1}; K, Q! \; z0 f) S' `
- tag_t * {8 a2 H) y8 k, J
- rev = NULLTAG,
- @% E9 e5 U" |1 z% ] - process_template = NULLTAG, k2 Q" ^- c) n- `
- process = NULLTAG;: O4 Z7 o% Y3 V% d; m3 }% N
- . ^4 m# k D& t- n
- ERROR_CHECK( ITEM_find_rev("000206", "A", &rev) );( m7 g0 D0 \* S+ _. u+ P1 b1 D P
- EXIT_IF_NULL( rev );5 B0 D# X8 c5 F' U
- * q$ G0 N _; O
- ERROR_CHECK( EPM_find_process_template("oneStepWithStatus", &process_template) ); - `0 c0 O' |$ M: N) ^/ z) I+ s8 E( H
- EXIT_IF_NULL( process_template );4 L' P/ p% W$ |% `! w
. O: s7 I6 v# m4 ?, y9 c9 u6 E
( U0 w* C% t( ]. S' R% `% {' p2 g- ERROR_CHECK( EPM_create_process("5421377", "desc", process_template, 1, &rev, : K! O9 }* W3 P4 q1 E
- attach_types, &process) );
1 i) ]" `! M+ { - & T" M. p& q/ x
- EXIT_IF_NULL( process ); U6 m( x6 J( i* N" g/ ~9 C- N& U
- }0 l a" A- S( K* Q: m' N8 m2 H
- " j5 |$ H9 u$ [4 g0 }! t6 Z! `
- int ITK_user_main(int argc, char* argv[])
8 V% \! H0 }0 p, a, H2 u. R% E - {
! h1 h7 F7 p+ m4 U- ^ - int
% o" Z% l& w: V' e3 S - status = 0; ) C" x- c: o3 o7 j% d- Q2 X
-
# c$ K- Y& R+ M" z) | - ITK_initialize_text_services( ITK_BATCH_TEXT_MODE );0 ^- s1 _& I! y) n7 p5 J
- status = ITK_auto_login();/ K' e+ `, j1 z8 f7 R9 L
- & ^1 B- U! ^& Z6 n. p
- if ( (status != ITK_ok)) printf("\nLogin Failed!\n\n");
- E% N3 L5 {. M/ Y/ c - else
3 ]+ z4 i1 n; c @1 t - {
) O) o: V2 [* j7 m" ?& d: g - printf("\nLogin successful!\n\n");
+ P+ w) _4 w& N* g+ K' A) c0 Z - ITK_set_journalling(TRUE);: ` f7 Z) u/ [6 _4 V3 K
- do_it();
: Q; a U0 X s' d$ Z( V) u- f - }2 s" R9 t* w' D/ V ], D
- ITK_exit_module(TRUE);4 F ^1 \6 N$ e1 j
- return status;
$ }2 T5 m) Q! C c - }
复制代码
" u. B" E$ ], G, \
' p# I1 I# b+ u+ j/ Q% S1 b: c" e' ]" K; b$ T
|
|