|
|
请使用QQ关联注册PLM之家,学习更多关于内容,更多精彩原创视频供你学习!
您需要 登录 才可以下载或查看,没有账号?注册
x
& I$ Q4 V$ h& c F6 V6 n5 H7 W9 G3 W
Teamcenter C++二次开发源码分享:创建item和item版本
( J" p$ r9 ^- p' U& ?
1 B! i6 G! n" a3 E- x; A. O/ ]3 E
( x( K% b' {. u通过创建businessobject 指定的createinput 完成对象的创建
n. {6 A7 R0 c; g1 k$ u; }9 O; v& w% T5 l" z
% \8 ^6 z" }: A, B2 g5 S2 O% z
- #include <constants/constants.h>" p J4 W3 L! e" y1 H+ u8 q# A }
- #include <TCcore/Item.hxx>
: V' ~* I, n: C8 E- @4 t8 Q' ^ - #include <metaframework/CreateInput.hxx>3 Q3 l7 D7 x2 R+ a1 v! J+ H
- #include <metaframework/BusinessObjectRegistry.hxx>
1 `2 i" v5 i ^
( ] j) c1 u1 ?% \1 Y1 ^- using namespace std;9 Z D+ R1 r+ N$ T% f$ R
& f$ {/ M$ V* W" A- static void createItemAndRevisionWithDifferentNames(void)' j/ M; Z* @! m( H3 t. v
- {0 y: E+ ?( G6 Y! {3 u) _
- int ifail = ITK_ok;7 [0 [5 o7 I& h) c" f, R" t% i0 s
- E' h. @! U, ] E8 ?
- char type_name[] = "Item";
, z) g+ S9 z, R - Teamcenter::CreateInput* itemCreateInput = static_cast<Teamcenter::CreateInput*>(Teamcenter::BusinessObjectRegistry::instance().createInputObject(type_name, OPERATIONINPUT_CREATE));
" U5 H5 p5 j+ e z. r' U; [ - 2 r( }) u1 i2 ?" ~
- //Revision type name is not always <item type name>Revision* N6 I8 j. n: {3 [/ y6 `2 L
- char *revision_type_name = 0;
* v: ]" Y; Z7 L/ b9 } - CONSTANTS_get_type_constant_value("ItemRevision", type_name, &revision_type_name); q* H0 m8 X2 i8 j8 I5 i
) @% Z8 U3 r R0 h& B- Teamcenter::CreateInput* revCreateInput = static_cast<Teamcenter::CreateInput*>(Teamcenter::BusinessObjectRegistry::instance().createInputObject(revision_type_name, OPERATIONINPUT_CREATE));
# _# b. d+ D& c% t$ A - / M: }5 J% u' [, Y
- MEM_free(revision_type_name);/ r/ m: K! O D
$ n# F2 V% x3 h* K- // set Item properties
4 i2 M2 F. h+ o: y - itemCreateInput->setString("item_id", "1234567", false);
1 T' f! |6 R5 c+ A# [ - itemCreateInput->setString("object_name", "My Item Name", false);
* c3 W( e. }* {8 `/ z, P F4 C9 F* } - itemCreateInput->setString("object_desc", "My Item Description", false);
: K- M5 M1 X$ x% ^7 b/ H) P. q - itemCreateInput->setTag("revision", revCreateInput->getTag(), false);, j4 q. t' d& k8 K
- 3 F( Y0 Z3 t( n, B
- // set Revision properties
2 x3 C0 f( B& o- N$ E, P2 r7 X- D - revCreateInput->setString("item_revision_id", "00", false);
& J- k( c3 ]9 ]5 ? @) H) s - revCreateInput->setString("object_name", "My Revision Name", false);1 g# a( I' ?% m
- revCreateInput->setString("object_desc", "My Revision Description", false);
* d# W' y! k5 t9 K
* H/ L6 e$ |% Z, L! d& M8 `- Teamcenter::Item *pItem = dynamic_cast<Teamcenter::Item *>(Teamcenter::BusinessObjectRegistry::instance().createBusinessObject(itemCreateInput));
7 j" O" [ C4 w2 A
' e4 T5 y, j! @3 k- ifail = AOM_save_with_extensions(pItem->getTag());
- `7 |- I4 e1 u - : N* F* t* g4 j
- // If the Revision is not saved it will inherit the Item's Name and Description.
+ u& o* }+ ]6 {1 I3 B+ J! i' `7 ] - ifail = AOM_save_with_extensions(revCreateInput->getTag());
) P. l- [, k3 Q, [ - }
复制代码
- C6 ^$ y. _3 i8 A: m
; h( V0 ~/ o# e3 Z4 }, ` E |
|