|
|
请使用QQ关联注册PLM之家,学习更多关于内容,更多精彩原创视频供你学习!
您需要 登录 才可以下载或查看,没有账号?注册
x
+ z0 f- x+ g' u) X4 G9 X0 j7 i+ {' a. H/ Y+ b9 ^+ t) U
Teamcenter ITK二次开发源码分享:创建自定义文件夹 O3 t" L: F {8 ^' j$ o9 R% o
输入的第一个参数是文件夹名称,第二个是文件夹描述。
/ c4 [8 I' Y8 ~0 r9 j
7 L/ D2 L8 _ X2 y' n2 e5 T# Q' n2 ?' G! z8 A* j
#include <TC/tc.h>
* b. f) c" r+ R2 E# q#include <tccore/aom.h>0 [/ Z2 ^4 G0 Y
#include <tc/folder.h>* i( v' |, W2 \) \+ Y
#include <tccore/workspaceobject.h>
4 R8 D+ F& v+ b
# G5 D* {3 _# q#define EXIT_FAILURE 1" S+ j! ]+ |: B3 I5 t% N7 y" k
( V& D8 T. `+ U' `7 U# h
static void report_error_stack( void )
) Y! k' S, Q( H- K2 H0 H8 ] {
7 i2 b* V. e% P- x# L! w int
$ B+ M9 J4 E6 x& U$ S) H7 u n_errors = 0,, V" |# k8 ^, H, L3 z, ]' }, D
i = 0;
4 V' U) e( |3 R' ^* N5 L/ M. {3 V' p const int
# e8 l1 d8 ?) Z" _2 f" K *severities = NULL,
& b0 B4 F" G/ F* E% H* w% _% A *statuses = NULL;
4 `" k2 W1 @ s: F2 A4 Y const char
' z6 B7 Z. c' z) z& o **messages;
8 s x9 r$ r; v9 T* |
/ q4 W; Z& \: [* u EMH_ask_errors( &n_errors, &severities, &statuses, &messages );$ c; ]- h- `5 ^8 }6 C, d
printf( "Error(s): \n");8 B: ^2 d; e9 y' r! G6 |# L
for (i = 0; i < n_errors; i++)
; C* K+ O: G- n1 V/ V" J/ V {3 \, f. t- n# I/ ?0 G
printf( " %6d: %s\n", statuses, messages );
6 Y6 F$ S$ o: y- p }
- }; z1 L8 p" N. M/ _ exit(EXIT_FAILURE);
) P+ R d; _2 K) Z' B5 ^ }
* ~2 G: ]8 V' t5 B: s1 t% d% e- t) ~2 x f' o# P, g
int ITK_user_main(int argc, char* argv[]). B) u% L( F5 G5 n/ U# h! a* S0 q
{3 ]# q) i* ?3 b
int" o" y& m6 K' m& j+ m* p
status;
9 F9 r0 v2 a- U$ k4 J1 @ char' j" I# l$ r9 I* T% b
folder_name[WSO_name_size_c+1],8 w7 C1 [$ U7 D$ ^5 j& I
fldr_desc[WSO_desc_size_c + 1],
7 l, X" k2 F2 U. O, ~1 t* f) v, x *message;
8 [6 ?; @$ Q8 u% Z' X tag_t( a, l& |/ J+ J6 o% S9 B6 N- U# u
new_folder; \ [: }% x* O$ o) z3 |
- }& S2 B$ D3 z; `. i
ITK_initialize_text_services( 0 );
8 q# ~8 o, R( w; n, z status = ITK_auto_login();4 K8 D+ n0 Q. C; O
if(status!= ITK_ok)
/ @1 V. w: r; K& N# S {+ p! S$ X. x) t
report_error_stack();
7 ~4 y4 o9 _, _0 R6 o6 x }
7 S" O& w4 V, G else
% Y3 m* k6 H% H- x5 U {
3 l) x% i3 _1 E- s printf("iMAN login successful.\n");
( g: N& p( G% \2 }* c7 Z }
6 _" ?! c& T* U9 O" t: `( s. {5 E) H
ITK_set_journalling(TRUE);* g. x) r; o |! g" b3 I
* Z) ?. k# i, s" V
if (argc > 1) strcpy(folder_name, argv[1]);- r/ @* L$ \$ ?; K/ d2 T
else
' Q& g3 `+ i) }% O* u2 Q) ?% n {2 S C8 A0 x* b) b% n
printf(" Specify the Input in Following format : \n");
; ^& m) [9 E% x- @- F7 u% E; m) f printf("program_name folder_name folder_description\n");
/ m, B1 D7 @% z! J* ]9 A4 W) a printf("E.g. create_folder phase_3 working_folder_for_phase_3_items\n");& l4 ?3 S, O) e- e) R+ J
return ITK_ok; ( `7 o5 i2 m* Q. L+ W' Z
}
' `% s @1 d9 T" Y: ]$ d6 v5 \! M: ]
if (argc > 2) strcpy( fldr_desc, argv[2]);
[1 r2 g' v3 `7 { else strcpy( fldr_desc,"");0 f& P( J E4 r2 P- Y; p- _; O
7 s" r3 ]7 v) M# t3 ^/ X
status = FL_create( folder_name, fldr_desc, &new_folder);8 R2 n; e$ J2 M2 |
if(status!= ITK_ok) report_error_stack(); 5 ?$ u% d* Y [' ~1 A# V
m9 F$ |1 j6 c
status = AOM_save(new_folder); V- m1 P; ]2 g3 H- w% U, l
if(status!= ITK_ok) report_error_stack();1 C6 N/ i' T' q/ c1 s9 D' G) \
else printf("Folder '%s' Saved; ", folder_name);) a0 f+ ^4 D s1 q4 x
M; M/ M. t2 Q( C# N status = AOM_unlock(new_folder);
3 G& M1 s4 H% _/ U if(status!= ITK_ok) report_error_stack();
4 g @5 I l5 S2 g/ M else printf("Unlocked; ");
8 D# t. x" J" o# v c) C) F: r5 {/ f9 z% n6 K
status = FL_user_update_newstuff_folder(new_folder);
0 i( g C- ~' P+ r! C, o if(status!= ITK_ok) report_error_stack();
3 [7 E8 i& i' J$ {; j* _ else printf("Put in Newstuff Folder.\n");0 i% K& R( \$ S
4 Q! \" }7 y5 |6 e' Q: p H ITK_exit_module(TRUE);
2 k1 M1 h# f. p g return status;
2 d/ I3 Z+ R1 \+ x1 z d}
3 @ ?6 ]) d y |
|