|
|
请使用QQ关联注册PLM之家,学习更多关于内容,更多精彩原创视频供你学习!
您需要 登录 才可以下载或查看,没有账号?注册
x
% Y: W4 @) w1 i9 o/ g. `: {Teamcenter C++二次开发源码分享:创建item和item版本( _) e+ n: {0 w' I
! G9 b7 [) h8 a5 z% l" g3 B3 e* y6 j- F/ r7 r
通过创建businessobject 指定的createinput 完成对象的创建
4 W" C- x8 d M; d( W- O* ]* r
. J y& \/ z+ X( D" D% s6 B4 L( E# J" `! \3 T" {: `
- #include <constants/constants.h>6 A% |6 l% L. z( G* H4 Z
- #include <TCcore/Item.hxx>
+ J( V' Y& R1 S$ k/ ^% ?$ \ - #include <metaframework/CreateInput.hxx>- P3 l; V: W- Q. Y: ^3 b: ?
- #include <metaframework/BusinessObjectRegistry.hxx>
- f! l) [- H: v/ G5 k
* L O* t0 X- k- using namespace std;; p1 L9 F% ^; a! Z) o
- - K1 N' @) x6 c1 e2 `, F" r# a
- static void createItemAndRevisionWithDifferentNames(void)6 C" W2 e, {7 E6 k$ p5 ?% A8 p" }
- {
9 g# J, F ]1 J; ` - int ifail = ITK_ok;- ]; J9 p6 V& ?6 j. f
% e+ v8 b, E+ n0 T' P7 h- char type_name[] = "Item";0 t& E0 i, r) r. U% V
- Teamcenter::CreateInput* itemCreateInput = static_cast<Teamcenter::CreateInput*>(Teamcenter::BusinessObjectRegistry::instance().createInputObject(type_name, OPERATIONINPUT_CREATE));8 x* r* j6 l) S" E/ L- R
: u* e4 C$ h- n9 U1 t$ J- //Revision type name is not always <item type name>Revision0 e# H2 X$ o' W$ Y
- char *revision_type_name = 0;) ?& d V: X" k7 `
- CONSTANTS_get_type_constant_value("ItemRevision", type_name, &revision_type_name);
: n8 b" e% L8 S7 E! u2 ^! J2 s8 \ - * Q( W( s- {. H2 `0 a$ s
- Teamcenter::CreateInput* revCreateInput = static_cast<Teamcenter::CreateInput*>(Teamcenter::BusinessObjectRegistry::instance().createInputObject(revision_type_name, OPERATIONINPUT_CREATE));
T l# B* d* \# X6 } -
1 z- y$ C* t D3 `' P( n% c/ D! ] - MEM_free(revision_type_name);; Z* P5 M4 V3 N) E7 X! Y2 o
. ], @: s, S6 o; [; U- // set Item properties
" W$ M1 S: h% P: I0 _# O' \+ l x4 _ - itemCreateInput->setString("item_id", "1234567", false);# v9 l1 z0 T1 Q9 i1 S; ^
- itemCreateInput->setString("object_name", "My Item Name", false);0 }5 M9 K( n9 v8 i
- itemCreateInput->setString("object_desc", "My Item Description", false);6 w4 ]4 f7 |; [1 \
- itemCreateInput->setTag("revision", revCreateInput->getTag(), false);
' A3 `/ I3 \( G+ o9 t7 N6 V# T. F: s
& I) g2 }; r* K- t5 B# Y- // set Revision properties* R" {9 c' d7 @/ \6 i+ x* \
- revCreateInput->setString("item_revision_id", "00", false);
2 ]. f1 V: `, m8 ^ - revCreateInput->setString("object_name", "My Revision Name", false);8 z% |- Y2 L4 g% l
- revCreateInput->setString("object_desc", "My Revision Description", false);
" b x2 j; X6 b: b# G, ?
) R) z7 `( D* f+ S5 L5 ?9 `- Teamcenter::Item *pItem = dynamic_cast<Teamcenter::Item *>(Teamcenter::BusinessObjectRegistry::instance().createBusinessObject(itemCreateInput));+ z) P9 j1 |% N% d) C
o; y: u8 k7 @+ C8 o- ifail = AOM_save_with_extensions(pItem->getTag());
r4 o0 a. `# g7 a8 r' l - 2 u* e5 J; o, i6 s: ?
- // If the Revision is not saved it will inherit the Item's Name and Description.+ x* C, z8 z7 ~' T$ O$ |. a
- ifail = AOM_save_with_extensions(revCreateInput->getTag());
! A: G7 F% `% L2 [% G - }
复制代码 & I J* f1 A: H
' t* U+ P( o( g |
|