|
|
请使用QQ关联注册PLM之家,学习更多关于内容,更多精彩原创视频供你学习!
您需要 登录 才可以下载或查看,没有账号?注册
x
1 Z5 @) J* I, {# m9 XTeamcenter二次开发源码分享: 创建Item Create Item方法
0 }( |+ Z, `; _( l0 f3 l
/ D) K. R1 u1 B! w6 [[mw_shl_code=cpp,true]#include <TC/emh.h>. b: {! G' C# [2 X; N. e* G
#include <tc/tc.h>
7 b2 R& F# b; G. i. ?# W# k- }#include <tc/tc_startup.h>
+ B* y' M' t' C' A#include <tccore/aom.h>
) e1 \( w9 l$ F2 g/ t# S
n0 A& K$ j5 l: `; c#include <iostream>
/ P' r8 V3 b+ F7 L7 I' J8 ?1 J+ x#include <base_utils/IFail.hxx>5 _! d) {" S2 q0 _0 Q4 V& V
#include <base_utils/TcResultStatus.hxx>2 [( B# A' k% J: E
#include <metaframework/BusinessObjectRegistry.hxx>
! {9 [: b: A; ?" v" H, }3 \( Y#include <metaframework/CreateInput.hxx>4 _: O3 J* W8 g8 m/ P# ^5 w% N
#include <mld/logging/TcMainLogger.hxx>
" T7 o& U$ E4 M8 _1 G ~#include <tccore/Item.hxx>8 ?: f I2 m6 K& U
" B9 Q+ z9 ~, ?+ {, X& w2 Pusing namespace std;
) P7 {7 _! I; [% J. c6 g2 b0 P' gusing namespace Teamcenter;' p+ M% L: e$ X1 w3 C# f s
using Teamcenter::Main::logger;: Z- t7 \3 o; M& n! G K
* L8 I2 ]+ f! g. `9 K; g% A' e4 pint ITK_user_main(int argc, char* argv[])8 |$ H1 E0 Z& n$ `( }4 W' Q- I
{# P+ }& Z" r) l, _+ ~/ y; \
int ifail = ITK_ok;
, ^% L1 G+ Y9 p5 O V3 n8 S$ S ResultStatus stat;
) W" Z0 B3 f1 n% R% _ try
5 q+ I# Z1 G3 l5 g: Y {, W1 Q1 D9 ~% h' L; K' n a x+ f
stat = ITK_initialize_text_services(ITK_BATCH_TEXT_MODE); 6 A6 S/ l8 `! n9 o( V- N
stat = ITK_auto_login(); 1 ^ h- k0 g- ~
stat = ITK_set_journalling(TRUE);
5 a1 K' _0 y9 z N; _
* Q% x& ^) |$ t4 H9 [+ j8 [' u" B) y' H! P9 i7 k
BusinessObjectRegistry& boReg = BusinessObjectRegistry::instance();
D1 p! }4 j v" j CreateInput* pCreateInput = - ]+ z% c7 r# e& t1 B" C0 F
dynamic_cast<CreateInput*>(boReg.createInputObject("Item", "Create"));3 G: T4 |1 X% z# ]. Z# T U: T
) t. d( ~# h6 h2 o; F& k. S$ R1 N
Item *pItem = dynamic_cast<Item *>(boReg.createBusinessObject(pCreateInput));
! g, r& E5 W# Z, i5 ]9 N" ?- G
, K5 v5 n. X1 e) x/ I/ g tag_t tItem = pItem->getTag();; M9 ]/ C- R2 R, E3 @
1 X( t9 m/ A6 I d2 d% ^! r
string sId;
& F( I9 l$ W7 p- Q% ^ bool isNull = false;
& ? I) { g0 d. J pItem->getItem_id(sId, isNull);
, N' S1 g- P/ n* @# ~ 3 ^( f4 `3 `5 ?* ^
pItem->setObject_name(sId, isNull);
4 C4 g2 G7 i4 H! R2 [" r9 y; T. ? e 5 V& Z. Q9 ?8 J) H8 Z, |. j
stat = AOM_save_with_extensions(pItem->getTag());; E$ T2 z- J1 S6 p8 h
; x. ]8 r) B" y/ o* [3 ?
cout << endl << " ID: " << sId << endl << endl;
# h/ S2 W) p& V+ ]; t }6 q( P+ Q( p) s" a
catch( const IFail &ex )
9 G) @ q- t4 }1 K {( v. E9 I5 Y/ ?# U
logger()->error( ex.ifail(), ex.getMessage());
( @3 S. X7 T9 E cout << ex.getMessage() << endl;& S8 o+ d, y$ U# O! w5 P; l( Y; Y
cout << "error " << ex.ifail() << endl; ) L; ?, A. q a, l$ x) s
}
& ]4 B( v0 T! p+ {" x const char* syslog_path;' A: Q# k/ I: G
syslog_path = EMH_ask_system_log();% S0 _. B& n0 d9 t; ^
cout << endl << endl;
5 H/ ^& B* q% W% v+ ? cout << syslog_path << endl;! C; ~ j* f7 Y: S; q' L- H
+ e) w U2 A; f1 M4 f9 {
stat = ITK_exit_module(FALSE); - E8 K$ k) W7 i% m+ @ w% I, u7 _& _2 N
return ITK_ok;
4 h0 R- F' t j; v) R}[/mw_shl_code]; k# `. W/ [& v" Q8 g
|
|