|
|
请使用QQ关联注册PLM之家,学习更多关于内容,更多精彩原创视频供你学习!
您需要 登录 才可以下载或查看,没有账号?注册
×
& J3 c- d6 Y5 t1 O( P4 r/ B! ]: l% B
1 M& E. N" x% U1 U
Teamcenter ITK二次开发源码分享:创建自定义文件夹
' n; ^% N' K, i输入的第一个参数是文件夹名称,第二个是文件夹描述。
# ?4 l! h! I, ?( Z
2 g1 O L8 c* U% h) k* q0 c& O7 z2 V" l: t$ n- [
#include <TC/tc.h>
& w/ P5 `- T: U6 |% Y4 q+ t#include <tccore/aom.h>8 v( Q) C9 {% [' m
#include <tc/folder.h>
3 X: U8 \7 W$ `, }#include <tccore/workspaceobject.h>
8 {3 x6 \7 Y# ]
% W+ K9 h0 A! F5 T# Y) F#define EXIT_FAILURE 17 [- [. }! N ~; j* [
) _7 \6 \; ^7 ~% d n
static void report_error_stack( void ), p* m( {5 P. s5 X5 L
{
' d, Q: C. C: }. U7 i& T- Q int e# f8 d. @4 w) ~1 ^- a
n_errors = 0,
2 c' U. q9 A; t1 p* L; T, D- | i = 0;' ?- \2 U1 @ F8 V' [+ S, \
const int
. z6 i7 [+ d$ r5 z5 X7 d *severities = NULL,: X c; G7 ]1 ?* l- {. t7 r
*statuses = NULL;; d. Q6 r/ W. V0 n( b
const char
; y5 E& Q: K6 O' a+ l( g( w **messages;" S0 s: _0 d U# g1 v, C
1 B: c" n2 U- x) {4 @& M EMH_ask_errors( &n_errors, &severities, &statuses, &messages );
* t$ f# p; p J( N printf( "Error(s): \n");
' q- I/ v$ W! Y0 m( V) Q: C. U for (i = 0; i < n_errors; i++)
0 c, C' G' Y, {- ?4 J {
) n, t2 i+ V! U" ]0 o: v3 a, | printf( " %6d: %s\n", statuses, messages );3 W9 s2 d4 B0 J \; ?; _
}# k; |( w# d8 r1 r* c
exit(EXIT_FAILURE);, D- T# i" c V
}, ] q! q& x8 Q7 F; E
1 w+ x* c. ?- O. x0 B6 m" \* qint ITK_user_main(int argc, char* argv[])
% D5 o3 x! e4 z/ x+ U( n+ x% C" F{
' D* H3 l3 v- \. C int) O4 ] a; `* @0 I" E/ G
status;: X' o! W8 L$ R X
char
* B5 Y/ Y" ~6 q7 \2 u1 Z folder_name[WSO_name_size_c+1],# B2 F* b8 {( k" M
fldr_desc[WSO_desc_size_c + 1],
$ J. s7 f. F4 x/ _: R6 ] *message;3 N0 E& m# D. a
tag_t
7 p$ ]3 t# u! l3 ^1 I new_folder;
" y6 Q0 R2 F& g0 C- G$ ~% B) Q' e7 C7 Y) ]; P: d2 k \5 y
ITK_initialize_text_services( 0 );: f" o1 }$ \1 R8 a& ^+ a% i* s
status = ITK_auto_login();, c* J4 L1 v3 ^0 y! t; @; a
if(status!= ITK_ok)" f! I# P5 e/ ?8 W2 N6 E
{
" o! E, S) t. |1 b) h8 a) Q2 B5 Q report_error_stack();4 b N* ^6 r7 V
}
& e( Z9 ~7 K% }0 s else4 ^" N# H# @& N1 ]7 x. G2 x/ n3 h% e
{9 K, c9 B, J4 t1 Y' S7 R, r
printf("iMAN login successful.\n");3 ?1 A9 `* p( H
}
2 s7 e0 l# G$ p# A2 O8 n& M" G5 \, x$ b9 [; {
ITK_set_journalling(TRUE);; P! `; r/ m6 P6 ?$ D8 R7 z
4 J/ Q K3 Q1 X, g
if (argc > 1) strcpy(folder_name, argv[1]);
$ P" M. |" g& d& P& } else1 ]+ G- F5 E8 E T; O0 Q- s
{$ Z! ]# H9 }% A+ S" D- n
printf(" Specify the Input in Following format : \n");; c. A, Q9 B2 A; {& B
printf("program_name folder_name folder_description\n");
$ C; o; r4 x7 k B! L2 d+ Q+ g/ E printf("E.g. create_folder phase_3 working_folder_for_phase_3_items\n");0 y/ M7 m) n$ c0 S8 w
return ITK_ok; - @; \5 @ n7 S3 s. T+ ^
}
2 V$ A3 e4 E- K2 @4 Q
) ^: a# S7 Q$ [: x1 P* X if (argc > 2) strcpy( fldr_desc, argv[2]);7 A- p" j2 M- }3 y
else strcpy( fldr_desc,"");
/ b C2 x) v3 T- K) [+ C: T+ r) [1 ?
status = FL_create( folder_name, fldr_desc, &new_folder);
! p) |: n4 x% D( S if(status!= ITK_ok) report_error_stack(); $ V6 u& G/ |' ?2 o6 M: c, P
e7 b0 X. \! {3 c: k# b; @& {
status = AOM_save(new_folder);
( G$ @9 `+ C2 ^ if(status!= ITK_ok) report_error_stack();
# x1 o8 N" F; ^6 K4 n9 g' `* K else printf("Folder '%s' Saved; ", folder_name);
- c7 C3 G+ U( d4 a! ]& \
% x ~) j% i1 a4 H3 U! w) P. j status = AOM_unlock(new_folder);& T% K7 w. c6 D1 h% Z' t# v9 G
if(status!= ITK_ok) report_error_stack();2 w. r1 [9 V& s- T) N% X
else printf("Unlocked; ");. Z- ?0 K) g, q3 o
" W6 i# H0 R6 ]0 e, F- W& D1 w
status = FL_user_update_newstuff_folder(new_folder);2 l' z6 n6 J' u4 _
if(status!= ITK_ok) report_error_stack();' N q o) `9 ?% `
else printf("Put in Newstuff Folder.\n");; [9 x% M: R' D2 y2 ^' x" Z! `8 j
. i+ M# J' }+ R$ Y+ u( n- p5 y R ITK_exit_module(TRUE);
7 r: x! c1 w! k- @" d" w; `2 ?8 g return status;
$ q6 n9 F4 b8 C}
: z0 r& R4 t6 `; ~2 G |
|