|
请使用QQ关联注册PLM之家,学习更多关于内容,更多精彩原创视频供你学习!
您需要 登录 才可以下载或查看,没有账号?注册
x
7 R+ V/ f6 ?+ C: ~ ~6 f0 q
Teamcenter二次开发源码分享: 创建Item Create Item方法
/ B6 y4 A) @. j4 |: p
8 G4 J# {0 ^, L' f; ?[mw_shl_code=cpp,true]#include <TC/emh.h>
u8 F( Z; N! Y6 M0 F8 o#include <tc/tc.h>& Z! w& S @$ r5 Y- C' ?
#include <tc/tc_startup.h>
1 T2 B& u4 D" ~- g- t" Z#include <tccore/aom.h>1 _$ A0 x5 H" C- B; B
3 G5 @5 M# T' K8 l6 H, \
#include <iostream>
( `5 M3 F- I) X t; y) q L#include <base_utils/IFail.hxx># |- d- ^+ C8 J* d4 y# M
#include <base_utils/TcResultStatus.hxx>
; }8 B! A ]2 A% q* \#include <metaframework/BusinessObjectRegistry.hxx>
% U' q1 I/ R9 P; K#include <metaframework/CreateInput.hxx> H) P$ g3 e7 M# r" S2 c
#include <mld/logging/TcMainLogger.hxx>5 ~( ?' j5 m, f5 T$ o/ i
#include <tccore/Item.hxx>& A8 X* |5 B$ V" x5 Q
( ^! f. S9 O M+ I) X0 R) Eusing namespace std;
3 P: t4 r" J% |% ]8 E/ husing namespace Teamcenter;5 W: y& F* `' D9 t7 t, f
using Teamcenter::Main::logger;* [. J9 y; { W |/ [3 z
: O0 P; w% e! O+ F' ~+ z! h
int ITK_user_main(int argc, char* argv[]); w r5 b8 [1 ]0 d# j1 ?; M# I
{ ?; Y+ f# T/ O6 F5 n
int ifail = ITK_ok;4 w' z# A* b; b
ResultStatus stat; _3 D }7 l' o* G2 {+ e5 ~
try
# n* i2 {3 T3 Q, E' ~ {
/ ^8 g \" j: T7 \& o9 [) `9 i* G stat = ITK_initialize_text_services(ITK_BATCH_TEXT_MODE); x) U8 _3 V7 _0 U
stat = ITK_auto_login();
; b0 z j% [2 Z stat = ITK_set_journalling(TRUE);; t% A- t0 a7 p( ` A
8 j1 s, x: f3 b9 y) u! W; g% b. U
7 e+ e8 I( }/ |' a* O BusinessObjectRegistry& boReg = BusinessObjectRegistry::instance();
" y8 A3 R: W4 ` CreateInput* pCreateInput =
0 Z0 c* t4 \1 m, F: @ dynamic_cast<CreateInput*>(boReg.createInputObject("Item", "Create"));
: R+ b7 o* j/ C, ?4 d( ]- V1 A, k; R: K$ ]* Z
Item *pItem = dynamic_cast<Item *>(boReg.createBusinessObject(pCreateInput));' |' Z" \4 T. {* \
6 M! K5 N' h- H2 x
tag_t tItem = pItem->getTag();$ F5 ]" Y& \% |
/ i8 U, o8 P* Y" Y( h& b
string sId;& {3 G- J3 F" J+ l/ O9 k! t8 B
bool isNull = false;
4 T. k! X" i( G1 H pItem->getItem_id(sId, isNull);
$ V4 u) C* T" y
( q$ t, Y7 {* D5 \5 x, w. X, i* Q pItem->setObject_name(sId, isNull);* \: U H, ~5 a/ t
+ {( b( y: `6 X1 k& c8 _" I
stat = AOM_save_with_extensions(pItem->getTag());
. w3 V' I3 E' [) X, E- J3 |
, ?5 G7 X; x+ B+ b8 s cout << endl << " ID: " << sId << endl << endl;
% u9 j) P/ d/ O5 { }
* f' M2 D+ w& |- n* t% v7 N5 h% O catch( const IFail &ex )
& Q+ f2 H- K1 v+ m# N! Q {& P, Q: E" p9 H5 U
logger()->error( ex.ifail(), ex.getMessage());
* g: Q4 a& v3 K, ]2 s* y# B" }9 Y cout << ex.getMessage() << endl;9 x& g( z- ~& p" m4 y- Q
cout << "error " << ex.ifail() << endl; * \$ v3 M8 O ~) k" p
}
1 k- I W& k/ r; i const char* syslog_path;
: ^6 b0 d3 Q: K) ] U syslog_path = EMH_ask_system_log();- [: p+ ]- g" n* a( w
cout << endl << endl;+ m% _$ W) E; g6 p& u
cout << syslog_path << endl;3 D6 ?- v2 T- m* t( x# { X
' [( p o8 [2 m" o2 l! P. H3 X
stat = ITK_exit_module(FALSE);
2 @' w& ^0 ?8 f+ n! L return ITK_ok;( S, \5 L' X- _! B+ e
}[/mw_shl_code]
l7 b& P$ ?3 @$ @! j |
|