|
|
请使用QQ关联注册PLM之家,学习更多关于内容,更多精彩原创视频供你学习!
您需要 登录 才可以下载或查看,没有账号?注册
x
# L) m8 d0 q; n0 q
) j! ?' E9 O8 ^5 D4 X- m3 P$ w- HTeamcenter ITK二次开发源码分享:创建自定义文件夹
0 t) x+ |5 A/ v输入的第一个参数是文件夹名称,第二个是文件夹描述。4 U3 @. s t3 g
7 x+ W1 C m `6 G$ e6 W7 p' D {9 n4 y! R9 s
#include <TC/tc.h>
- i; B+ B3 u+ S1 u3 a x#include <tccore/aom.h>5 t5 S6 V6 v9 x) x) J
#include <tc/folder.h>2 F4 U h4 V" _ O- e+ C3 x
#include <tccore/workspaceobject.h>* A' X! Q9 a! o+ {, ?9 b5 V
: b& q* d' a6 m2 Z) P#define EXIT_FAILURE 1
; X5 Y% f9 T$ I3 W: V( j" g1 T. p
# ]; e8 a, y9 r J* jstatic void report_error_stack( void )9 a8 A$ Z9 ^7 b8 ?3 _
{3 D7 @" b2 L" _, N/ q( L5 f: r: `: Z
int
9 X H" C v9 a n_errors = 0,
- h B6 E; B7 O# O+ a1 G O1 `6 b i = 0;
0 a' F* I+ \: [- U7 H3 M0 l. t const int+ B9 x& X8 p. G3 y
*severities = NULL,/ s) b. Z* x3 D
*statuses = NULL;& |$ _1 c+ ]% M) `
const char
5 e2 W) f2 i& c( T2 Q2 w **messages;
( h+ B4 m b' g0 M' l& V, b8 J& u" f+ V7 Y& F, w
EMH_ask_errors( &n_errors, &severities, &statuses, &messages );
" k+ {( l& `6 | printf( "Error(s): \n");
9 w7 K- J$ e( ]. B8 X7 h+ J! d5 } for (i = 0; i < n_errors; i++)
: W' s. N3 p; ^# c( [% B4 f {5 d& S7 i" ]( \2 I- O
printf( " %6d: %s\n", statuses, messages );
8 D; Z9 h" Z+ g% y }4 |6 e) c9 O) e
exit(EXIT_FAILURE);
: U$ w1 ?( t$ ~. r9 y5 z }
3 s( J0 Q- T/ A0 n1 F% L
+ m! `& i+ v. r1 Wint ITK_user_main(int argc, char* argv[])6 M% ]3 L" X) t/ n) N* `
{2 [. G) V4 H) T) ]6 N
int
2 ?2 _/ C" p3 e/ n( k; G) o# i( [ status;
, _9 a0 `* O9 [ char
2 g2 e5 j. v [0 G folder_name[WSO_name_size_c+1],
; r1 {) ~7 _/ b+ y fldr_desc[WSO_desc_size_c + 1],
# e! E. o1 ?/ J( U *message;
% R% X1 ~- n; N6 x9 B tag_t
7 g. N$ V' l7 r1 c new_folder;
+ S7 P( ]8 g5 A7 V4 ^$ f/ @& t; L2 G: t2 |8 y
ITK_initialize_text_services( 0 );) w' W3 c3 Y1 |% t1 c- j7 q9 N5 ]
status = ITK_auto_login();$ S2 l9 i7 s8 T- P4 C3 j
if(status!= ITK_ok)
2 i9 D6 L/ I e, A% t8 C {4 ~2 w0 Q% E9 P' S4 [- R# d
report_error_stack();
% v1 O& ^1 w' L' o; U6 S: d5 U }# `* z5 W" F/ g: M# F% i
else l4 n9 D% m' S0 b$ b1 K* n
{ q1 q4 l9 ^; ~ B" q* x
printf("iMAN login successful.\n");
2 _2 q3 E8 `' W5 G }) Q4 @$ D% e# Z, j
0 o. [1 _5 B" J: C# l ITK_set_journalling(TRUE);
3 q9 B0 \0 k% l; ^" e, i( @2 D) ?- p+ k5 n3 f0 X8 V- E& w. h
if (argc > 1) strcpy(folder_name, argv[1]);4 ~% W) @9 u/ f6 R& Z- E. G7 A1 M
else5 Y# ^. @; A6 L9 b, K3 e3 _
{) H5 z( G% H' `4 b9 ~
printf(" Specify the Input in Following format : \n");
2 c$ \0 B. H: ?, W h J8 p# t printf("program_name folder_name folder_description\n");& l1 @% Y% K2 _4 Y z4 l7 H
printf("E.g. create_folder phase_3 working_folder_for_phase_3_items\n");
' |1 j! O8 `5 A& [7 P return ITK_ok;
' P, F1 R$ S8 w W' [ }
8 r% d' L9 d( ]* M% o, q
. l$ @; X% n4 a! r, _4 d if (argc > 2) strcpy( fldr_desc, argv[2]);
! U4 m2 N: B) r9 \ A$ ? else strcpy( fldr_desc,"");1 B }9 \# q5 o1 b N9 R
: L3 l4 [5 B; V1 S9 @
status = FL_create( folder_name, fldr_desc, &new_folder);
0 ?; A: b% w0 C2 k, H- T4 p4 c0 [5 J% T if(status!= ITK_ok) report_error_stack();
: W. p& d' M$ U7 @7 k8 @; g9 F5 u
# a, y5 F, o1 V$ v5 { status = AOM_save(new_folder);
8 A- w0 E! }8 e | if(status!= ITK_ok) report_error_stack();- x; e- ~# C: f2 |$ X2 J& L
else printf("Folder '%s' Saved; ", folder_name);3 @' E& V+ r- ?5 \- ^+ W% q- s
1 f2 I! G* ^( j' E- k* G9 [% G status = AOM_unlock(new_folder); j) f; s U3 N* z9 \2 Y
if(status!= ITK_ok) report_error_stack();8 i7 z% Y$ A0 K, C
else printf("Unlocked; ");
) l/ K3 @8 ]1 k3 e1 @$ o
5 Q$ u# z: }) ?/ P$ P% _" l status = FL_user_update_newstuff_folder(new_folder);
/ Q8 X" C' [1 B if(status!= ITK_ok) report_error_stack();
5 T$ l: o' {& P* o( O1 d2 Z else printf("Put in Newstuff Folder.\n");9 I/ r" v2 V; t1 K; [ q
7 C9 I/ \0 h3 w: M
ITK_exit_module(TRUE);
# G1 B, p' J" J" A2 r( T1 y* U return status;
" j3 S3 `4 u7 ^6 a: `}
( w% z: g, ?1 x6 H: T. S" p# Z3 H |
|