|
请使用QQ关联注册PLM之家,学习更多关于内容,更多精彩原创视频供你学习!
您需要 登录 才可以下载或查看,没有账号?注册
x
0 ^* s3 h. L, e
Teamcenter二次开发源码分享: 创建Item Create Item方法5 X7 K$ c6 ?$ } L
' `" i7 @2 e/ i5 Y! M[mw_shl_code=cpp,true]#include <TC/emh.h>
( d4 X# ^/ V1 q; A$ b* X#include <tc/tc.h> k F% G% M' {
#include <tc/tc_startup.h>
3 E6 a8 X9 V) [, ?#include <tccore/aom.h>
/ z/ U2 l- u' k, ?
$ s: P" R& p& }+ W#include <iostream>2 t- H, {% x% c& `, U* o$ R
#include <base_utils/IFail.hxx>
" Y Y9 L+ p1 ?" _ q. q) U4 {#include <base_utils/TcResultStatus.hxx>
% h# k5 j( e) n6 X w$ Z#include <metaframework/BusinessObjectRegistry.hxx>
% O3 ? R9 `: U( f1 c( b8 b6 X% b#include <metaframework/CreateInput.hxx>, Z+ b8 r# y' n! y& [# V
#include <mld/logging/TcMainLogger.hxx>
: p* a% b( V+ o) b1 g4 s) n#include <tccore/Item.hxx>6 C6 p5 _, s+ W0 R
, n) p( I8 {2 q! N) x% T4 x
using namespace std;& V* u; e6 F6 ]. T
using namespace Teamcenter;( m& `1 C0 ^: b
using Teamcenter::Main::logger;$ R0 y8 B" ?) j6 \# S* \( z
& U1 f5 g, ?" {. Iint ITK_user_main(int argc, char* argv[])
, F% S G# P7 a7 A9 S# Y T{5 _- m: p- i- O8 @
int ifail = ITK_ok;
0 g2 I- H3 n3 |. F% `7 Z5 } ResultStatus stat;* x8 i7 t- `& T2 E' \* y. E
try
& T. T" o( {$ o {& {' @3 y0 `6 F2 f1 n
stat = ITK_initialize_text_services(ITK_BATCH_TEXT_MODE); " d% e6 C9 n! d
stat = ITK_auto_login(); % P& k9 j' Z) J# T! }) y' {3 }
stat = ITK_set_journalling(TRUE);
4 x4 J/ X+ R2 p0 E5 q' B3 \4 p
+ @" `. L/ G6 O" `' \ u2 d, @9 v3 I% h/ u0 B! n* y( L
BusinessObjectRegistry& boReg = BusinessObjectRegistry::instance();
# B; I6 b7 B; }. U, f CreateInput* pCreateInput =
" k- h5 U* Q& {2 z! L& t* ?2 h q( P dynamic_cast<CreateInput*>(boReg.createInputObject("Item", "Create"));
2 j# E' l# W W, W% s5 t2 a! ], N) }# u: Y- b- _' R1 s
Item *pItem = dynamic_cast<Item *>(boReg.createBusinessObject(pCreateInput));
2 P9 d) u3 i! r% ]) Z! Q' g
& E4 D/ x2 J2 o4 R5 t8 q5 A v: P tag_t tItem = pItem->getTag();
% o! a( f0 C' N8 _& Z3 z7 g" O4 ?6 n, [3 [6 H& A% G
string sId;: X+ c8 f* r3 w- G) w! C3 V
bool isNull = false;
L# V Y: c0 u pItem->getItem_id(sId, isNull);
: A4 Q/ |9 Q7 j6 B 3 }" y+ S. w" m; v5 ?' t) z
pItem->setObject_name(sId, isNull);) A' o) o" O, ^5 `- t% _
7 J7 x- s2 L% v
stat = AOM_save_with_extensions(pItem->getTag());2 [6 u* u$ v# m9 R
8 g! f/ z, @" Y7 O! X7 o: g cout << endl << " ID: " << sId << endl << endl;
; d6 F$ H, M6 C8 _ }
+ A- t2 j) P, t9 W3 Y catch( const IFail &ex )) X" A C3 n! `9 Y+ {& p
{
' _7 D) j" s$ C, \7 X; A4 u3 @. W logger()->error( ex.ifail(), ex.getMessage());
. {2 w- J% G/ @ cout << ex.getMessage() << endl;* d V/ b* a$ Z* n
cout << "error " << ex.ifail() << endl; 5 r1 P+ h; s/ W0 a4 ?7 p
}
8 B9 ~9 j6 E' b- o. p2 p9 h% b const char* syslog_path;
' W. i9 Y5 r$ s' n syslog_path = EMH_ask_system_log();
7 w4 D9 o2 @7 p+ c9 K. Q% @ cout << endl << endl;
1 K+ o8 {/ p: C cout << syslog_path << endl;) K" E Y, q m0 a A8 ^3 k
2 X* ]: `& L( y1 H2 n7 O' v stat = ITK_exit_module(FALSE);
9 `: t! O# X$ c# a return ITK_ok;
& R. l4 }0 B% X. y' Y}[/mw_shl_code]
, u/ b2 x I3 L |
|