|
请使用QQ关联注册PLM之家,学习更多关于内容,更多精彩原创视频供你学习!
您需要 登录 才可以下载或查看,没有账号?注册
x
) p$ V: i! ]2 z: ?% rTeamcenter二次开发源码分享: 创建Item Create Item方法1 l6 C s0 B# t/ B; y: y# ?$ i
4 E7 r9 K) D$ `8 o" S[mw_shl_code=cpp,true]#include <TC/emh.h>
. ^' V+ |6 R5 g#include <tc/tc.h> |' l R% [1 L% Y& e, n
#include <tc/tc_startup.h>
& I' ^* T, h& j- H( {, \#include <tccore/aom.h>- |" a3 h" t( _$ i( \
+ f" l. G" b+ e" n$ J5 w4 x#include <iostream>
+ Q5 c8 Y# u T; r; P#include <base_utils/IFail.hxx>" v3 c' l( ]0 D; j9 D
#include <base_utils/TcResultStatus.hxx>* C/ `, Y& x' J7 B- P" @. A& {
#include <metaframework/BusinessObjectRegistry.hxx>
& s0 E5 P' c$ j8 P b: P' I- W0 A#include <metaframework/CreateInput.hxx>. J% L+ Z( X: o8 |
#include <mld/logging/TcMainLogger.hxx>
, ?5 y; h3 S9 M% ^#include <tccore/Item.hxx>: q9 V& k o$ t0 f7 l* t
6 i5 S7 O2 U* U: I7 x/ w' W
using namespace std;( R$ y. E, m& Z4 R% j) N' o! \4 b
using namespace Teamcenter;
8 i8 ~4 X* _8 |7 F# Q4 ]using Teamcenter::Main::logger;, S4 e& I2 u$ G ]3 l: N0 O
6 b& N( c( d' e0 nint ITK_user_main(int argc, char* argv[])
$ G1 i9 A' w: `{% v( z, K8 B! M
int ifail = ITK_ok;
2 {" W: X8 c4 x. S7 I ResultStatus stat;
$ ?- @0 t/ j6 {) i9 s* f try2 b1 Z4 q- `% {% t0 P6 k0 @
{
& m- X- y7 s7 _) L, J stat = ITK_initialize_text_services(ITK_BATCH_TEXT_MODE); % Q+ E9 T* E/ t& n
stat = ITK_auto_login();
( P: \& e6 {: z stat = ITK_set_journalling(TRUE);: B) i8 S/ f2 C: {
( f1 {2 F8 k7 J) r6 p
8 d- g0 n) S2 Q9 k& p! X BusinessObjectRegistry& boReg = BusinessObjectRegistry::instance();
0 r9 w- r& M3 c; t2 S( _1 @ CreateInput* pCreateInput = j# r! Y* ~- N" Y/ y' \3 M
dynamic_cast<CreateInput*>(boReg.createInputObject("Item", "Create"));; {* J8 k# ?$ m. y$ G* z
! ]5 d* ]: f$ t8 r
Item *pItem = dynamic_cast<Item *>(boReg.createBusinessObject(pCreateInput));% k- h3 S% u. \7 r+ C! G
, o2 g2 d" A8 [& T6 u& Y tag_t tItem = pItem->getTag();
2 h. W" T/ f3 j; _7 N( A4 H; i1 N h% w* L) j
string sId;' ` Y! K8 }% o1 y/ J( M
bool isNull = false;
1 B( C5 _% w* ]0 f pItem->getItem_id(sId, isNull);
5 R$ [8 _* X0 d# s, I6 } % Z0 R6 X' K+ V$ a1 t
pItem->setObject_name(sId, isNull);
2 a V4 r& K; |) w$ c
# c. v. C: ?% V5 {# w, S7 Q5 m stat = AOM_save_with_extensions(pItem->getTag());+ d* _8 X7 S5 f$ G! W) l+ V$ s2 S
0 q j( t+ I* `8 b
cout << endl << " ID: " << sId << endl << endl;
* N8 O' |! F$ ~5 ]. C8 C7 G$ w; ?7 E }3 a4 W6 a, R3 e1 v8 C' ^# z
catch( const IFail &ex )3 \0 m" `) M. F& {5 c0 q) s9 W" k
{. c1 h' w9 U+ Y! [4 A- f
logger()->error( ex.ifail(), ex.getMessage());
" ?/ {/ M) f8 R* J/ [1 r' k' w7 f cout << ex.getMessage() << endl;
! y; U" @$ S2 l" T cout << "error " << ex.ifail() << endl; $ H/ ]# Y/ z" M* m$ n% R& S
}2 U3 _" u$ H6 A: L
const char* syslog_path;
) c) e% T# t* ^: r: [ syslog_path = EMH_ask_system_log();0 N# R1 ]4 h' j, @# G1 o- {
cout << endl << endl;2 ^9 c x- k4 L i* p( t' h8 [! x
cout << syslog_path << endl;% U1 S$ _' a( |5 r; ^
+ D0 x; F) u+ M: B0 ?) a
stat = ITK_exit_module(FALSE);
$ O1 |* _1 z- U, V return ITK_ok;& x0 g6 `3 N5 M; ]3 m
}[/mw_shl_code], n, r3 _/ [# a& Y9 `4 ^
|
|