|
请使用QQ关联注册PLM之家,学习更多关于内容,更多精彩原创视频供你学习!
您需要 登录 才可以下载或查看,没有账号?注册
x
2 x* q' L# L HTeamcenter C++二次开发源码分享:创建item和item版本' U- ?9 f0 Y w+ Q" k1 ~2 F
, q- b& l/ A. G1 E
: T& e9 q9 b7 }: X通过创建businessobject 指定的createinput 完成对象的创建
; x A0 k$ n9 t3 R! n3 J& Q
" n; d- i' P f3 w E1 C9 N2 u0 L/ C" T7 r% v" p, p/ H
- #include <constants/constants.h>
' b q& Q1 h( Z" R; d - #include <TCcore/Item.hxx>
0 [) j5 K1 I+ G6 b& ]# E; w - #include <metaframework/CreateInput.hxx>
$ a* n4 p: w: o# q9 q* B - #include <metaframework/BusinessObjectRegistry.hxx>9 [ z- D6 d! {4 b& ~
1 Z% A* D# z$ Y. [- using namespace std;# F) U5 E' a- v, e4 P5 f# v" F
- 1 N( p8 B1 s: d, s
- static void createItemAndRevisionWithDifferentNames(void)
1 x. S+ G" G, S - {
0 k" g# q" R- Q, g8 M9 S2 \ - int ifail = ITK_ok;
6 ]; C9 N# i0 u: t# i6 Q
5 j/ N3 \3 G, L6 K- char type_name[] = "Item";' m# |# F' x- ~5 N. }
- Teamcenter::CreateInput* itemCreateInput = static_cast<Teamcenter::CreateInput*>(Teamcenter::BusinessObjectRegistry::instance().createInputObject(type_name, OPERATIONINPUT_CREATE)); x! J. C" P# ?3 D4 a1 i3 u, v& s: @
+ N* ~& E% d" c+ w c6 [- //Revision type name is not always <item type name>Revision
7 ^" W' ?' k5 Q$ {5 k - char *revision_type_name = 0;6 j- `2 q2 h( L( F, ?( W) g) x
- CONSTANTS_get_type_constant_value("ItemRevision", type_name, &revision_type_name);
3 M6 C' G4 w3 W" ?: f
# Z+ _8 U$ I( ` J+ L% V- Q- Teamcenter::CreateInput* revCreateInput = static_cast<Teamcenter::CreateInput*>(Teamcenter::BusinessObjectRegistry::instance().createInputObject(revision_type_name, OPERATIONINPUT_CREATE));& u0 E6 Z9 T6 l: k: X; z+ {$ B- {
-
4 H- n5 U- \& [0 l, j - MEM_free(revision_type_name);
+ C I1 @) C/ m U$ k
) l0 ?) ?- k" v o n- // set Item properties
+ H; L4 {8 i' n& G* O - itemCreateInput->setString("item_id", "1234567", false);3 t) \5 R& {& l `6 S
- itemCreateInput->setString("object_name", "My Item Name", false);9 {1 y7 C% n% p$ Z
- itemCreateInput->setString("object_desc", "My Item Description", false);
2 r V$ Z& e3 ~9 Y - itemCreateInput->setTag("revision", revCreateInput->getTag(), false);
% ^4 K, X0 D! _ - 8 O m, h- w! V1 L B% d
- // set Revision properties
2 P: q( j1 w0 e* z+ ~* N - revCreateInput->setString("item_revision_id", "00", false);* R/ Y1 a, A% l/ b
- revCreateInput->setString("object_name", "My Revision Name", false);
* ?1 M+ Q0 t8 L8 t - revCreateInput->setString("object_desc", "My Revision Description", false);8 p0 x$ S- L# `- S! l$ T
3 H$ J( |0 l$ f4 N5 Q( |8 J- Teamcenter::Item *pItem = dynamic_cast<Teamcenter::Item *>(Teamcenter::BusinessObjectRegistry::instance().createBusinessObject(itemCreateInput));; z1 `5 {/ F! {
- ' [% J% N( p: R) y5 N- z& e3 B
- ifail = AOM_save_with_extensions(pItem->getTag());6 W" h0 W+ F: o# f
- ; o+ ?) A) f; d
- // If the Revision is not saved it will inherit the Item's Name and Description.
% b2 a F! Q- G5 K4 z - ifail = AOM_save_with_extensions(revCreateInput->getTag());4 u) I& j8 K- O& P; o! d' y. y$ o
- }
复制代码
) Y8 R7 |# \) [# y2 ], _2 \0 @: f& J0 N
|
|