|
|
请使用QQ关联注册PLM之家,学习更多关于内容,更多精彩原创视频供你学习!
您需要 登录 才可以下载或查看,没有账号?注册
x
9 W' D, b5 a% v) ]' ]6 fTeamcenter二次开发源码分享: 创建Item Create Item方法( }9 G' I2 [) G" u
/ ~6 ]# M0 d# B* h# f[mw_shl_code=cpp,true]#include <TC/emh.h>
?5 j/ i2 [2 i: r#include <tc/tc.h>
$ w2 \! P. E4 P- ~# f$ v#include <tc/tc_startup.h>
4 c% F& }2 p2 t: o#include <tccore/aom.h>
+ W7 r& ?' }) |* g: Y4 D, ?( i* m
4 `3 H; a X8 F' w: S4 L3 T( t#include <iostream>/ d4 N& N1 f% W) v- q" h
#include <base_utils/IFail.hxx>, A- W3 k2 f: F2 q, s+ ?
#include <base_utils/TcResultStatus.hxx>
1 c: s: \! z2 r: p) w) \#include <metaframework/BusinessObjectRegistry.hxx>) x$ Z6 a8 i0 }' t; z
#include <metaframework/CreateInput.hxx>3 i( h4 |! j% c4 _
#include <mld/logging/TcMainLogger.hxx>
% @8 e! C8 T/ _0 e- H#include <tccore/Item.hxx>
3 g; R# o Q3 F! u9 u( x. u; ]" S
using namespace std;$ i1 c& m$ k/ U5 x0 j* E
using namespace Teamcenter;
7 B" O& }. z# j5 q- e7 G7 k. ?using Teamcenter::Main::logger;
. `- V4 m0 u4 p9 Y. Y- r) e, c0 {4 Y- E1 f9 D5 v0 B+ @
int ITK_user_main(int argc, char* argv[])1 g1 v3 l( y. w* B' |
{
0 J/ @) `, Z2 K7 J- Y int ifail = ITK_ok;
4 x ]) t' F6 w. X& R2 V ResultStatus stat;
3 W6 \9 n2 u. C" h* Q1 _ try
1 C8 p/ a* G, i" G8 W! O {! Y0 X5 s% {) A/ b& z1 f
stat = ITK_initialize_text_services(ITK_BATCH_TEXT_MODE);
+ _! T# o* Y6 y6 D o" R stat = ITK_auto_login();
2 D2 Z( S8 e9 M0 V6 l stat = ITK_set_journalling(TRUE);
0 Q3 @& i! S% n$ c/ [) j' Y' K
$ {8 C/ m/ K1 b: d
BusinessObjectRegistry& boReg = BusinessObjectRegistry::instance();
, _6 U4 g- b4 u; R CreateInput* pCreateInput = * e: [0 _1 A7 r# D
dynamic_cast<CreateInput*>(boReg.createInputObject("Item", "Create"));- ~* K$ L% _+ x; H4 h) |
* K6 e% v9 e/ a( _9 e6 [8 X
Item *pItem = dynamic_cast<Item *>(boReg.createBusinessObject(pCreateInput));
% j$ F$ d2 e2 a! `* a" E
9 u, ~3 y- R7 Q5 j$ p/ s S tag_t tItem = pItem->getTag();3 H x e t& \
8 [0 g' M+ S& a+ Z! Y/ V string sId;
- a) R C# h5 E0 o! A bool isNull = false; o9 F: S0 L+ i" |8 s5 c; o
pItem->getItem_id(sId, isNull);
4 e y- k7 U( W( V* s, U " A1 b( x. ` u4 S+ h# n c+ S
pItem->setObject_name(sId, isNull);
/ `. u6 E+ `" q7 W+ [8 T0 _ ) K2 l0 q9 P) G( d/ W+ v+ s
stat = AOM_save_with_extensions(pItem->getTag());
" G! a$ f3 P2 b' f0 ]5 S- V# O0 m- x, T5 h: b- Z- P( S( i1 O4 k
cout << endl << " ID: " << sId << endl << endl;8 k: r2 h9 O$ I7 _2 I8 }
}9 J5 i1 l8 z7 {& q% @. n1 c
catch( const IFail &ex ), |1 R2 d; i( l2 h
{3 q" E9 g6 R; w- j N3 m0 \, N
logger()->error( ex.ifail(), ex.getMessage());% y4 ~2 {3 S1 j
cout << ex.getMessage() << endl;
9 @4 l% B) J: k8 h. L cout << "error " << ex.ifail() << endl; " N- P" K6 c1 v* A" M& {2 n5 T
}' {) y- E c( g$ R
const char* syslog_path;0 @4 \' i2 D$ ^$ I
syslog_path = EMH_ask_system_log();0 r# B* I8 R1 t
cout << endl << endl;
. i# V$ Q0 l+ g& S" q' M8 U8 e cout << syslog_path << endl;# @) S& r- x2 T% b( f
4 U& `0 b5 l" J) B* P* R stat = ITK_exit_module(FALSE);
% @6 S- r8 J% y: G return ITK_ok;/ J1 ?$ f& [* ^$ Z' x
}[/mw_shl_code]
4 O8 w+ N$ V% z2 G |
|