|
请使用QQ关联注册PLM之家,学习更多关于内容,更多精彩原创视频供你学习!
您需要 登录 才可以下载或查看,没有账号?注册
x
! ], d9 F- T: H( R, I
Teamcenter二次开发源码分享: 创建Item Create Item方法0 w0 s) q! X, z" ]
0 l, W1 i7 [, F& P
[mw_shl_code=cpp,true]#include <TC/emh.h>
& ~; J, G. W7 f( { B0 V#include <tc/tc.h>' ~% i3 D9 k1 b
#include <tc/tc_startup.h>
Y! w( [. n+ F+ I#include <tccore/aom.h>. P1 F: V1 I3 U
* g+ H& k; U6 T* w- m) I! F#include <iostream>8 a9 w% W& Q: r7 m! u3 m; h
#include <base_utils/IFail.hxx>
* B6 w+ D$ s1 a& i' T* o- u6 C' B#include <base_utils/TcResultStatus.hxx>
+ O8 B/ ?: `& X/ k#include <metaframework/BusinessObjectRegistry.hxx>
# m8 A1 v& [" L' w" k#include <metaframework/CreateInput.hxx>
: `2 _ @2 P) q1 ^#include <mld/logging/TcMainLogger.hxx>0 Y: W! w0 v5 P: d# J# z/ n( q
#include <tccore/Item.hxx>6 O' \* i: v( Z- {+ f
) T4 B4 @8 X! i6 g- @1 K/ U
using namespace std;/ Q3 M/ e @5 B
using namespace Teamcenter;
" ]6 ^- F& C9 G N) Vusing Teamcenter::Main::logger;
! U( Q. Y* ^- n& N* ^/ F) V! q9 O S: p2 B
int ITK_user_main(int argc, char* argv[])
* L' z, [ t h$ d+ _3 o9 {: m6 k! u{4 H6 A. X0 R* `$ j4 S
int ifail = ITK_ok;
/ `- P$ s% p1 d" n( ?. I ResultStatus stat;( ~, N& _ y9 r5 D1 p( K; o
try3 b5 i2 Z/ b4 s! L6 { t. C) }
{
! c; j9 H+ z- C# U; x+ U: R stat = ITK_initialize_text_services(ITK_BATCH_TEXT_MODE); ) q0 p4 D8 g7 n a
stat = ITK_auto_login();
# p" @& i6 W3 V6 P7 { |! J stat = ITK_set_journalling(TRUE);, T" t, G/ o& F
' ~! F& L; [- p% x8 G3 d
$ ?* Y4 d! A. |6 h, c. q BusinessObjectRegistry& boReg = BusinessObjectRegistry::instance();7 S' x9 F5 E: O6 r
CreateInput* pCreateInput = ( x3 h, `! b" I6 a( N
dynamic_cast<CreateInput*>(boReg.createInputObject("Item", "Create"));
* l. e+ W8 T% o K, e. L' V1 S
2 z, l9 v# D8 D# C3 Z% M: G Item *pItem = dynamic_cast<Item *>(boReg.createBusinessObject(pCreateInput));4 Y5 L& b! f h# o& L, o
8 r1 ]" Z& A" B) K) ~; B tag_t tItem = pItem->getTag();
3 W, g# y) Y2 O- e' Z: }4 N+ E. W6 ?/ T' N P9 J
string sId;
) |; E* f4 |$ Q9 V- q' m bool isNull = false;1 `) {* E7 m u. } Z7 D2 s
pItem->getItem_id(sId, isNull);$ E. a K6 r2 g, p% ~0 Y- b; O
7 `! E' \ Q1 H
pItem->setObject_name(sId, isNull);0 d$ H$ w1 c/ e! H* g6 R/ K
/ ~. S3 Y$ l, W
stat = AOM_save_with_extensions(pItem->getTag());
. l/ C/ f, m' s1 m" Y0 ^, H# G2 @# U% A# ^' G6 M2 d; O& f
cout << endl << " ID: " << sId << endl << endl;
6 e0 r8 k, ^- C% H0 b5 t! k4 Z1 h }
" Z2 p" T- Q# ^' Y$ _, N l catch( const IFail &ex )
% {$ i: c- }: m; z" M$ e$ b+ b% y {
( B/ S( O: N( |3 | logger()->error( ex.ifail(), ex.getMessage());- A9 C5 L/ K; g0 s4 ]+ X* S8 C
cout << ex.getMessage() << endl;2 N/ W$ N* C+ }7 q$ d: U; x: \
cout << "error " << ex.ifail() << endl; 1 S, _3 f$ W4 h0 U2 b
}
^9 ]! Z2 }4 U$ q) \. P. i const char* syslog_path;8 V0 T- z2 B9 d
syslog_path = EMH_ask_system_log();$ E; \$ Y- V# x
cout << endl << endl;
( H/ n2 W/ ?8 p$ X2 j6 U! H cout << syslog_path << endl;
, g5 x) V4 j) F. E$ L
) j" }. t( `: X/ V# {5 o/ Y stat = ITK_exit_module(FALSE); * P9 O4 |" V! U' R1 V5 a l2 B/ c! p
return ITK_ok;4 ]- o9 H5 m3 ^; j
}[/mw_shl_code]: e; n' R& ~2 y
|
|