|
请使用QQ关联注册PLM之家,学习更多关于内容,更多精彩原创视频供你学习!
您需要 登录 才可以下载或查看,没有账号?注册
x
& Y: e5 H) a* N6 k4 k
Teamcenter C++二次开发源码分享:创建item和item版本( b; j5 @2 O$ T, p
- f$ u7 U, h9 H' L! K2 Q
: {1 T5 M/ y# l2 G: j通过创建businessobject 指定的createinput 完成对象的创建
3 I9 {" K' r/ W, z6 p, `; ^- ?- f2 \
: ]# L0 d# h0 ]( J$ p7 l$ K0 w- #include <constants/constants.h>3 [6 f4 B4 p: D. y) o% e+ ]% y' j
- #include <TCcore/Item.hxx>
0 [9 e& w+ \9 }5 {* p6 A1 o - #include <metaframework/CreateInput.hxx>0 G1 U, i. R! K. u" C; z1 j
- #include <metaframework/BusinessObjectRegistry.hxx>& F& x4 s) g( m/ [; X- E
- 3 B* A5 e' @! \9 {
- using namespace std;
( I$ l2 e l) B& N
; ?# h4 m# |# [- static void createItemAndRevisionWithDifferentNames(void)& n1 V, f) b+ I {: e6 b
- {& s# Q2 u5 p8 t; I4 {7 `7 O
- int ifail = ITK_ok;
5 A9 a( f. m$ L; v$ r - 6 \* F) j' m. B" Y8 w: z5 |! h5 @' _
- char type_name[] = "Item";
6 Y7 Z/ p! t0 j: D4 o - Teamcenter::CreateInput* itemCreateInput = static_cast<Teamcenter::CreateInput*>(Teamcenter::BusinessObjectRegistry::instance().createInputObject(type_name, OPERATIONINPUT_CREATE));
# ~/ V& A1 |+ s" c0 C* X1 D
. q5 ~7 {: z' ^4 I8 P" z- //Revision type name is not always <item type name>Revision7 q& ]& X4 ?8 ]7 _* H9 ]
- char *revision_type_name = 0;
3 K4 q' Q# c8 W9 b, r3 u' Y# K - CONSTANTS_get_type_constant_value("ItemRevision", type_name, &revision_type_name);
1 v/ Q) ]1 i& u8 J) L# W% Y( Z - : M! y. H' K5 J' F! B0 Z
- Teamcenter::CreateInput* revCreateInput = static_cast<Teamcenter::CreateInput*>(Teamcenter::BusinessObjectRegistry::instance().createInputObject(revision_type_name, OPERATIONINPUT_CREATE));% x5 X( L) h6 [: ^3 J9 ^, }
-
3 l4 ^9 n& U7 Y' H- Z: X - MEM_free(revision_type_name);
" V* a0 E6 Q+ P' Y8 u
- F( M$ d3 p6 U* S+ O- // set Item properties) u' H$ l( A! i* W( R e1 C5 x
- itemCreateInput->setString("item_id", "1234567", false);
- o5 u; v: X ~. W5 X3 t' @" M - itemCreateInput->setString("object_name", "My Item Name", false);
" O9 P" L% C- S `; a - itemCreateInput->setString("object_desc", "My Item Description", false);" Q( C' Y% y: k+ c6 u2 R7 q7 b8 |
- itemCreateInput->setTag("revision", revCreateInput->getTag(), false);
8 N9 M+ g4 ]2 i1 z R' f. R
/ r% d1 w T y# o- // set Revision properties
p* n! j& } l5 ?" j - revCreateInput->setString("item_revision_id", "00", false);0 _7 D' N, g; h$ Q9 j1 _
- revCreateInput->setString("object_name", "My Revision Name", false);
5 S2 r5 E* i1 \) h* |6 } - revCreateInput->setString("object_desc", "My Revision Description", false);% f3 u9 X* C) R1 ]2 e
- 2 R( p% J5 A# o t& h U8 G; l5 j
- Teamcenter::Item *pItem = dynamic_cast<Teamcenter::Item *>(Teamcenter::BusinessObjectRegistry::instance().createBusinessObject(itemCreateInput));
2 O$ O+ j& S* `9 h( h6 g" @* K - * u5 I. Y* j4 u1 @) _2 [
- ifail = AOM_save_with_extensions(pItem->getTag());# Y/ L; v4 Z0 B" Q' c
- , o% N( L l8 j. [; N7 K, P
- // If the Revision is not saved it will inherit the Item's Name and Description.
! J- h, q& L6 g0 D8 K: y - ifail = AOM_save_with_extensions(revCreateInput->getTag());6 D: m* r5 \, v7 }, P3 O' Z9 P
- }
复制代码 & w, A! s0 o8 f3 S. C
% _# p ]) Q8 v% i* f: A4 z |
|