|
请使用QQ关联注册PLM之家,学习更多关于内容,更多精彩原创视频供你学习!
您需要 登录 才可以下载或查看,没有账号?注册
x
/ x0 {/ V8 o: r$ H+ p
5 q% X' n- q( U& |8 ATeamcenter ITK二次开发源码分享:创建自定义文件夹
$ m; P. S7 k9 X, o# M! I输入的第一个参数是文件夹名称,第二个是文件夹描述。" d3 I; G3 U/ }& V: {: F. {
2 T! J% e& j% O
h8 M6 E0 X1 O4 c#include <TC/tc.h>
4 d' K; M8 w5 G0 A#include <tccore/aom.h>' }2 ]9 b, F. X% C
#include <tc/folder.h>: b1 F1 ^: Q6 ]- c- w
#include <tccore/workspaceobject.h>
5 j7 S; b! ^8 W) v5 Q: F% U$ k* s' [% i
# k9 A; s+ z# d, }: O. P#define EXIT_FAILURE 1
+ n& I: }2 I. z- D/ Z2 V- R7 t d" Q7 v) P6 C
static void report_error_stack( void )" Z$ X' ~ l! M) t: Z; ~) d
{
" q" p7 E' I2 Z* c int
) F( y# K. s( T. z& N! V n_errors = 0, I( d9 t; H: n
i = 0;6 D u) n: b( j$ e3 h* d% |
const int- Z. c3 }! W, M/ S. f
*severities = NULL,
. M7 E; z: n' x( O; e7 c *statuses = NULL;
8 Z2 x( y" p/ \! B& H A. b ^* p const char7 V* t+ R. \# E! J- }* x# g
**messages;* A8 e$ H7 P; h/ ?" `4 B. [) T
6 r ~3 o7 H" A- @8 [) \8 r
EMH_ask_errors( &n_errors, &severities, &statuses, &messages );
Q% q c! a5 V! V- ~3 M printf( "Error(s): \n");1 e' `0 M! ~* \6 V" Z
for (i = 0; i < n_errors; i++)
5 C0 _# e7 y/ b4 h: B: _ {( w2 v! e9 }/ t
printf( " %6d: %s\n", statuses, messages );
5 o0 l; X) \4 c! }8 k# { }+ v1 a* E! t( |$ _5 F7 q4 F' z r
exit(EXIT_FAILURE);! M" f" k. y) _$ l. L7 G) P1 u
}
2 d% N6 V7 |; h) l/ D+ q2 K1 n( U
, P' \+ f$ F# i7 I$ A8 p g: H, Mint ITK_user_main(int argc, char* argv[])
5 e( ^2 H q. ~8 x% N- z2 h{
h/ {0 t4 k, K, J% q+ W int
7 j! @& Q7 q8 R7 U status;
r; N, m' c* C- |4 M: K( W char
5 D9 n1 x2 P; y% \. s folder_name[WSO_name_size_c+1],' L/ v+ y! ^0 n* R' b
fldr_desc[WSO_desc_size_c + 1],
$ m. f6 L9 G# M8 [- O! U *message;
0 l, @6 e/ [+ D' B1 d8 c M7 T4 N tag_t
2 B+ v9 n5 A! c, B: w3 H, E new_folder;9 K7 y2 U6 _ K* H- d# }4 u, e' k
5 n- Z1 s: ?. j/ c/ r& U1 M ITK_initialize_text_services( 0 );
8 ?0 o p2 J3 a4 a9 S; J' d9 |6 B status = ITK_auto_login();( g0 b- C8 `% I9 X& k9 c
if(status!= ITK_ok)2 ^. B; G3 Y( [: ~: }3 d! F
{
( P7 L4 h( }8 u g- h% D report_error_stack();
7 i; |, J. T1 x. p, Z7 Y% b }' k$ W% t& g3 E/ W$ l
else* q" q1 O8 l! l6 s3 f6 x# h- J" o
{( k1 C8 z" P$ K( x: f3 a
printf("iMAN login successful.\n");: C m: L1 R8 E3 u8 V# G" W
}
5 v3 Q9 Z, }; n+ z/ Z/ f0 d& r2 Q# b3 h4 n. S2 O; @ q/ @
ITK_set_journalling(TRUE);
4 r' L3 G) j% `# a, h
p: g. b* _' P1 h if (argc > 1) strcpy(folder_name, argv[1]);
8 L) w ?; ^' ^8 w else
+ u2 T! n0 z- W* D' @ {
' O# u2 K2 h% W1 D& D& V; A" v- R printf(" Specify the Input in Following format : \n");
& f+ F9 q/ o* z0 X4 S; }" U" W printf("program_name folder_name folder_description\n");# j5 X; K7 @4 w7 F- X" G
printf("E.g. create_folder phase_3 working_folder_for_phase_3_items\n");: j. B4 P4 S% f0 t4 m6 I8 q
return ITK_ok; 6 Y2 T1 X3 n4 k c
} % O# i2 ]( Q& O$ _1 s* ?
5 y: T; O9 O: K: T4 V& K$ J
if (argc > 2) strcpy( fldr_desc, argv[2]);
4 Y" [$ G9 i$ `3 c" o. q# I else strcpy( fldr_desc,"");2 q- G. B6 X3 |* r- o
) U0 J, l# V; G8 ^. X+ |- U
status = FL_create( folder_name, fldr_desc, &new_folder);
( Z# {4 I* P: {2 J: b if(status!= ITK_ok) report_error_stack();
4 I5 e: K& w2 K3 g; |1 ]+ S1 s8 U
status = AOM_save(new_folder);
: s4 S) Z1 Z, u/ G: ]3 F if(status!= ITK_ok) report_error_stack();. w9 V- A9 ?2 P$ y' E
else printf("Folder '%s' Saved; ", folder_name);9 c6 O. L& ~& V1 P: G( C, T
$ X! y" Z9 B- ?% h% r# {
status = AOM_unlock(new_folder);3 V# T& @& _) C7 v0 Q
if(status!= ITK_ok) report_error_stack();; V4 M; ` u: u( g$ I
else printf("Unlocked; ");
( Q# P0 [ ] a- y9 s$ R- @. j
status = FL_user_update_newstuff_folder(new_folder);
2 D% V1 \) A5 d8 ~( h if(status!= ITK_ok) report_error_stack();/ N3 j( N1 s2 k' `
else printf("Put in Newstuff Folder.\n");
6 D, s8 V" ?: ?, i% w4 {6 D- R8 ]# |/ W# C8 T& C
ITK_exit_module(TRUE);
' W y( ~5 ~5 L( z2 u! d2 ?3 s return status;
! ?5 t5 w6 g; @! M}
, K7 }1 j/ z; I. W |
|