|
|
请使用QQ关联注册PLM之家,学习更多关于内容,更多精彩原创视频供你学习!
您需要 登录 才可以下载或查看,没有账号?注册
x
# b& C+ @3 I3 r2 x6 l$ G. h& y
9 G! U/ B3 [7 y' i$ F, sTeamcenter ITK二次开发源码分享:创建自定义文件夹
/ \5 H6 f9 Z- d' D* t9 Z. e0 R输入的第一个参数是文件夹名称,第二个是文件夹描述。+ M. I2 p. c F0 i) |* {- `* I9 j( [
( I" v5 f: D) R( d& P& f3 k$ s
/ q4 ^# V+ h! m# D5 K0 W#include <TC/tc.h>- V7 F7 C0 r1 G! C( T2 O# P
#include <tccore/aom.h>
0 i( \# |0 m1 K S5 l7 k- n#include <tc/folder.h>
+ y/ c( Q, U+ P% ]- S: [$ t2 N3 l- x#include <tccore/workspaceobject.h>( p v) e6 U- W, E
. T' M# I& z3 {4 w# a
#define EXIT_FAILURE 1
2 w; N& ?; ]* f0 X! L
) N4 ]1 y) K) P& sstatic void report_error_stack( void )6 L: X# M0 o3 ?. o
{
0 l4 y8 w4 g% h1 n# y8 W {/ r int
3 J) v2 ~7 v) i& ? n_errors = 0,
8 h. G( |" x! R# U3 n( j i = 0;
: H; N% {# d; h& u9 R$ A const int
& |# @) H: k0 L, v% j9 U *severities = NULL,
' V8 x# t C2 G: _& D *statuses = NULL;. L4 O/ R6 \. d- |9 U) @7 g
const char
. q; N' w# H3 p& X; F" g4 J8 M5 n# o$ R **messages;
; m4 `% n/ G& B' o8 \: {( A' h
- O" w% P; S- x. d/ D$ Q$ | EMH_ask_errors( &n_errors, &severities, &statuses, &messages );8 ~6 Z" Z. J4 u
printf( "Error(s): \n");
: o2 C7 N' E+ w- \: D for (i = 0; i < n_errors; i++)
7 M. C+ O( R; J$ `& \3 B! f {! ^0 V/ H7 e" Y
printf( " %6d: %s\n", statuses, messages );% s- p& }. E; M4 J/ |$ P
}6 `1 e# h% Z, J
exit(EXIT_FAILURE);+ A3 V! Z. Y! G$ N
}
$ L; ~9 a0 R/ G
3 ^: a. _5 q" }9 q, jint ITK_user_main(int argc, char* argv[])4 q( }' \# W8 L2 q/ J5 x
{
; n2 Y" n& R# O7 b k$ i% Y3 F int
$ H, X3 m6 r4 |- F9 o status;" G4 f( I8 d/ J
char7 i8 V3 R3 K3 p" C) Z# u/ ^
folder_name[WSO_name_size_c+1],7 J5 W" m8 V$ V
fldr_desc[WSO_desc_size_c + 1],. E4 M1 g4 A$ s2 ?& _
*message;* [% `( P- P3 B( h
tag_t0 o5 @% ]# v/ h3 }1 N5 Q5 a& u
new_folder;8 y( K. L7 {( ^1 G, `1 ?( p
! F; z" \9 @3 D9 \ ITK_initialize_text_services( 0 );2 N* h8 s$ T+ Y6 J5 |
status = ITK_auto_login();
/ [* d" {5 H' {: e, o5 ]0 a2 q if(status!= ITK_ok)6 ~ G4 x/ W* H# H6 V
{' i6 H) w( R2 X
report_error_stack();
/ Z' Z* s( `) u+ n2 B% B }- ?; p# |: L; W
else$ t9 Y; J6 w' E! Y y/ O
{
1 ?" Q+ a8 c0 t# L1 t+ t8 s printf("iMAN login successful.\n");
$ ?; L$ w, t W }
; |6 D9 g' }7 e! E4 t8 Y, Q6 ]; g/ f6 g$ S: e$ ?# [% U
ITK_set_journalling(TRUE);! P; F5 D- Z! B
; X& I2 z( ~' o! k# N. Y/ J2 U if (argc > 1) strcpy(folder_name, argv[1]);" ~& J. I/ L7 ~0 ^: I0 h
else
" l, h$ ^# |7 J! q. @# E' } {3 W/ |4 \7 R" A: O
printf(" Specify the Input in Following format : \n");
' _* x8 ~ [" c, a3 w printf("program_name folder_name folder_description\n");
& ]* \! a% K6 d3 I9 a u printf("E.g. create_folder phase_3 working_folder_for_phase_3_items\n");
7 z& t9 p- S2 M3 H% K' Y% Y return ITK_ok; : Z. Y* X- d9 d3 u" c& \: E
}
$ h' o5 C# a- L( C: O
3 ~# Q% j/ c7 O7 v1 q# ^ if (argc > 2) strcpy( fldr_desc, argv[2]);0 a+ X* h# |- _; c" u5 }2 P
else strcpy( fldr_desc,"");8 n( A9 _% i `0 l) p7 Y# `' v
" f ]3 {+ E1 ]4 n* h2 U* l; w
status = FL_create( folder_name, fldr_desc, &new_folder);
; W/ f4 d% h. L Q& J" C6 ~7 E1 b3 } if(status!= ITK_ok) report_error_stack();
% Y O+ c+ y$ D1 c' e) t3 N% V) q/ F$ Z4 w+ k! j' a
status = AOM_save(new_folder);
8 e, V$ a1 }; B% J3 t! k7 Y3 _ if(status!= ITK_ok) report_error_stack();
4 c1 c( C# o) m0 C! F: [' G: b4 V else printf("Folder '%s' Saved; ", folder_name);# e. B* c0 w4 f3 d+ o, k
3 Z9 f/ ~, x6 _9 P o2 S* t" ?# _
status = AOM_unlock(new_folder);
6 R0 q0 p; `0 o( {2 ~ if(status!= ITK_ok) report_error_stack();
0 F) G$ W0 V8 g else printf("Unlocked; ");& j* r1 ^0 n7 o$ J. K4 v
+ d9 V3 P/ y# G6 D% _7 N status = FL_user_update_newstuff_folder(new_folder);
) w% _5 ~ ]5 ^) H% A if(status!= ITK_ok) report_error_stack();7 ^1 O6 T2 B9 B! b, O
else printf("Put in Newstuff Folder.\n");2 a$ F* n4 B' B5 g y) O8 l! Y' m
" [$ ?' g7 H" h8 i0 N; w# U
ITK_exit_module(TRUE);2 s$ t# e" a( o
return status;
; i/ [* B3 c, }' Q3 i3 G}* Z; G- u ]5 I+ X: _
|
|