|
|
请使用QQ关联注册PLM之家,学习更多关于内容,更多精彩原创视频供你学习!
您需要 登录 才可以下载或查看,没有账号?注册
x
& V3 }2 z/ `5 W# P8 {. D9 \( d
4 A9 K$ Y7 d8 w' @Teamcenter ITK二次开发源码分享:创建自定义文件夹
. T6 E w8 D* X ?. g输入的第一个参数是文件夹名称,第二个是文件夹描述。
7 v, F& |7 t6 U
- [7 g7 D3 j2 `+ {8 ~; T( {* P2 S2 n @
#include <TC/tc.h>
* J; m& z/ `( B7 l A" O#include <tccore/aom.h>
/ k2 h! e9 ]$ h/ K) \; c#include <tc/folder.h>0 l, S3 [# [% P
#include <tccore/workspaceobject.h>* {9 W# W8 F1 q) V2 F `6 p
. n3 }* f; Z+ M, b- [1 {2 ?' h, k
#define EXIT_FAILURE 1
" G. c4 p: H+ T6 }% o( f' l1 @. Y/ s7 H! R% `$ b
static void report_error_stack( void ): g: V) f, I: ]0 |
{
7 u! s& d: _- [# V* L; t5 x int6 D5 i; O6 S P, W2 K, F
n_errors = 0,
7 F" W# N2 G$ q* Y- ^, S/ u6 ~1 |$ u i = 0;
+ p T5 u1 m5 z B9 N( O M! X const int
( Q$ S6 M7 U( K* Q! u4 y% j *severities = NULL,
* c) Q3 K9 R+ s2 p *statuses = NULL;
# M/ o% i) _: \- d! e: } const char
0 y- j- F8 ~. ~ **messages; k1 S3 T8 s( ?
x& f- l8 X0 k0 p EMH_ask_errors( &n_errors, &severities, &statuses, &messages );: [! Q( J! D1 J8 M* L( F ~2 a
printf( "Error(s): \n"); ]* z8 E. i5 b% t) }3 K5 m
for (i = 0; i < n_errors; i++) / H. B8 V6 q* z F, N: ~
{' u! I, K% z/ _5 Q+ }8 q& K2 H/ v
printf( " %6d: %s\n", statuses, messages );
( Z$ t; G" v4 S1 N }
# d3 z7 T7 @9 |1 Y8 D9 H exit(EXIT_FAILURE);& O. l1 q2 Y: I$ p' u* R
} K/ A- w; q- A. L
) b0 E; s. g' H) S* Y
int ITK_user_main(int argc, char* argv[])
5 T. _& ^5 o- F' P1 `" M4 M' ?9 M) _{
" u; m; A/ n% E2 J2 t int
# Y, @+ b5 `. J status;
' W9 D2 Y" g4 M4 |# c( K* k6 p char" ~1 x- T6 q* |/ m4 k$ X
folder_name[WSO_name_size_c+1],
' n. h' e9 ]3 r fldr_desc[WSO_desc_size_c + 1],
+ E8 ]; @+ v. F! [8 V& a/ C *message;
; K& d. l+ B: {+ X2 l$ c; ?6 R tag_t
. i/ l; Q7 g1 {; }! j new_folder;+ e' {6 c: ?& J4 t2 ~0 |
6 f' [3 o( J+ e2 E
ITK_initialize_text_services( 0 );
& }7 d7 Y1 C" S/ G; r status = ITK_auto_login();
4 r# o! `$ B6 `7 x; j/ C5 y if(status!= ITK_ok)# Z8 G+ W ?' O& w
{, T, W0 g4 U9 k: r0 Q* K
report_error_stack();
7 A9 f7 D G; g }
2 [5 a6 d, S, N; B+ l else
9 N6 _) Q' s3 O9 ~0 J R n+ O {
0 M) y7 T; u. ]# s* E q" Z printf("iMAN login successful.\n");
1 v8 l: ` Z$ T9 ^$ Q" ~) z) b }% g8 D9 G& h) i
, E( N: { I5 i7 Z
ITK_set_journalling(TRUE);' N2 T# O) l a9 h
1 C9 p& t9 P0 |
if (argc > 1) strcpy(folder_name, argv[1]);# t% K( |, p/ d1 I" b. `4 v( T
else" b5 t2 d1 A y0 b$ [7 `( p$ X
{; N0 U t; @' d3 a! R- [
printf(" Specify the Input in Following format : \n");
3 V& n+ I8 f5 G, U$ \7 R/ w0 @ printf("program_name folder_name folder_description\n");& _ r1 c$ i t1 d |) `9 \# @
printf("E.g. create_folder phase_3 working_folder_for_phase_3_items\n");
6 V2 D# C7 w9 q# b* I6 \& L return ITK_ok; 2 O; R+ |; G1 v$ u3 h% K. W
}
- p2 b+ {$ m$ {9 P. \! h2 }! z8 z+ y' B# L1 I5 L; O% M' k( n' U
if (argc > 2) strcpy( fldr_desc, argv[2]);
5 q" x' W- ~( R8 G2 I else strcpy( fldr_desc,"");# b# [2 e0 @; W6 ]
# ]5 c, f7 u% o7 ] status = FL_create( folder_name, fldr_desc, &new_folder);' J" l' b7 w. N3 _# [+ O, T" C/ k0 p) }5 n
if(status!= ITK_ok) report_error_stack(); * |$ C7 c) C1 I
5 Q) {# T( N& r& I" R$ B$ ? status = AOM_save(new_folder);* E- t9 A7 _6 f; K3 I" N2 K0 K0 B" `- [4 L
if(status!= ITK_ok) report_error_stack();& |) j* C; z8 I# O+ f7 Z0 n
else printf("Folder '%s' Saved; ", folder_name);' u4 r: b+ N+ N! }
% ^" d5 ?' L% _4 y F6 N' x# @ status = AOM_unlock(new_folder);
* n/ e9 F+ X2 @, m3 B if(status!= ITK_ok) report_error_stack();
+ Y, F8 p$ x9 j" ]. z* { else printf("Unlocked; ");( g4 U, P) m0 \+ P
9 Z+ t4 B2 R+ m1 e! n status = FL_user_update_newstuff_folder(new_folder);# r4 F8 h y* n$ U$ c" N8 ]. t( X5 C
if(status!= ITK_ok) report_error_stack();
/ w; @! B9 b/ e else printf("Put in Newstuff Folder.\n");
G3 J' w* e) D' T. x% T& u' l0 d* D0 Q% q" r \
ITK_exit_module(TRUE);3 I# M. b8 H0 O( G/ U
return status;2 d( o7 E3 y, o" M0 w2 M1 M
}' n: `5 a% B" d; W+ L6 U7 B1 o
|
|