|
|
请使用QQ关联注册PLM之家,学习更多关于内容,更多精彩原创视频供你学习!
您需要 登录 才可以下载或查看,没有账号?注册
x
4 D& j; i% M: w* r. U% l8 p5 w; g. Z/ f9 z
Teamcenter ITK二次开发源码分享:创建自定义文件夹
8 g5 {8 L9 s" m7 ~$ {1 l输入的第一个参数是文件夹名称,第二个是文件夹描述。. ?( c( z |+ b, L3 J
3 b. Q I1 O- b/ p( z0 X
$ b9 A% z" F+ G1 f a0 q#include <TC/tc.h>
y, Z( [) v5 ^1 }) [4 N& y#include <tccore/aom.h>
, a. I P0 b; l: ]8 t! Y: u#include <tc/folder.h>
, ~# f E. F" ?$ y& A ~#include <tccore/workspaceobject.h>( q" [; ]# k/ Z) }" b4 E3 G& h
! o/ z1 g6 E3 I m! G/ C2 d2 E$ m#define EXIT_FAILURE 1
4 {9 s7 J$ t/ g. g: N2 H( C& F! H6 G8 @( O2 I1 e
static void report_error_stack( void ): k r) x# {1 O6 x) u4 R
{
. T* X$ E/ M" U( S* y int
- C; A. t& ~7 w5 c ]+ t1 c+ H n_errors = 0,
+ o+ v# b0 d' H i = 0;3 J9 l6 K( \7 o6 X; b0 h
const int
% v) T8 D0 C& o+ w' U8 B *severities = NULL,
- R/ B$ R* R" L+ L9 T% r *statuses = NULL;
* g, b& P* ?6 f! r- t4 e const char: b3 g! R: t/ @; [+ w; c
**messages;. A4 P# r- P S) A; U
) ?" X$ ]; ~' [) T7 z, `% c EMH_ask_errors( &n_errors, &severities, &statuses, &messages );/ \6 ^2 i0 Z1 a! W4 I
printf( "Error(s): \n");
. B; e: M! N' U& w3 }* L, r- ` for (i = 0; i < n_errors; i++)
; l' D* b/ j) ^! V {
/ Z. L7 G7 P2 R6 L1 o2 c: @. Y: o8 ~. O printf( " %6d: %s\n", statuses, messages );
7 X' _' |4 _- a }2 U6 ]: |( `0 [! k
exit(EXIT_FAILURE);" U5 F$ k! d+ [8 [! q
}. z9 u) E% [2 p5 T
% {) M6 j0 h% D2 `1 s" k. V
int ITK_user_main(int argc, char* argv[]). I2 r. h2 X' T! k% X
{ O: h5 `# V3 a, S
int3 n& d/ [% @8 {; M9 f% q0 F1 r
status;. x9 f1 H" T1 n
char
) q0 v& y- u$ m) ~ folder_name[WSO_name_size_c+1],
6 Z4 p- q2 c$ G* j4 h fldr_desc[WSO_desc_size_c + 1],3 T ~" }" G8 w
*message;( W$ ?1 T) X. q$ M
tag_t0 q( F+ k7 T- R
new_folder; y4 T& l' y' g7 p5 C) C
" R& `9 u1 E9 y- w+ ~& ~
ITK_initialize_text_services( 0 );
4 z. K+ k7 m$ \( D! D status = ITK_auto_login();
* S3 U" o5 c- [ if(status!= ITK_ok)
7 }1 \5 G- e. S% `, n( ^ {
- J) x! l, r. A, O" ` report_error_stack();% z, y1 ~+ B8 g' h
}
3 Q& w) a2 A/ ]" u# c- v3 U0 I else
$ Y& J( I. W3 i% _ {
^$ h: ^6 ~- t5 `" l5 U printf("iMAN login successful.\n");
3 k" [3 M. ]# K8 U1 g }
+ ~- K. C0 Y- V: E2 }, O$ ^3 ^( @, e, k& O5 {; q& G
ITK_set_journalling(TRUE);, u9 g# E w. x/ o( ^" L- t1 @0 T
: x. E H5 w8 W2 r# P' b
if (argc > 1) strcpy(folder_name, argv[1]);- Q4 _- [% `* j8 k; D
else
6 d6 \5 }9 r: ]) L* m; p {8 C! ?2 L8 w5 z" [4 a
printf(" Specify the Input in Following format : \n");
8 z; m* x( l3 I2 }7 z( o; \# P printf("program_name folder_name folder_description\n");$ ]6 t0 _" o% z$ @* s! @' ?
printf("E.g. create_folder phase_3 working_folder_for_phase_3_items\n");
6 _& y3 _5 _/ f w, U s return ITK_ok; " ~/ H" G7 o# W( T- W* x7 f% E
}
& ~/ `& @6 V) f7 ^$ I. b& U z+ `/ h8 c, v
if (argc > 2) strcpy( fldr_desc, argv[2]);1 Z2 U6 X2 a& y
else strcpy( fldr_desc,"");* D( @& ~' J% f- d! k, M
' s0 f+ W6 Y9 g& ?( z status = FL_create( folder_name, fldr_desc, &new_folder);
9 o: ~! P' s' {$ f8 o6 ? if(status!= ITK_ok) report_error_stack(); $ v r6 O5 u* |$ n5 E
6 r$ F7 C r$ p- C5 p' }' u$ P+ t
status = AOM_save(new_folder);. ^: ]4 P6 `1 p" N2 C- b* J
if(status!= ITK_ok) report_error_stack();& K9 r# d3 y1 x& W& s
else printf("Folder '%s' Saved; ", folder_name);
# l2 \0 t+ ^1 I, b
9 B/ d& }, c8 Z status = AOM_unlock(new_folder);/ _6 U( O) r- w- ]# ?- k5 p# |& o# c
if(status!= ITK_ok) report_error_stack();2 d) A6 \) d5 s0 z7 Z$ ?/ h! T& u5 q
else printf("Unlocked; ");
) z0 V2 c, M* i2 p2 C1 x a2 A6 z1 ^( ]- B/ W& f) [
status = FL_user_update_newstuff_folder(new_folder);+ n) o, A" r, d# R4 X: |
if(status!= ITK_ok) report_error_stack();
' h; `- \- W, V) R else printf("Put in Newstuff Folder.\n");
: n0 H2 U3 X# s- ?" a! S6 B& h6 {. [; l
ITK_exit_module(TRUE);
) ~; a- U6 T* O0 V return status;/ b \9 l# q! Z4 A- K* i8 e
}- R5 g$ ~, r* ~. s( m! p3 S
|
|