|
|
请使用QQ关联注册PLM之家,学习更多关于内容,更多精彩原创视频供你学习!
您需要 登录 才可以下载或查看,没有账号?注册
x
`! X [5 j# u, y; j* v
; T9 A5 Z* |9 _0 p4 `
Teamcenter ITK二次开发源码分享:创建自定义文件夹. K) p/ X) B+ @. e/ r# {
输入的第一个参数是文件夹名称,第二个是文件夹描述。
( Y4 T6 t2 `/ u& W# v" f
a, `6 ~: F. K* c; {* D. N$ X4 U6 L) [+ W8 e) f
#include <TC/tc.h>- W/ j1 W5 [! k! [% z9 J# a
#include <tccore/aom.h>
0 u" W5 x$ ]/ q; ^9 Y#include <tc/folder.h>: ]4 h9 k& m6 B! e* q
#include <tccore/workspaceobject.h>6 \6 L `, X+ P: F K
* a( [% B: B% F
#define EXIT_FAILURE 1( f% j0 S Z& B, e. t H% q5 R
- h, E* ]' n) @! f$ Vstatic void report_error_stack( void )4 Y7 L/ P/ U: I0 X- K& d
{
; c7 k8 E% g, t1 X3 e. B3 B E int
, Z7 l1 G2 Q6 G e0 ]& ? n_errors = 0,: e% C0 I$ @$ r) m2 Q
i = 0;" J L ]; L# B ^
const int
! h1 R$ e$ K0 ?5 H. \6 o! C& E *severities = NULL,
4 b+ q1 k% T; t# I *statuses = NULL;6 W+ Q3 N1 Z5 k, P
const char
. X4 a* K: K" N: Q1 f **messages;
7 ]- {- c3 K0 n' C8 a8 k: O5 B8 G) j! w# v9 b8 h: u5 f; v
EMH_ask_errors( &n_errors, &severities, &statuses, &messages );
- F+ Q6 a0 J, ^# C( z! p printf( "Error(s): \n");6 ]) U7 A1 ` I! Q% g
for (i = 0; i < n_errors; i++)
$ S5 |3 j8 p& X* {+ e8 W {4 ]& n. k9 \! J, @* O+ N3 X9 {) ]: }
printf( " %6d: %s\n", statuses, messages );
( V% x, ^6 o+ X3 B7 V' ~6 } }
" B/ j8 V% Q( f+ p) O+ G0 {! J6 k exit(EXIT_FAILURE);
! K/ V+ X( C* u& ` k6 ` }2 k4 O9 y6 @+ _+ q
! h$ l( g: N' u) a: P
int ITK_user_main(int argc, char* argv[])
% @4 j9 I% g) `! N+ ?- n2 ^5 e{
6 S# a' W9 y( b( _; G9 y% D8 M int$ U* e, L% _$ |* T
status;' e4 Q+ [9 l1 d5 n4 n
char
9 u! k: i0 {7 e* W6 ` folder_name[WSO_name_size_c+1],
$ G5 H$ c8 S E" P5 K9 c fldr_desc[WSO_desc_size_c + 1],
% o$ |9 m8 R; r% e3 G. g+ Y *message;) _" \4 |, [' q& f; Q- Z
tag_t
7 y& t* p9 S" o6 \( U( R& \; f new_folder;
* J& a$ c$ |, }: O5 ?4 G( C" Y7 _3 V5 _+ i
ITK_initialize_text_services( 0 );
0 N" T! w8 r) f$ R. s5 o status = ITK_auto_login();
3 h6 d/ e" f4 p5 S) J if(status!= ITK_ok)
" X+ B1 a6 A4 q { y& k+ K. W+ ?, l
report_error_stack();
& I4 `" Q& V& ~2 q }) ?7 s$ D7 m. O9 z' q8 L
else- K! O8 u9 R8 y s3 }+ S5 `
{
) h6 j6 `$ ^8 y+ l( u9 a3 F9 F printf("iMAN login successful.\n");
( x1 K7 p. W1 Z$ O9 O) m# S6 E }
, f3 i6 Y& J+ D! ~! |4 ~ J9 ?$ R+ |4 y! @: h3 G) }
ITK_set_journalling(TRUE);+ y# ^, t h3 i4 h' r. \
# z( W0 q! }2 u) R2 j
if (argc > 1) strcpy(folder_name, argv[1]);1 t9 j7 i* z0 l( E6 [
else1 j# J$ d1 @2 `- C
{% U1 k( ?, r5 h( r- `
printf(" Specify the Input in Following format : \n");
: Z9 G! v- A: R! A printf("program_name folder_name folder_description\n");3 {, p D: m2 r; ~' |/ I5 s, Y
printf("E.g. create_folder phase_3 working_folder_for_phase_3_items\n");: |6 j( P( }( u) E, K/ {: a; z
return ITK_ok; 2 t' b0 e+ W9 G# F) X4 Y
}
8 v# Y( X z. L" s
# G& `% n" _2 s6 Q( h if (argc > 2) strcpy( fldr_desc, argv[2]);, h- p/ x& H- M+ @& l8 K
else strcpy( fldr_desc,"");
% z* E! r2 l/ J% G3 y( i$ {- Q! I. i! J; q
status = FL_create( folder_name, fldr_desc, &new_folder);0 k J9 N `, ^2 V
if(status!= ITK_ok) report_error_stack(); - A; N' g$ g- x& a' d2 P
$ E2 X9 r/ S6 ~0 a: J1 I status = AOM_save(new_folder);0 u" Y. G7 u0 J6 y
if(status!= ITK_ok) report_error_stack();2 D. i7 Z7 ?; Z0 W3 N
else printf("Folder '%s' Saved; ", folder_name);
5 S: h( e3 k- W/ i
0 |9 ~( ^: ^; X1 p status = AOM_unlock(new_folder);
" i' Y0 n8 q& P& F$ h+ v if(status!= ITK_ok) report_error_stack();
# E7 }5 Q/ Y$ h( K" [: C else printf("Unlocked; ");% P |0 A0 @/ ~: C# n5 y/ f; \
7 }1 N. b. x! I
status = FL_user_update_newstuff_folder(new_folder);
& p9 q) ?& I5 m& [* o, Z0 V if(status!= ITK_ok) report_error_stack();; X6 N6 Y5 U5 h2 K
else printf("Put in Newstuff Folder.\n");
7 |- Z, F8 \! \4 R" g: w" m' Z- n; t) {8 ~3 ?
ITK_exit_module(TRUE);
, @2 a& p$ a. @ g+ r return status;' {; s' m O/ {7 p
}! I; d% ~$ X& K3 |- f7 g8 v7 r' i
|
|