|
请使用QQ关联注册PLM之家,学习更多关于内容,更多精彩原创视频供你学习!
您需要 登录 才可以下载或查看,没有账号?注册
x
7 U5 i# M( G7 v3 C. P" W
Teamcenter C++二次开发源码分享:创建item和item版本
5 V& Y7 k. u4 G3 @
* G& @8 ^( E7 q4 U; E* h4 ^/ _/ c4 M; \: V, |. [
通过创建businessobject 指定的createinput 完成对象的创建6 L3 W9 X+ Y7 a) T% W
7 u/ n% W+ A# s. O
{) d6 f: c" y
- #include <constants/constants.h>
7 M0 y4 n0 ?' G" V - #include <TCcore/Item.hxx>
* H/ V: O. `- K/ Q - #include <metaframework/CreateInput.hxx>
* A8 m% s* m2 K( N: l - #include <metaframework/BusinessObjectRegistry.hxx>. F, s! u% |- l# ?
- * I/ ?7 i/ S$ N( C* f6 S5 C
- using namespace std;
, M" `- r/ |/ |1 e - $ _4 L0 [- [* @! }& U
- static void createItemAndRevisionWithDifferentNames(void)- C, Q, h$ E/ V& D
- {2 u4 `* _5 U: d
- int ifail = ITK_ok;
# K* [8 i& h8 }; x% M - 8 m5 }6 r! Z" }# t. T* Y
- char type_name[] = "Item";
+ O: _- m! c/ }7 b8 ~8 |/ c" q! g - Teamcenter::CreateInput* itemCreateInput = static_cast<Teamcenter::CreateInput*>(Teamcenter::BusinessObjectRegistry::instance().createInputObject(type_name, OPERATIONINPUT_CREATE));: L5 G! h; M0 H
- 0 n% R) N2 w/ S2 z# c4 }" Q% T
- //Revision type name is not always <item type name>Revision
: T3 O( g# X. R# L- o( |% x - char *revision_type_name = 0;
7 p+ _' c4 L8 Z3 { - CONSTANTS_get_type_constant_value("ItemRevision", type_name, &revision_type_name);
5 Y" ]- j( t) { X - ' g8 c+ }* N5 j9 M) P1 ]$ a1 v
- Teamcenter::CreateInput* revCreateInput = static_cast<Teamcenter::CreateInput*>(Teamcenter::BusinessObjectRegistry::instance().createInputObject(revision_type_name, OPERATIONINPUT_CREATE));* v6 r; f$ w) b" O4 K8 N* h: ?; m1 H
-
! s' y, ?9 [/ ~$ P - MEM_free(revision_type_name);0 ]2 v! Y$ F6 F2 s
- 0 T3 D, W" [: Q; s4 j
- // set Item properties
S" `. [, N+ u- G. q8 } \! } - itemCreateInput->setString("item_id", "1234567", false);
, v& t( w! S/ _4 j0 ]! F$ }$ j - itemCreateInput->setString("object_name", "My Item Name", false);2 o, ^, {9 W% K6 Z& m3 R3 q6 V
- itemCreateInput->setString("object_desc", "My Item Description", false);
9 C) M3 t5 ?7 y5 A2 ^6 S - itemCreateInput->setTag("revision", revCreateInput->getTag(), false);- X/ V" M2 W5 h5 R3 m7 D
, i; t" D! U2 Q$ B3 T* P- w- // set Revision properties0 `5 G* P# a2 t& H8 W3 Y/ O+ g
- revCreateInput->setString("item_revision_id", "00", false);
/ c! }& \" R) n- j3 n3 j$ n7 H - revCreateInput->setString("object_name", "My Revision Name", false);% d! I% B, ^2 j5 r
- revCreateInput->setString("object_desc", "My Revision Description", false);
1 R+ g" a8 C( F5 x* ?0 u3 ~
5 b2 z& v9 r: A+ T& E# T- Teamcenter::Item *pItem = dynamic_cast<Teamcenter::Item *>(Teamcenter::BusinessObjectRegistry::instance().createBusinessObject(itemCreateInput));" b' `1 J, }+ ~: |* q. N3 c
- ; m: x' D% k% A
- ifail = AOM_save_with_extensions(pItem->getTag());: f: M. O5 l7 H% N9 y V
* B( w: W- D$ l- // If the Revision is not saved it will inherit the Item's Name and Description.
: ?7 R# o$ l) ]. U; K - ifail = AOM_save_with_extensions(revCreateInput->getTag());
0 [+ y, [: {! ?& m - }
复制代码
" |- M1 @2 \8 [% G: J# d: Y( h
, B' p k3 ^/ i4 ~. E' o |
|