|
请使用QQ关联注册PLM之家,学习更多关于内容,更多精彩原创视频供你学习!
您需要 登录 才可以下载或查看,没有账号?注册
x
5 \& {- W5 g7 H& z# c) G3 z
Teamcenter二次开发源码分享: 创建Item Create Item方法+ h+ B- {9 M0 f: s. [
$ ^# s( v) I8 z. R2 ?7 o1 D
[mw_shl_code=cpp,true]#include <TC/emh.h>
! I5 Q4 p) I; @4 G- n7 I#include <tc/tc.h>
% ?2 A6 f5 g& I; d5 B/ P#include <tc/tc_startup.h>; \4 {9 E8 K- @2 h! J- p$ x
#include <tccore/aom.h>
! j7 ]3 x: B0 H' w8 L
3 f4 C; K7 a; O0 E#include <iostream>9 b* ^$ ]3 E4 V# r" y
#include <base_utils/IFail.hxx>6 o& c, x- c7 P7 Z- H
#include <base_utils/TcResultStatus.hxx>
" w) L; A: _2 O5 S! k# T#include <metaframework/BusinessObjectRegistry.hxx>. R g/ P- b- ^( K7 {) R7 @
#include <metaframework/CreateInput.hxx>
/ G& z' L' l5 [; W0 j#include <mld/logging/TcMainLogger.hxx>: c& R0 Y' y# ]
#include <tccore/Item.hxx>
: O u2 f$ _8 b9 [( s" P9 ]! ]+ t- @6 Z" O) T! v- u
using namespace std;" E2 B3 j% K s8 B
using namespace Teamcenter;+ M) r; M) W3 W
using Teamcenter::Main::logger;
9 z. ?+ | z5 c1 Z
L# X9 U$ y$ z, F0 ^int ITK_user_main(int argc, char* argv[])
6 [3 p7 O5 v$ P{8 T! I" ^5 I* o' z
int ifail = ITK_ok;
3 B% P& B5 n/ Z- l/ b ResultStatus stat;" z7 B5 Y, y6 V' C
try
5 g9 V4 a9 Q$ i9 f {" G- l N, D+ V0 d$ U9 L
stat = ITK_initialize_text_services(ITK_BATCH_TEXT_MODE); - x3 u) Y* a& j1 L% L1 R
stat = ITK_auto_login(); : w" z$ I; ~* j* f' h, a
stat = ITK_set_journalling(TRUE);
b# x0 ]7 Z! Z2 C8 Y" ~! @ l- e( W
. l: o) |! X5 h" H' C' A' Y& }
BusinessObjectRegistry& boReg = BusinessObjectRegistry::instance();; t, [7 A4 h% Q' w: H
CreateInput* pCreateInput =
5 z" W' I9 {& Z+ p) ` dynamic_cast<CreateInput*>(boReg.createInputObject("Item", "Create"));
5 p/ {9 ~. z! p) E4 X) F+ y, ~' I J! P) u0 R
Item *pItem = dynamic_cast<Item *>(boReg.createBusinessObject(pCreateInput));
1 R# J, ^# r2 E% J: j" {+ K5 [" |2 h0 v. o I" e
tag_t tItem = pItem->getTag();% F! |/ I) x7 p u+ Y5 k
0 }% U4 m A9 O string sId;0 z3 r7 i) z: o
bool isNull = false;! _' r' ^" u* F3 ^0 \8 j# j" ^
pItem->getItem_id(sId, isNull);
2 o( b# M0 g7 r; P" l3 ?# o G: P% k$ u' ]
pItem->setObject_name(sId, isNull);
6 b& Y, {, K) Y7 r# N1 x4 D' o
6 z: V; O; Z1 A: H8 X9 b stat = AOM_save_with_extensions(pItem->getTag());
) j: k" }$ n! M3 n- x0 X2 t- [: X) t0 s" p+ b- Y( {' S
cout << endl << " ID: " << sId << endl << endl;
) _$ q2 X/ g6 } ?) V }
- I6 Z# N( |, c1 V catch( const IFail &ex ): v) q* G1 N0 Z9 G& M
{
6 K, l7 T. j5 S, S logger()->error( ex.ifail(), ex.getMessage());
- u0 E: t' W' O& p- _% ^3 x3 S cout << ex.getMessage() << endl;- {- Z& { c2 _5 `+ h( E7 q8 I j
cout << "error " << ex.ifail() << endl; : b/ s: h8 N" G& F5 d0 v
}
/ Q1 i( h* O$ b- ~ const char* syslog_path;
' l/ M1 O: |) p' y syslog_path = EMH_ask_system_log();
( C, @+ j1 J& K) {1 u; ^ cout << endl << endl;
. j; o. T$ R' S% v$ q% H cout << syslog_path << endl;
1 ^$ D6 f4 v- o. \% |. ~. }' g1 h+ B( i7 `' g
stat = ITK_exit_module(FALSE); & ?, W! p* Y& g5 t
return ITK_ok;9 x. E& {0 @6 ^
}[/mw_shl_code]
/ t; p* ~. b( W3 ?! K+ W |
|