|
请使用QQ关联注册PLM之家,学习更多关于内容,更多精彩原创视频供你学习!
您需要 登录 才可以下载或查看,没有账号?注册
x
' C* f+ k' H. \& y6 \
Teamcenter C++二次开发源码分享:创建item和item版本. `* i, N0 @3 f4 A
! y$ P7 ^/ o, V8 H! S7 D# v' t7 g# p2 N
通过创建businessobject 指定的createinput 完成对象的创建9 ?4 l! \# p& B/ u9 D; k
' z+ u& W8 C0 C3 i% L) x- d" b# ^/ d* k4 k+ S& ]; W7 J/ P
- #include <constants/constants.h>4 E- U4 |0 Y: f; t/ }6 N W
- #include <TCcore/Item.hxx>
( l+ G+ V, s. b - #include <metaframework/CreateInput.hxx>
4 q0 ?; d$ E* V5 c - #include <metaframework/BusinessObjectRegistry.hxx>. T$ B3 ]1 r, F, x
1 T+ h# C& J+ Z G& O- using namespace std;
& c: r3 k$ i2 [+ @7 b) N
: i2 Z/ T _1 ]8 k7 G5 K$ a6 C2 w. b- static void createItemAndRevisionWithDifferentNames(void)0 B, u8 d5 A2 m6 o
- {' h& j' H9 |" d8 }! e, m5 }' P
- int ifail = ITK_ok;
' ?, l4 z* k/ | - 7 e+ p4 {1 ~0 J! ~
- char type_name[] = "Item";% R4 L% I# V, f6 a
- Teamcenter::CreateInput* itemCreateInput = static_cast<Teamcenter::CreateInput*>(Teamcenter::BusinessObjectRegistry::instance().createInputObject(type_name, OPERATIONINPUT_CREATE));
8 B2 G+ i- C5 U u- j v7 s5 B) d( K K
& ]1 t+ W! G9 j- //Revision type name is not always <item type name>Revision! X E0 v% ?, J1 ^3 k# K" M
- char *revision_type_name = 0;
0 _$ [; {: \7 h6 h - CONSTANTS_get_type_constant_value("ItemRevision", type_name, &revision_type_name);6 m6 w- ^% t j2 c/ F
- 8 ]* Y, A8 _# n! |$ b) N
- Teamcenter::CreateInput* revCreateInput = static_cast<Teamcenter::CreateInput*>(Teamcenter::BusinessObjectRegistry::instance().createInputObject(revision_type_name, OPERATIONINPUT_CREATE));, _4 C, ~' d) N* T/ X
-
4 D, W+ s7 f+ O4 J6 U8 q, J - MEM_free(revision_type_name);
1 s+ D! _/ X; w
$ i: g9 d0 i/ d$ x6 G' |2 `- // set Item properties+ f* W0 i6 S/ I$ } c, i
- itemCreateInput->setString("item_id", "1234567", false);, O) u' i" \) ]
- itemCreateInput->setString("object_name", "My Item Name", false);/ m( A* L2 c% ~; w
- itemCreateInput->setString("object_desc", "My Item Description", false);, _" z' Z9 Q4 Y1 J0 r% c; o4 U# v
- itemCreateInput->setTag("revision", revCreateInput->getTag(), false);
4 o* ?# R5 t# `/ h& N. @' S - $ K2 }* R$ y2 [. G& b
- // set Revision properties
5 l- s$ D g- V* W3 t9 a - revCreateInput->setString("item_revision_id", "00", false);! W2 W* \" F6 y0 W9 m# e; A
- revCreateInput->setString("object_name", "My Revision Name", false);+ ]* N( y7 _0 O# x
- revCreateInput->setString("object_desc", "My Revision Description", false);0 c: v3 M- m4 p) G# c5 j u' ~7 P) m# N
h! [; u) R% a+ P- Teamcenter::Item *pItem = dynamic_cast<Teamcenter::Item *>(Teamcenter::BusinessObjectRegistry::instance().createBusinessObject(itemCreateInput));
+ z- r9 D8 d* G7 ~5 b - : u9 M4 g& |" [( q
- ifail = AOM_save_with_extensions(pItem->getTag());7 W& [# G& n6 M0 c& C
9 Y' D0 E% }7 X2 W6 S& ^' r, q, W- // If the Revision is not saved it will inherit the Item's Name and Description./ p. X; E% e& X, X
- ifail = AOM_save_with_extensions(revCreateInput->getTag());& a, Z$ d D4 a8 u0 f7 p
- }
复制代码 ' J* T! w$ i+ d! l+ H+ b+ u# E
% d% ?' ]! h" Y8 `+ Y, q) F
|
|