|
请使用QQ关联注册PLM之家,学习更多关于内容,更多精彩原创视频供你学习!
您需要 登录 才可以下载或查看,没有账号?注册
x
' d5 R, T* o. X4 w6 h: U2 ?1 bTeamcenter ITK二次开发源码分享: 创建一个工作流2 S, n8 g' A5 C$ c! E8 Y& L6 h
3 y6 o- u& E$ C5 n- /*HEAD CREATE_A_PROCESS CCC ITK */) l$ W8 K5 F; i7 [1 T4 l% }
- #include <stdlib.h>
; h' h. I: l) ^! G - #include <TCcore/aom.h>
' }' \' k. s1 L - #include <tc/emh.h>
0 J5 n; b3 E" ]2 m - #include <epm/epm.h>, R+ {" @7 J! M w; l+ U
- #include <tc/tc.h>5 k* _- |$ i4 Y1 |/ o0 |' g5 Z
- #include <sa/tcfile.h>
; R2 t, r1 {; j& Y4 ~4 g1 [, b - #include <itk/mem.h>
% i0 u. C J; T - ) U1 G, T* `# K- ]8 H
- #define EXIT_FAILURE 1
- s* r" v! k, c* `5 E2 d+ q6 S - #define ERROR_CHECK(X) (report_error( __FILE__, __LINE__, #X, (X)))
- [' l5 s q1 r5 o6 C7 q a - static void report_error( char *file, int line, char *function, int return_code)0 {, N( r" ^1 b) e5 I
- {
3 J0 R7 l9 n4 Q - if (return_code != ITK_ok)
1 u0 h6 r3 ]+ N, r- m8 _ - {
$ M+ I) x5 E; \5 t - char *error_message_string;
! }% a+ G1 h/ [7 Q H - EMH_get_error_string (NULLTAG, return_code, &error_message_string);
* {5 S$ |% S5 v$ ^# W+ x) o. E: h - printf ("ERROR: %d ERROR MSG: %s.\n", return_code, error_message_string);4 R& E0 x# Z% j5 q$ F0 z' K# E8 c
- printf ("FUNCTION: %s\nFILE: %s LINE: %d\n", function, file, line);" a* A2 O3 o7 @
- if(error_message_string) MEM_free(error_message_string);
, c# T5 h, n! ?1 _ - printf("\nExiting program!\n");
5 a( D, h# B" q - exit (EXIT_FAILURE);
, ]5 t* o; K- K0 r - }
* _2 n# W5 k% i5 O i - }% u' x6 r) Q, @- r$ }1 X
9 o4 ?! Y! t- ?9 F- #define EXIT_IF_NULL(X) (check_value(#X, (X))): D! w4 [ D& R$ W/ L
- static void check_value( char *function, int value )
7 X+ l: }) o+ R7 g7 w - {
) a5 j3 I7 N$ l, U; Y2 D: o - if (value == 0)
* J( H6 m: x& }2 X7 y - {
/ p, o& d$ `2 z! G9 y$ F - printf ("\t%s is NULL\n", function);
9 n" }8 Y% f1 R: k - printf("\nExiting program!\n");
8 G+ E" ?4 o' C) @: T& n - exit (EXIT_FAILURE); . c2 U; j* J: j, V+ U# v
- }
: W1 K2 O% r9 n! X& ?5 c K - }
- a: }% X( L2 m$ J, V - ( Q7 k9 N' s* J) y9 P2 `- x: d5 A
) p3 m' E1 O. w- static void do_it(void)
! p7 W) _- s4 w - {. C }7 X$ P9 l2 [- y" u6 l
- int 8 p; }4 K$ U+ \$ l8 Q( J* C! I
- attach_types[1] = {1};3 A1 F; q% i" _; L1 y9 ?
- tag_t + D$ l9 `8 }+ Q" a7 }/ N* n5 l
- rev = NULLTAG, ) e( o2 X1 t" C4 D4 y
- process_template = NULLTAG,
# s9 @4 |) o! R8 G# t: }& U! B { - process = NULLTAG;
' Y% M) A0 A f% ] - - k0 }0 }: E4 d" b1 Q! ^& h/ ~' g
- ERROR_CHECK( ITEM_find_rev("000206", "A", &rev) );
5 v5 ~, \% q; |: w1 b- f - EXIT_IF_NULL( rev );
/ s, y$ `" y9 Z
$ f1 X% H2 j' V7 ^/ \" ]5 z- S, v" E- ERROR_CHECK( EPM_find_process_template("oneStepWithStatus", &process_template) ); 3 x& m- X5 p6 p- s
- EXIT_IF_NULL( process_template );
& a& I A7 u8 R$ `( L - - }3 ]9 w! E0 f, p4 V7 u; q
3 \3 J& t$ v$ f& r3 d; f( Q5 F" b7 L- ERROR_CHECK( EPM_create_process("5421377", "desc", process_template, 1, &rev, & O) _0 D1 t0 E# L& P, w7 Q) k
- attach_types, &process) );
2 t1 V; |& {/ V% X& {, F - $ q8 F6 j; L& x& N" Q% Y0 i4 f% O
- EXIT_IF_NULL( process );$ G: ]+ i7 \6 m& I' g: \' x" b
- }
4 W: w3 u! l+ j+ o' u - - X1 U7 A s P# S
- int ITK_user_main(int argc, char* argv[])
4 e; G7 l: G& N6 C4 C4 V - {
' _5 t2 W5 h# e$ Q8 [9 z* _ - int0 v: I7 M) U5 W2 |% q( R
- status = 0; 2 s8 F) b H2 X2 h) P
-
0 N9 F& h3 c! A6 n - ITK_initialize_text_services( ITK_BATCH_TEXT_MODE );
5 q0 H: ^) O! A% J' J6 ^9 @ - status = ITK_auto_login();
6 d& A; F2 q; y" f- ]4 ]5 B -
) X U; F1 j. v7 _* L4 N- F - if ( (status != ITK_ok)) printf("\nLogin Failed!\n\n");
" ~7 x# R3 Z* k9 ` - else
. H7 i# b$ a' E e6 \ - {
+ `8 E. D! h( R2 @1 X& s - printf("\nLogin successful!\n\n");: D H% M, C! j0 ~9 E1 M
- ITK_set_journalling(TRUE);: d2 i4 N: f/ v, [9 _4 h4 u1 C2 L
- do_it();
7 r& I+ p+ O/ r6 x( N. P - }% Q9 O' T- K" T9 o/ r1 x
- ITK_exit_module(TRUE);# _7 Z2 v) F* f! S
- return status;0 |) j) a( t% y8 u
- }
复制代码 / H6 U- j4 O P Z7 z+ B2 k+ I6 b
8 f' i# A, X' C) D( O( s( l- [0 {3 R5 u
) g! e# |, w6 ^% o/ F- E. P. b, g |
|