|
请使用QQ关联注册PLM之家,学习更多关于内容,更多精彩原创视频供你学习!
您需要 登录 才可以下载或查看,没有账号?注册
x
! p+ G/ P3 H# k- ^) V3 I( I y& q: u. V, R/ o& Q) k5 f
Teamcenter ITK二次开发源码分享:创建自定义文件夹/ m% J. B% {& r( b; @1 }( Z
输入的第一个参数是文件夹名称,第二个是文件夹描述。
" Q' K z8 E. K8 i8 I. g
+ S. \) I8 y0 u8 L7 F2 v" S5 c
+ q. W, N! V ?' y$ }#include <TC/tc.h># E8 B! w5 f3 {$ L& f
#include <tccore/aom.h>7 m$ u, f. @1 g+ _$ W* k
#include <tc/folder.h>3 t8 z( K: w% d( E3 q0 i
#include <tccore/workspaceobject.h>) ?2 y: n9 b8 }& v
; g1 m o; F$ K/ F7 u8 Y8 f
#define EXIT_FAILURE 1
+ ]4 [! ~+ T2 a) s: C1 T! l( T6 ~4 } Z, D( v; j9 @8 P, s2 J
static void report_error_stack( void )/ B- Q& `: A6 J5 w$ D+ E" e8 a8 }
{' o2 y9 ^/ T4 j7 b* s. `( N" u7 K
int5 I9 q% h# a5 Z$ w! Z( L. s
n_errors = 0,
( j8 }- A; H6 ^4 S' _, T/ } i = 0;. v$ ^. e0 E. C9 j/ x0 _: [
const int
6 T% @2 z7 O7 [% w+ Y *severities = NULL,
4 J" h* Z3 z, |' B8 S: N' r) | *statuses = NULL;
( C: Q' B0 j5 y! Z3 b/ P const char
/ A. b* m4 x4 `7 v **messages;
- X# G+ z+ a* d/ o8 _! n# ~; x4 ?5 n
EMH_ask_errors( &n_errors, &severities, &statuses, &messages );8 r; t$ e {. E# e0 u% s
printf( "Error(s): \n");5 M. p" H' }: p% L6 Y- C, p, s$ _
for (i = 0; i < n_errors; i++)
7 g6 B% n$ }9 S/ ?) s" [( D+ U {
^2 r2 B. X, w printf( " %6d: %s\n", statuses, messages );
[; I, r9 q. r4 s, K v }
& G; j4 Y1 R6 W4 F' M exit(EXIT_FAILURE);
7 H" {( d& A* W9 l# k m$ a) {6 x: O }) }9 O" Y9 f9 E% z5 |/ }
( C( U0 t' y f M" `6 z
int ITK_user_main(int argc, char* argv[])
8 L" w7 [1 i" {' k9 U. r% N{* M. `8 G4 V \8 ~
int
. F2 @3 u) v. I% o0 x( | status;
6 P3 |! V0 T0 [( {, ~) C char
1 ?8 ]5 V) B" g! D* H( F% a folder_name[WSO_name_size_c+1],, S4 P: @$ V' v' T5 d( Q$ i
fldr_desc[WSO_desc_size_c + 1],, L, k# M8 c% r9 [' {- }
*message;/ B3 \! U& o3 F/ U" H. c
tag_t* D: }/ i' H! m
new_folder;
9 ]8 x8 l- v1 H& S' M
! R' q9 _8 N2 h: E: x ITK_initialize_text_services( 0 );
8 p: m+ Z( `6 S o status = ITK_auto_login();
- p0 O% A( B% x+ n if(status!= ITK_ok)9 {2 J% R1 ~2 p! a
{5 {4 F# l4 y+ k; Y7 N- ]
report_error_stack();
: r2 d4 E& R c0 d1 f, x0 w9 l }
$ @6 D- E6 d. X/ s else( @9 c. R3 j8 X, Q
{8 \5 D- y3 a, Z g. s6 F
printf("iMAN login successful.\n");
) i9 Q0 D+ f# |; B" e }
$ i% f/ E( _* z( u) p3 j
1 X, @: A7 x- ^4 U" n, X ITK_set_journalling(TRUE);! h, j5 l) S# g( Q) T# }0 k
* }0 w; V. B* W7 N4 x1 ?% q) u
if (argc > 1) strcpy(folder_name, argv[1]); h4 w1 ^- j* \
else
) T+ z5 H9 s& x: M {- w% C2 K8 O, B1 [2 L
printf(" Specify the Input in Following format : \n");7 l4 ^5 i( O6 I- R/ f$ e6 q
printf("program_name folder_name folder_description\n");- r, y) b$ N q& N" h+ p" Q( `
printf("E.g. create_folder phase_3 working_folder_for_phase_3_items\n");
3 J/ k6 D i, g- j return ITK_ok; 6 g% E: n- t+ N( D" L
}
) v4 T& h# Z' y0 g- v1 X+ A% m, Z/ `. z: x/ D7 W- S
if (argc > 2) strcpy( fldr_desc, argv[2]);& e" ^- @8 T0 W+ g; a/ ?& \
else strcpy( fldr_desc,"");
& S4 F$ ?/ j' A( w7 N" a& H5 m- }" b/ B8 p# A7 R4 ^
status = FL_create( folder_name, fldr_desc, &new_folder);" |( R9 w' q ]$ h% w M- t" L
if(status!= ITK_ok) report_error_stack(); 2 ~$ V' g/ i6 k7 V3 u
3 v' ^$ P( S0 P
status = AOM_save(new_folder);
# Z5 o6 P: `3 ?( ` P( g if(status!= ITK_ok) report_error_stack();6 E! c- M: f& g( D' i6 Q
else printf("Folder '%s' Saved; ", folder_name);
5 x r y& A8 t6 f5 X G9 R. p9 A$ S6 k+ z7 C/ ^
status = AOM_unlock(new_folder);, L+ ]: N; V+ ~" I" Y4 b
if(status!= ITK_ok) report_error_stack();( h, |1 a& j! g6 i0 m2 ?& T0 S
else printf("Unlocked; ");) d4 I( ~: U0 Y, Y6 U7 E( n
/ `, H W* @5 a- [# B status = FL_user_update_newstuff_folder(new_folder);
. U7 h% o( Y+ P+ {; Z+ o if(status!= ITK_ok) report_error_stack();+ y1 f% u: Q: L! ^
else printf("Put in Newstuff Folder.\n");% t# u" B1 L, I
; p4 ?* W4 q; n
ITK_exit_module(TRUE);
! H2 [* U) q4 P1 v' R- m return status;
3 b$ \, j2 J# n H0 b}
+ r- g* a& O2 o! g8 i! O% B0 v |
|