|
请使用QQ关联注册PLM之家,学习更多关于内容,更多精彩原创视频供你学习!
您需要 登录 才可以下载或查看,没有账号?注册
x
. {. |& T1 M; C( \8 c" u
Teamcenter二次开发源码分享: 创建Item Create Item方法
: B) c% a* a# e, W+ k. T% Z4 M) Y$ n. N
[mw_shl_code=cpp,true]#include <TC/emh.h>
* ^8 ~' w9 f+ S; A5 u#include <tc/tc.h>. l9 C; M" D0 n: b7 z2 u# e
#include <tc/tc_startup.h>3 @6 V1 F8 _8 _
#include <tccore/aom.h>
3 E! f% B+ h: q" q. b' g2 H3 R+ @' s7 }+ [! l! x8 I
#include <iostream>! W+ z8 O' a! _ [
#include <base_utils/IFail.hxx>
5 m# s2 i0 s- w' v( I#include <base_utils/TcResultStatus.hxx>3 B4 B7 V7 |* G% u/ H" S) O
#include <metaframework/BusinessObjectRegistry.hxx>
4 k' }% W& i8 F/ B! S#include <metaframework/CreateInput.hxx>
2 C; l& ~" v9 f6 N+ n8 c/ t( a#include <mld/logging/TcMainLogger.hxx>
; Z8 y: d% S6 D6 |; H+ J6 w7 ^8 \ a+ V#include <tccore/Item.hxx>+ s3 G3 l; c, E. t. s9 g
& R. i& P6 I1 P0 ~7 \# vusing namespace std;: N1 ]: f, T: w' z" D0 n' F/ x$ g! `
using namespace Teamcenter;
7 j4 J, H& i, X1 u# S8 `using Teamcenter::Main::logger;
8 Z, ?( p0 W4 x6 W m& @5 K7 e
' [2 ~/ E: v* `+ y; ?7 sint ITK_user_main(int argc, char* argv[])
5 X1 H8 i$ e- a: F0 E0 y" {6 m{
( r' O" X |$ c* {+ l3 m; C r int ifail = ITK_ok;
! x q2 `! y! A! o, o4 Z0 @ ResultStatus stat;" w2 }+ _. N! w U) ^$ l0 |# @
try
9 r1 x" k+ K9 Q& r5 D5 R* u9 I' j {
3 E! H/ k/ e6 S/ H, T8 G" F! I( C/ Z stat = ITK_initialize_text_services(ITK_BATCH_TEXT_MODE); 5 w( H( [% T4 g+ \9 u
stat = ITK_auto_login(); 6 k! J1 [$ u5 Z) }# J9 O0 S
stat = ITK_set_journalling(TRUE);) B; U8 a* A" T9 H: J* {9 k# d& ^
8 n" {" X: c$ B) x9 L! B3 b k. ?
BusinessObjectRegistry& boReg = BusinessObjectRegistry::instance();
( |$ A) F, M5 r: I, }) d CreateInput* pCreateInput =
. K1 S* m7 m0 T- ^1 m: E: w dynamic_cast<CreateInput*>(boReg.createInputObject("Item", "Create"));
5 c. L6 J) Q7 C* g
4 s' z w6 e" y! M Item *pItem = dynamic_cast<Item *>(boReg.createBusinessObject(pCreateInput));
, w3 |5 f9 B. U0 H" I+ q: ?
. \3 i& y4 m; L4 ^$ f1 z tag_t tItem = pItem->getTag();$ q4 O# l# L5 Q
+ o) Y0 ?9 ?0 s l7 R) T, M4 q
string sId;
# a+ Y6 }% S/ Q/ K$ m bool isNull = false;9 n' t* U6 a" S: N. ^
pItem->getItem_id(sId, isNull);( b, c+ Q! f% }" J, Z
5 f( g* h$ c+ K6 ` pItem->setObject_name(sId, isNull);
: {9 @$ Q! \6 x+ H) l+ l
! p! s8 g* J) b5 ?/ Q4 K. T stat = AOM_save_with_extensions(pItem->getTag());7 H! C1 G" [& X
" Z- Z; B3 l8 t* j$ s/ s) Q/ K6 a6 ^ cout << endl << " ID: " << sId << endl << endl;
% n8 x5 d% `1 d$ L: ? } P9 `& ]# ^# c' \2 R \, h% k0 G4 D
catch( const IFail &ex )' A8 I# y q% G+ K$ v
{
# P# e2 y% _2 G- f6 W# r: W logger()->error( ex.ifail(), ex.getMessage());
9 g! H# `! ^! G9 o0 ~ cout << ex.getMessage() << endl;
/ i" J& Y( ]' ]9 N9 s" ~8 Y cout << "error " << ex.ifail() << endl;
/ W3 u$ e& G+ H% l% J6 ~ }
; _3 X3 \. x6 L" s3 Q; _" v( O const char* syslog_path;( l% Z: [. M# Q6 r0 O" s
syslog_path = EMH_ask_system_log();
2 L1 A" \+ N: q$ T3 A" ] cout << endl << endl;
" K5 Z' U w/ X( J: F: G cout << syslog_path << endl;5 C" `5 [9 r3 V
. j, `$ v9 m5 a; E" J stat = ITK_exit_module(FALSE); / p/ Z5 Z& Z, ~. V7 j5 X
return ITK_ok;. C( F* M& Y* @* L9 G4 C
}[/mw_shl_code]
6 M( o6 x* Z% Q" [; X& D |
|