|
|
请使用QQ关联注册PLM之家,学习更多关于内容,更多精彩原创视频供你学习!
您需要 登录 才可以下载或查看,没有账号?注册
×
+ h8 g) M; z4 j! U5 e8 o! h/ [, J
Teamcenter二次开发源码分享: 创建Item Create Item方法
0 a" w- C- q0 ^# `. O
* W3 G ^; W d0 M: a4 u) E: A[mw_shl_code=cpp,true]#include <TC/emh.h>9 \3 C- k+ f- a; d- s4 g% T; S' Q1 g
#include <tc/tc.h>! @5 r( n) i- x) I9 m
#include <tc/tc_startup.h>8 H4 I2 @" K5 x
#include <tccore/aom.h>1 Q# ]+ Z2 q3 p; Y. Q8 f2 N7 @
$ r8 o0 |7 Z! { L* |) k0 \. j
#include <iostream>
" I' t; i' z; C- M$ z#include <base_utils/IFail.hxx>
0 i% Z/ {% @( D#include <base_utils/TcResultStatus.hxx>% _" F2 Q7 Q, }, u$ [) N2 g P, q
#include <metaframework/BusinessObjectRegistry.hxx>
6 E3 H: \, N# E- u9 c' q/ C2 l6 F x#include <metaframework/CreateInput.hxx>3 [4 J% ^3 L2 a; Q# B8 e
#include <mld/logging/TcMainLogger.hxx>
/ M' i8 r/ Q" h#include <tccore/Item.hxx>
. N; A" Q, c3 S0 W
# z2 N* r- v) m: G3 Xusing namespace std;
& N. J |. o3 c2 R. [; n* N* vusing namespace Teamcenter;
$ }5 d+ { N% x/ m+ Q; Uusing Teamcenter::Main::logger;! y! E, h/ a- s; i
7 m7 H I8 a# O/ D4 o! \int ITK_user_main(int argc, char* argv[])
; C: t h0 D8 f* }7 [! ^( S{
) a8 @' o, ]7 d% w- `. s0 P0 h& ]" z int ifail = ITK_ok;
& S% d, d9 c& ?1 I ResultStatus stat; F/ v0 e# _- N* g
try
* U+ e; {" `4 [/ C& V# V W0 R3 h {
8 g6 n/ ^) L+ S$ T% y stat = ITK_initialize_text_services(ITK_BATCH_TEXT_MODE); 7 d# ?; ^0 R, x8 {% S
stat = ITK_auto_login();
/ \( U8 e3 V" b2 @ stat = ITK_set_journalling(TRUE);
$ g8 }/ r! u# ]1 I7 Y* \4 |, P! n8 K% w# Q$ L: ~9 Y$ E1 b
# u9 F. K9 H t; P4 Q9 Z/ f+ w% j& v
BusinessObjectRegistry& boReg = BusinessObjectRegistry::instance();
# b, t! v/ X5 x, _# J. E4 Q% I' \ CreateInput* pCreateInput = / m( c- V0 {1 W4 G. H8 ^
dynamic_cast<CreateInput*>(boReg.createInputObject("Item", "Create"));
* k5 {: E# g" \( j7 m
6 O( F# d9 I& b Item *pItem = dynamic_cast<Item *>(boReg.createBusinessObject(pCreateInput));
/ y7 s( s5 o) }) B9 K1 u& f- y9 A+ z% J0 f. X, E* w
tag_t tItem = pItem->getTag();
7 D3 D# l$ d& f( C0 g, h. P6 s
1 ]3 R9 Y1 f5 g- o, g( I string sId;
, M( ^% h9 Q% f* g* N bool isNull = false;* N4 C% N) Q; q" P
pItem->getItem_id(sId, isNull);7 q3 ]1 G! s4 c* o
/ ^5 e i2 m K6 l; v pItem->setObject_name(sId, isNull);
& ]6 p; h- D$ Q2 ~# ]. V9 U, y " _6 _; N1 F" R% f) B
stat = AOM_save_with_extensions(pItem->getTag());0 Z2 V G0 _9 u; X* I
4 U$ `; [+ h% H8 ?8 ~ cout << endl << " ID: " << sId << endl << endl;
`* J, i" C& y8 w- p }
/ d4 i6 R* z0 N/ e catch( const IFail &ex )! [- D' n+ p* a2 _0 T
{3 R2 t# ~- j; z9 v- I/ |
logger()->error( ex.ifail(), ex.getMessage());
5 ?" y8 i' L3 K- p' c% X# F cout << ex.getMessage() << endl;
. c4 Z$ u( U5 h cout << "error " << ex.ifail() << endl;
/ w7 ?% u9 B/ d5 ^& }' s }# [: U: X" a: f) y g6 w2 a
const char* syslog_path;# ~. _; g) Y+ S) [' _! |
syslog_path = EMH_ask_system_log();
+ g5 }9 X9 S* z9 }4 m" {1 q% o cout << endl << endl;0 H8 N; u; W1 z5 I" D
cout << syslog_path << endl;6 y$ p4 t% V; `! l+ `+ i5 {6 g
; t' O2 G R; m f. {1 z
stat = ITK_exit_module(FALSE); - X) Q9 y# m; B- g- h
return ITK_ok;
1 P- l, Z: b, w}[/mw_shl_code]
/ ~ W' }+ G# l# k; t, P |
|