|
请使用QQ关联注册PLM之家,学习更多关于内容,更多精彩原创视频供你学习!
您需要 登录 才可以下载或查看,没有账号?注册
x
+ {% C2 Q9 E6 e
Teamcenter二次开发源码分享: 创建Item Create Item方法6 U% X7 B v- v
/ y' H/ z& |$ o
[mw_shl_code=cpp,true]#include <TC/emh.h>3 V, [2 i# X4 j* o
#include <tc/tc.h>
, O% Q- R$ V* g* l- f. Z#include <tc/tc_startup.h>
$ n0 A" \& F; {. L7 ?#include <tccore/aom.h>
" `2 U9 B+ h; T# l1 p8 n* I. Y6 X
% q9 x T$ ^ v+ n2 q$ B#include <iostream>
! O! U4 Z! P7 U# X, V#include <base_utils/IFail.hxx>
$ t# x# U9 Z. I; ?8 T% q#include <base_utils/TcResultStatus.hxx>
- E* }4 ~: p* c& s' K e#include <metaframework/BusinessObjectRegistry.hxx>7 D+ ?1 Z( o& k$ U9 Q, j$ I
#include <metaframework/CreateInput.hxx>
) D! r6 S, X, r! M#include <mld/logging/TcMainLogger.hxx>
- ?# G2 t; y" }# L#include <tccore/Item.hxx>$ J5 A1 y% X# ^* e
4 ]! ^/ S! |( G q8 h6 xusing namespace std;
4 R+ q& C4 ^) o5 U7 ?3 w9 m4 f# L; d3 ?using namespace Teamcenter;; }& a# Z: h" m
using Teamcenter::Main::logger;9 H2 Z" y& c1 @( l. t/ ?+ S
) Y" ?) q; F5 W! A/ tint ITK_user_main(int argc, char* argv[])" j" I& @4 U) h" A7 @: s2 o8 i* a
{
, R3 p9 P% \/ l$ R& \ int ifail = ITK_ok;
5 ]4 M) [) A5 w( ]; X0 U ResultStatus stat;
G* n; D& w8 V3 W try
- ]1 q1 _1 [ p9 @" Y {
. Y, G* a' }2 @& G) a3 S stat = ITK_initialize_text_services(ITK_BATCH_TEXT_MODE); 6 b/ x/ ^7 l4 F, }" x( A
stat = ITK_auto_login(); ) ~# L0 i" ~# c% |8 _8 @
stat = ITK_set_journalling(TRUE);
$ g* H5 o7 o1 }6 I }% j: ?; _ v' [/ }8 T6 o% \) I& l, ` A% k3 d
6 T6 q- \- H6 P6 {) \7 I% E
BusinessObjectRegistry& boReg = BusinessObjectRegistry::instance();0 l, z: o% L! p- \! @
CreateInput* pCreateInput =
: L5 A- A* w# k. f- l dynamic_cast<CreateInput*>(boReg.createInputObject("Item", "Create"));! Y+ ?: S! y( z7 M7 g
; r d8 N; J% D& P6 A& j Item *pItem = dynamic_cast<Item *>(boReg.createBusinessObject(pCreateInput));
6 G0 ~2 c w& Y% x5 G Q, a/ x) C8 M. \
tag_t tItem = pItem->getTag();
! w3 d6 q; f" M! f- H5 K3 ?) u' G) m; S* ?& P
string sId;
5 @1 n6 X4 q. |" z& t bool isNull = false;. M$ r; w. [- ?; q) Q& r- A3 Q* P
pItem->getItem_id(sId, isNull);
- w9 n/ i* h7 V . b9 e: B( i: N3 {& d) W
pItem->setObject_name(sId, isNull);: N! p: J. i& `0 K! Z- E. v& y% T
* b8 e8 M# Q, |1 w
stat = AOM_save_with_extensions(pItem->getTag());
; p) t* c1 e% R+ y; O5 c/ k3 F" p' L/ }' v! t
cout << endl << " ID: " << sId << endl << endl;# |/ `$ V1 J1 E* x$ H9 _
}
9 o! S8 `3 ?5 s. y/ Z& w( ] catch( const IFail &ex )
1 ?) t& K3 k9 ?; e h2 h5 } {& T9 R; c6 M4 u) `
logger()->error( ex.ifail(), ex.getMessage());
4 }, X( y- l# T5 s8 F/ S1 ^ cout << ex.getMessage() << endl;
- [/ M& b: a1 L, z8 S+ \ cout << "error " << ex.ifail() << endl; 7 \8 A% B" @) G) v
}- U, |& ~/ R6 c0 B
const char* syslog_path;
% u7 m' m1 M# q$ r* G8 U syslog_path = EMH_ask_system_log();
N! {, G) i |8 E& Z. H% F- d cout << endl << endl;
, e E) r" z1 X; W: U cout << syslog_path << endl;; i" T1 }* U; r! y8 ], B3 l
# n- C2 h4 r: h5 B1 q stat = ITK_exit_module(FALSE); & Q |4 h$ g( {$ c1 k0 _8 d
return ITK_ok;1 D) P! j8 j/ u k( ?
}[/mw_shl_code]# ~) M1 i% o! T/ i( ?* `
|
|