|
|
请使用QQ关联注册PLM之家,学习更多关于内容,更多精彩原创视频供你学习!
您需要 登录 才可以下载或查看,没有账号?注册
x
3 m$ T; Q5 W# x1 h: c
Teamcenter C++二次开发源码分享:创建item和item版本" e5 T: i# q- D) e: }9 L
7 V, { _7 t" ] V
0 [+ C+ u. p; g- x( A通过创建businessobject 指定的createinput 完成对象的创建& m1 Q7 T& {# v6 h ?8 \
8 A0 E; o9 n9 O/ C+ z& z8 M
& g4 ~7 d8 M+ g, p3 A
- #include <constants/constants.h>5 h5 I c5 Q# {: c
- #include <TCcore/Item.hxx>. G- L+ D5 {# Z8 z& Y* i9 i
- #include <metaframework/CreateInput.hxx>
0 h- e$ G$ I$ j6 b; j( C - #include <metaframework/BusinessObjectRegistry.hxx>6 `, J0 s8 a$ Q- G- k- {
# L. R& x7 ]: C* P' Z$ ]/ Z- using namespace std;+ P9 D& ?1 \5 |6 y5 Q
- M y( x% }/ z/ Z* i- S0 \- static void createItemAndRevisionWithDifferentNames(void)
2 a0 I/ f3 Y* ?& |4 b( l L: v - {& u* y# C8 n) R: u3 v" C
- int ifail = ITK_ok;
7 T4 B$ G `1 ?* J6 Q
# l( L6 T5 l3 H. z- char type_name[] = "Item";
/ u# r% K; ~' C$ P - Teamcenter::CreateInput* itemCreateInput = static_cast<Teamcenter::CreateInput*>(Teamcenter::BusinessObjectRegistry::instance().createInputObject(type_name, OPERATIONINPUT_CREATE));
- ~$ `3 |0 Y8 T; Z$ O2 C# w - & |. u2 k4 [4 I& X: Z
- //Revision type name is not always <item type name>Revision0 A5 u" A3 m, E: l) G
- char *revision_type_name = 0;
/ U2 T$ i/ ^" O0 d y* @ - CONSTANTS_get_type_constant_value("ItemRevision", type_name, &revision_type_name);% J! ~" T! a( S1 x
- ) G$ M0 @% K& P, w8 W
- Teamcenter::CreateInput* revCreateInput = static_cast<Teamcenter::CreateInput*>(Teamcenter::BusinessObjectRegistry::instance().createInputObject(revision_type_name, OPERATIONINPUT_CREATE));
5 _/ \1 S8 u! v D6 U -
9 h5 b+ m% w$ [, y$ T - MEM_free(revision_type_name);8 I. @( O9 f& z& e5 q2 H' m8 s
- 2 u. Q' Z2 [' b0 A
- // set Item properties
3 A6 P; h/ o V3 ^( d - itemCreateInput->setString("item_id", "1234567", false);7 I. t T6 h: l* ]* H2 ?
- itemCreateInput->setString("object_name", "My Item Name", false);
* D8 I" i' E+ x% n - itemCreateInput->setString("object_desc", "My Item Description", false);
$ a$ Y2 V8 r1 \4 j1 {" ` - itemCreateInput->setTag("revision", revCreateInput->getTag(), false);
9 q0 L" i0 D! {6 W$ R - ( _) Y2 e: J; U: c) U
- // set Revision properties
5 T' H1 f) H$ ^. j& B0 K$ p - revCreateInput->setString("item_revision_id", "00", false);
% J+ s/ g9 G L/ X - revCreateInput->setString("object_name", "My Revision Name", false);
+ S& y9 {# w1 u& [( G- d k" m# W/ @ - revCreateInput->setString("object_desc", "My Revision Description", false);
, x* z* N% d1 \' c6 X- r6 f2 A# s - 8 E3 w% E6 H/ @
- Teamcenter::Item *pItem = dynamic_cast<Teamcenter::Item *>(Teamcenter::BusinessObjectRegistry::instance().createBusinessObject(itemCreateInput));
8 b, |/ @( b9 o3 G' e$ ]+ M - $ t2 z& ~5 z0 u* c$ j. h
- ifail = AOM_save_with_extensions(pItem->getTag());+ N% f+ T k$ [9 L4 d1 _
& _, U8 \$ @6 d# o# b5 o& C- // If the Revision is not saved it will inherit the Item's Name and Description.
9 u6 e9 A9 Y9 \6 l( e - ifail = AOM_save_with_extensions(revCreateInput->getTag());( H- Z4 V( ?& ]8 L9 }9 L
- }
复制代码
3 f* ?1 }. s0 f- `& l7 S! [6 @7 O7 g: x7 G. c
|
|