|
|
请使用QQ关联注册PLM之家,学习更多关于内容,更多精彩原创视频供你学习!
您需要 登录 才可以下载或查看,没有账号?注册
x
4 \; i: ?$ ?, ? e) {$ G5 ?
8 k; ~+ e6 w/ S/ a$ ZTeamcenter ITK二次开发源码分享:创建自定义文件夹$ X7 q% [ S8 [, ^8 M
输入的第一个参数是文件夹名称,第二个是文件夹描述。
8 |1 R2 M6 }7 {7 ~9 H) r5 U( G" h2 [6 w- d
/ Y3 n) r, y6 g! s* o) w2 Y
#include <TC/tc.h>
' s$ `7 e- V3 s/ i7 s8 t4 q8 E5 l#include <tccore/aom.h>
; o9 A4 Q) H9 ?: R- @/ V#include <tc/folder.h> |0 x E/ F" z. v
#include <tccore/workspaceobject.h>' U! i! Y% r. ?: X+ g
" G6 q; N$ ^9 `, N: g0 j
#define EXIT_FAILURE 1) k& x3 n# [" E* D) H K/ Z6 p' ?
; [2 G8 G* e6 ?# Y
static void report_error_stack( void )
6 P; Q) O& t# s o4 k {/ _0 N& ?$ g8 \8 S3 O5 X) p
int
, f$ m8 P3 A& _) u n_errors = 0,
1 |( Q; L! |9 F- ]% j6 O i = 0;
# w0 f0 [5 I& U$ t4 v& K const int
% Q( v3 D' L$ k3 Y *severities = NULL,: h! a( d) l F
*statuses = NULL;8 M5 k" y' E* ~: Q3 T2 i2 J
const char+ Z- ^& f% H5 }- L& J" d8 R% |
**messages;4 L3 q2 t1 H9 J2 K! T
1 X. B) _. h7 n2 J! ]4 G
EMH_ask_errors( &n_errors, &severities, &statuses, &messages );
7 q$ n9 W% |5 j printf( "Error(s): \n");# }- W9 c- }: M4 f: l3 o
for (i = 0; i < n_errors; i++) . y: G8 V& S8 u
{
6 F" I) U. X& j: S2 l printf( " %6d: %s\n", statuses, messages );
& V1 C1 }" \. `& C4 }& }5 i }# p3 c1 E7 @0 |7 ~( g# |
exit(EXIT_FAILURE);" H9 X0 D- g. I T
}( P P9 g: U, s1 F
0 Y# B* @; A' u: A; o" e9 \7 t
int ITK_user_main(int argc, char* argv[])
1 J7 l0 Z; B8 O# g5 S' Z) \( f{
3 q. W& y z' p; {4 i, l/ l int
2 U( U- z4 T( i: ~8 V- S7 i status;
8 x$ r+ C: _2 g- ] char; M$ s7 D) R7 Q4 N; a6 Y
folder_name[WSO_name_size_c+1],
. `' l i5 z2 r- o fldr_desc[WSO_desc_size_c + 1],& Q. X- w* K) \1 p% C: D% N/ p
*message;+ u' N. V' F) [4 _7 m: F0 z
tag_t
" ^" z3 V* y* [ new_folder;7 F, {) U- ~8 |& h: g* n' @6 n
8 F. a# Z/ [4 G# r7 q% a; ?
ITK_initialize_text_services( 0 );6 Y& z0 _" z6 H" b( P
status = ITK_auto_login();
3 Q, V" o& n" Y7 B; ]4 X+ F1 B- z if(status!= ITK_ok)6 q% W6 Z$ Z- B9 I& P0 ^& K; `
{ _6 f& f0 `& @ ? l
report_error_stack();
7 B9 N9 \/ [% f, w9 u4 e }
# v- g4 T3 w$ B" K5 S0 A: a! _ else
6 k$ p( s' K% a {$ M3 D S- ]2 {$ z& l
printf("iMAN login successful.\n");2 N' e" x6 a; q
}3 l7 I, d! N1 {: I/ f. l3 x; r
7 A8 {7 v2 M7 o% a& h) p ITK_set_journalling(TRUE);
7 b8 s3 H3 J3 V& `7 e9 e/ s" g$ j s1 c
if (argc > 1) strcpy(folder_name, argv[1]);
% p% `# I' Z2 E. L9 H else _* k x* D/ t+ q/ N0 ?: Q2 h9 K! E
{
3 j, Z% `; r7 T. b; [8 P- R1 E printf(" Specify the Input in Following format : \n");
( H0 p& M+ [5 S! P1 y: H printf("program_name folder_name folder_description\n");
5 t8 `3 T+ P7 V( d- a printf("E.g. create_folder phase_3 working_folder_for_phase_3_items\n");
) V6 H9 H" a! n: g return ITK_ok; 3 m) \9 j9 }# b0 z7 p
}
7 N: `- O i+ R% y0 J2 [7 M5 U4 B* @8 R. e2 L; e
if (argc > 2) strcpy( fldr_desc, argv[2]);% n( f& V: g7 t
else strcpy( fldr_desc,"");
3 Y, m d. Q0 E' Y4 H
( k$ A0 E* C" |) |- r$ P status = FL_create( folder_name, fldr_desc, &new_folder);
! x! P# Z# P5 z6 |& J7 E8 j7 E' o5 O if(status!= ITK_ok) report_error_stack();
, o0 }" \* ] {/ N& B. y8 l
# h, _% j( b5 ]3 B0 a; d# g5 Q4 h status = AOM_save(new_folder);
, _4 ?# L3 \! {4 ]: i9 b if(status!= ITK_ok) report_error_stack();. C1 s: S8 B3 a8 X2 G9 c5 l
else printf("Folder '%s' Saved; ", folder_name);
( ?" `/ w* T! G' x# I( X; p6 B6 X/ Y* G2 D1 W6 u
status = AOM_unlock(new_folder);
, y% E d5 f5 Z1 F5 K6 @7 `# J if(status!= ITK_ok) report_error_stack();; S) l( p2 a; d# w: Q
else printf("Unlocked; ");6 ?9 a) v; c. i w3 s
, o- _' p1 U* J4 _" A! K5 N G
status = FL_user_update_newstuff_folder(new_folder);# d) s% D4 b. q) ^6 O; M6 t1 X
if(status!= ITK_ok) report_error_stack();2 g6 r: j( ]! D1 l* T9 V' P
else printf("Put in Newstuff Folder.\n");
) T- o4 K& s# e0 Q P0 n! m& N/ J' y0 A" X7 {! c" l
ITK_exit_module(TRUE);
' G1 B4 p: S% [3 H8 O' X$ g# H) o return status;1 U5 v- ]% n, z4 m
}
1 c! u O9 X8 } x |
|