|
请使用QQ关联注册PLM之家,学习更多关于内容,更多精彩原创视频供你学习!
您需要 登录 才可以下载或查看,没有账号?注册
x
! @; F7 j% Q% K. \/ `& V( I8 R6 d4 Y2 D1 i' H
Teamcenter ITK二次开发源码分享:创建自定义文件夹
* y3 f" s% o- V9 N/ T$ ^输入的第一个参数是文件夹名称,第二个是文件夹描述。& K( C6 h! t1 n, V5 i
$ l% X. ` N+ s* T
: V+ u) z' u' b* ]4 E#include <TC/tc.h>* [; F! F$ h( ^' I V
#include <tccore/aom.h> @& x$ l" }8 n! E* c
#include <tc/folder.h>
9 a9 J1 |& x$ ]3 a9 j/ b9 ^#include <tccore/workspaceobject.h>
# P8 `6 S" J' z( H9 h7 O; e( y4 u* X4 f- q5 U
#define EXIT_FAILURE 1& j; }, x' C8 d+ _6 |+ b$ k
" f) [/ {" s2 Y/ Q- p" x* X4 ^
static void report_error_stack( void )
" u: O4 h+ S* t0 r+ N {
& u. H4 a1 U" }* F2 ^9 S( ?& u- T int
6 k. ^) a& u6 J; x, A n_errors = 0,4 r" k* y. N! j) g; Q& F
i = 0;1 E6 g, O, X& L
const int
/ v. U1 P5 `# e$ e! }& W1 U8 x8 c *severities = NULL,1 B9 F- p4 h! d' F ~
*statuses = NULL;
% R H. ` }: B% ^+ |7 R const char
: J; b4 e+ \, Y3 }2 l **messages;
% V" @* W& P; G" |3 k
7 A+ X5 c T8 }$ t4 r! D% x EMH_ask_errors( &n_errors, &severities, &statuses, &messages );; y" n: G/ Q5 C# R
printf( "Error(s): \n");
9 S- _; Q) ~, L6 C h for (i = 0; i < n_errors; i++) 4 N0 W2 q0 e. `6 s/ m, |
{3 P# W9 o6 `4 Q4 a' r% v. @
printf( " %6d: %s\n", statuses, messages );
8 R% \: @( k* [% G" b: F }
8 q! h7 `& [3 O. U7 I( K U exit(EXIT_FAILURE);" w: G, y7 Z# M4 y6 P! Z, t: `: ^
}' {3 M+ t/ V9 m& J3 I
1 B: n/ |' }- v6 K# yint ITK_user_main(int argc, char* argv[])% v$ k. I# z) B" P
{
( t+ T! \( L( p4 ^* y9 x int
. V7 O+ z+ j0 j! j V! u ^5 b status;/ b5 |( h0 r+ {* t# ^3 }8 R
char
8 f0 |- U! P; I6 |' e folder_name[WSO_name_size_c+1],
1 W5 S/ I: [7 J fldr_desc[WSO_desc_size_c + 1],& d% H y; R3 R7 J! L: a
*message;. V) k& s3 V/ Q
tag_t& a7 x# a& R) s" K' j
new_folder;
7 P# t/ O; j% B: ]4 ^# j* o( x/ d" D9 Q
ITK_initialize_text_services( 0 );# y- d6 ?7 D) z! y& b" `, V
status = ITK_auto_login();, l$ W9 E4 ]8 U' K
if(status!= ITK_ok)
3 Z2 d0 l7 H3 I% I2 t: U1 v: ` {. P- R$ \8 b* n
report_error_stack();
5 t. u G4 Z# ` }( O2 V! w2 m/ M1 Q% d3 d
else M5 e5 D9 Z1 D$ N
{ m4 T" J1 z- g6 Q7 i# b) u
printf("iMAN login successful.\n");
# C6 k+ S3 M. I }; L/ o. ~* S7 G8 y" p; H9 d
) Y0 [. Q3 ]' x4 u V k ITK_set_journalling(TRUE);
0 H: Y: l! X' A6 w5 P* V; s0 O/ Z* P$ H! k& n8 q
if (argc > 1) strcpy(folder_name, argv[1]);
' G, I1 E7 Q, a% w: _7 s" o else
* B: g* m3 T* \& E, G g' } {
; A' B% `1 F; `8 J6 r/ s; G printf(" Specify the Input in Following format : \n");$ g7 D, j; M5 C% x4 h/ I
printf("program_name folder_name folder_description\n");! U% t J ~* ~4 ^7 `2 I$ g
printf("E.g. create_folder phase_3 working_folder_for_phase_3_items\n");
' V+ K- u) o% s" H4 a. } return ITK_ok;
! |, X' J2 u3 K6 _7 X, r5 D& q } ( a0 D9 ?' A* _
4 D5 s m$ a; F H if (argc > 2) strcpy( fldr_desc, argv[2]);7 z2 Y0 c3 d- a0 o( Y) R! z
else strcpy( fldr_desc,"");. r' M, O+ f& i
3 t) V# b/ k% _; z status = FL_create( folder_name, fldr_desc, &new_folder);
5 j' Y: Q2 r2 H! E if(status!= ITK_ok) report_error_stack();
' e* n' l( h) r8 f" i% N- ]* s O$ a( r2 r0 a
status = AOM_save(new_folder);
7 D, [- _5 E# w7 F4 n* u if(status!= ITK_ok) report_error_stack();
$ t6 e7 ~! `$ X2 R: D2 R9 ? else printf("Folder '%s' Saved; ", folder_name);
6 c4 W7 k3 Y7 `7 o' G: O D8 E7 S/ J3 \/ M0 z
status = AOM_unlock(new_folder);
8 ~9 v$ s1 m( m: l if(status!= ITK_ok) report_error_stack();3 U* ~: m* ~! k' c1 z5 P
else printf("Unlocked; ");
. T8 T- [$ ?0 E9 M6 ?6 D
4 I2 B( K/ J6 x7 ~. ]6 a1 m; g status = FL_user_update_newstuff_folder(new_folder);
8 j: ^- M7 [7 b" J* |5 \ ~! ~ if(status!= ITK_ok) report_error_stack();
2 H+ H; W4 R& ` else printf("Put in Newstuff Folder.\n");
( E1 ~) U* a2 G% [2 C! o+ H0 K% i
ITK_exit_module(TRUE);
9 o. m8 Y/ N# j$ q return status;9 t! b( r! ^& n; G5 U
} d8 H' L+ F8 M( _0 ~- G
|
|