|
请使用QQ关联注册PLM之家,学习更多关于内容,更多精彩原创视频供你学习!
您需要 登录 才可以下载或查看,没有账号?注册
x
H; Y! Y& \- q, T g! zTeamcenter二次开发源码分享: 创建Item Create Item方法
) I4 H* C5 J9 A5 _$ ]( Q) k9 l1 V
[mw_shl_code=cpp,true]#include <TC/emh.h>; U2 L0 P- W u% ?" B
#include <tc/tc.h>
2 M- I7 A$ ~4 }+ h7 B#include <tc/tc_startup.h>
) O9 T5 B- v- r/ i2 ?- w4 e#include <tccore/aom.h>
5 d4 V. y( V: v' f+ F2 v8 s1 ?
/ N5 b* _( M* r0 t: @1 V#include <iostream>
* Q5 o$ s) {& h, \) W#include <base_utils/IFail.hxx>+ g. ]! |; a/ n! K
#include <base_utils/TcResultStatus.hxx>6 X# P7 ^! M6 k# x; ~- m) Y6 K
#include <metaframework/BusinessObjectRegistry.hxx>
) b" M8 n6 `" d; F) t, r4 y#include <metaframework/CreateInput.hxx>
3 M' L6 B# a. q: m#include <mld/logging/TcMainLogger.hxx>( [5 k9 m% X: u! I
#include <tccore/Item.hxx>
2 e t$ `4 M( t
) h! [, V- A8 ~- o* Vusing namespace std;
% |$ L# k' T. `: V7 m9 c1 m' Susing namespace Teamcenter;' a1 U: a' c% k1 O
using Teamcenter::Main::logger;. Y9 U! e2 b, \
( Z z% p: I Z0 j
int ITK_user_main(int argc, char* argv[])
2 \ \3 c5 J/ H6 P{
?& Y* p# B1 \& E/ T int ifail = ITK_ok;
7 m3 l: C1 b' `; t- h ResultStatus stat;
: u! e$ v: S1 [( L8 @+ s! e try, \& |7 R+ v/ _, R
{9 S! ?( ]" O7 {" q& d
stat = ITK_initialize_text_services(ITK_BATCH_TEXT_MODE);
9 r6 G$ Q, k# {( a8 O4 V$ S stat = ITK_auto_login();
1 g C$ l* I( T$ t$ e6 I6 d* r stat = ITK_set_journalling(TRUE);* Z8 x5 T# Q1 C2 a( X+ i
% u& n* {! ~! E# ]8 n
* w2 ~0 b' i7 @. v. x; b. D8 {6 N
BusinessObjectRegistry& boReg = BusinessObjectRegistry::instance();
# U6 I8 m; f5 ~ CreateInput* pCreateInput = 7 a: U' E$ d( b: h# r3 X
dynamic_cast<CreateInput*>(boReg.createInputObject("Item", "Create"));2 U# Q L3 U, l% q% l1 u0 |
- O; B6 \6 O/ w, W
Item *pItem = dynamic_cast<Item *>(boReg.createBusinessObject(pCreateInput));& p1 f( M3 w/ k( B3 j% \
$ \2 z* x: |( w3 x8 f( y
tag_t tItem = pItem->getTag();
$ h( w- y# }( b- q
% V, b) e( t$ C u; Z string sId;6 V6 L2 V! B0 l K
bool isNull = false;0 N; f+ [* J, o- b" R, P& n
pItem->getItem_id(sId, isNull);3 c, n. a1 \+ N& l9 _2 n$ J
5 f% N" K. Z' {! X' }: s pItem->setObject_name(sId, isNull);
. u6 v+ A! @6 M7 t& r
, {* ~; d) Z: U6 B% `" ` stat = AOM_save_with_extensions(pItem->getTag());% X8 N# h# G- ?! l; ~: E: u
2 x1 O0 K7 u) `
cout << endl << " ID: " << sId << endl << endl;
0 V9 c% s% P/ Z) _ H; Q( e }
, G, X9 K" G" B) e7 a8 e( V catch( const IFail &ex ); F! K3 a+ \! f1 A
{
% B' D, Y( C- o logger()->error( ex.ifail(), ex.getMessage());9 I; L, {- q0 t/ Y$ B6 i9 G; W
cout << ex.getMessage() << endl;
: j D4 V/ w r4 G/ g* c- L cout << "error " << ex.ifail() << endl;
1 q" }5 U' Y+ R3 J' V }
. {* Y4 U3 u! j. Z const char* syslog_path;$ y+ Y/ ^9 L5 X& V* Z9 E4 R
syslog_path = EMH_ask_system_log();" U; B" j- f6 @/ O3 N( o
cout << endl << endl;; Y x( n0 V" J5 l( y" w: \9 M
cout << syslog_path << endl;
' \3 y- r0 y5 P- G* ]) s1 |! \/ S( A6 ]8 D, m
stat = ITK_exit_module(FALSE);
9 C1 Q9 B% e- Y: X return ITK_ok;3 s7 I, [4 T2 b
}[/mw_shl_code]
. t6 c8 r1 f: n! Y( H' ^2 w6 @ |
|