|
请使用QQ关联注册PLM之家,学习更多关于内容,更多精彩原创视频供你学习!
您需要 登录 才可以下载或查看,没有账号?注册
x
2 K& Y% P7 N9 Y9 V1 b
Teamcenter二次开发源码分享: 创建Item Create Item方法2 p- `9 J9 @% P7 [$ n6 h- ?
7 J% _+ E* }1 u( c+ R
[mw_shl_code=cpp,true]#include <TC/emh.h>
6 P J0 u$ [- ?+ A#include <tc/tc.h>; q: e" @" _6 | F7 u
#include <tc/tc_startup.h>: `, M: k2 u" |! a* m
#include <tccore/aom.h>9 W& V- U+ N/ L4 t* D2 T/ s
/ o+ O! h) C5 u% W" I; h#include <iostream>
( {* Z& ]) X- l/ {0 @#include <base_utils/IFail.hxx>
6 N/ {# \ Z' W+ d2 l#include <base_utils/TcResultStatus.hxx>
; d% O% M% X0 N9 X9 ?$ M#include <metaframework/BusinessObjectRegistry.hxx>
# z( U5 U# C6 |# Y& S4 ]) \#include <metaframework/CreateInput.hxx>- S8 V" m+ c# |6 m U7 {8 ^: d0 Z# p
#include <mld/logging/TcMainLogger.hxx>
" h$ Q2 B! M ^+ _# C#include <tccore/Item.hxx>$ Y- ~ _% f8 ^3 W! r) n+ `9 L
- v" }( @/ z7 ~3 y# Rusing namespace std;
. K; N ?" p' s; H+ s. l6 eusing namespace Teamcenter;* r) W ^: K% v% f# i' ~& x: V
using Teamcenter::Main::logger;
, b+ {3 U, [4 R* x$ b4 \& t) A; Y$ K) v" h
int ITK_user_main(int argc, char* argv[])
" _( P0 {1 G+ d3 l' D! d. g; G{" d. o) ?, N, a" S3 D7 H" N# Y5 w$ u
int ifail = ITK_ok;
8 [( M/ |8 u' q Q9 a% g; g' D ResultStatus stat;6 W- c- I+ m3 x& r1 Q" l$ N& a3 m
try
' a4 d. f- f$ \+ m {: P* b; b0 r- T5 m7 ?$ S; e! {
stat = ITK_initialize_text_services(ITK_BATCH_TEXT_MODE); . n0 V& Y7 F/ q2 T) K9 A, d
stat = ITK_auto_login();
( e# G9 @, Z- x stat = ITK_set_journalling(TRUE);: ~) G* ]3 G8 U# f$ k# K
5 @* V5 I5 ]3 x" e$ w
9 Q2 ]: j7 S6 o8 ]; J BusinessObjectRegistry& boReg = BusinessObjectRegistry::instance();* p$ y! A: _7 M: {$ [
CreateInput* pCreateInput = " X0 l+ s/ x$ N2 O) I
dynamic_cast<CreateInput*>(boReg.createInputObject("Item", "Create"));
3 Y- `% Z, i1 C" U O8 W
3 \: U- Y3 ]& S1 {- X- T5 S& J" L Item *pItem = dynamic_cast<Item *>(boReg.createBusinessObject(pCreateInput));
3 W- n0 p. r J) i( N2 k. V! Z6 o6 w+ _8 {1 @1 C# y8 F
tag_t tItem = pItem->getTag();* k f2 U! ?: `* R- W1 |7 `1 d* k! L6 q
: i* R" D; W; S) L/ _ string sId;6 q0 z6 `* I2 c8 K
bool isNull = false;3 z& m& ~$ D }: O" |9 q
pItem->getItem_id(sId, isNull);9 O; \$ |) n3 o- i1 g" @( b* Z
; x+ ~# N3 ^$ ?- T' } pItem->setObject_name(sId, isNull);
5 y! v4 F+ T- w
]; g4 ~; |9 B, \ N: m5 v stat = AOM_save_with_extensions(pItem->getTag());
! _* `4 G" L6 N) }" W0 u; D: g x
: e1 N& K1 X. Y) r0 M cout << endl << " ID: " << sId << endl << endl;
; m) b/ S$ e0 H1 P4 t5 o. k }% y4 V$ d- h, m7 a
catch( const IFail &ex )
7 r/ O7 V- o+ V3 i" U0 I- w$ ? {/ J3 t2 ~9 H- ?0 {3 r8 C
logger()->error( ex.ifail(), ex.getMessage());- {" c/ |% |$ ~ P" r3 O
cout << ex.getMessage() << endl;( C- H3 Q9 P$ @' @! C
cout << "error " << ex.ifail() << endl;
& ?0 M6 P+ _& p. G2 N/ L6 V+ c }
' J; j+ l2 L7 S7 T5 b const char* syslog_path;
3 B+ I; i% O) o5 h! o* o3 h3 g) P syslog_path = EMH_ask_system_log();
" ?* w' Z' E9 N7 _ cout << endl << endl;+ `! N5 O! e/ w
cout << syslog_path << endl;
/ Z+ w) O1 C7 ]9 U% q+ x# B c% g2 `2 e2 y) p6 Y
stat = ITK_exit_module(FALSE);
! n8 J( Q |" r return ITK_ok;- c) U; n j% `- ^8 Y3 N: {& b
}[/mw_shl_code]
( h) w H7 E# C: C% q- [: S |
|