|
|
请使用QQ关联注册PLM之家,学习更多关于内容,更多精彩原创视频供你学习!
您需要 登录 才可以下载或查看,没有账号?注册
x
3 G e3 f$ @1 X( {
Teamcenter C++二次开发源码分享:创建item和item版本
9 D. Q: [% M' x4 L; ^. r& L
9 k; \# ]4 r" ~* P: v2 a8 j( P1 u
通过创建businessobject 指定的createinput 完成对象的创建
0 @9 q F; P) u& n4 I! v
: m8 n) w% z0 b9 d
1 U! U5 Y1 A# b- #include <constants/constants.h>
) N. Y& x* U( k4 @, n) V4 j1 c - #include <TCcore/Item.hxx>& r, J* @8 P8 p* _: r% o
- #include <metaframework/CreateInput.hxx>
. z) {1 e7 n A/ p% r9 Y - #include <metaframework/BusinessObjectRegistry.hxx>
S+ f: w2 O) m: ?0 r! H - " ^3 H% a- a4 g9 O
- using namespace std;' r/ x% Z; U% x/ W' J
3 }; `3 D! z7 X3 G4 h/ a" o# h- static void createItemAndRevisionWithDifferentNames(void)! x( c& i% {( O: Q/ B. ]
- {
& B; f3 G6 l5 g# T0 y' i. E& g - int ifail = ITK_ok;1 [) ^2 i1 i! d1 A
- + y# z3 B2 J' ~& R
- char type_name[] = "Item";
; A& G2 Z. g- p ?3 l - Teamcenter::CreateInput* itemCreateInput = static_cast<Teamcenter::CreateInput*>(Teamcenter::BusinessObjectRegistry::instance().createInputObject(type_name, OPERATIONINPUT_CREATE));
9 F( f) S+ J( L, t" l5 h
, {+ u( {2 z5 p: i0 J; v- //Revision type name is not always <item type name>Revision
1 i+ g0 y, t- R Q8 b4 A# j/ e9 d - char *revision_type_name = 0;: B5 m$ b, T5 G7 d2 n$ ?
- CONSTANTS_get_type_constant_value("ItemRevision", type_name, &revision_type_name);2 _, i, H) p/ |
- ' b0 m0 @; _( k; c3 o
- Teamcenter::CreateInput* revCreateInput = static_cast<Teamcenter::CreateInput*>(Teamcenter::BusinessObjectRegistry::instance().createInputObject(revision_type_name, OPERATIONINPUT_CREATE));
) _) Z' D5 ^0 Q$ q% l( x -
* Q! q9 ^, ?% K, f6 Y! i* o, f - MEM_free(revision_type_name);% ?/ Q' d; U9 H* z+ H2 F
+ t% b: `: B( B0 @9 t: @- // set Item properties) @2 }2 A+ V3 D3 M4 g& v+ g% Z
- itemCreateInput->setString("item_id", "1234567", false);
4 D& W3 t( |0 {2 \) J. z - itemCreateInput->setString("object_name", "My Item Name", false);7 o2 i6 Y# J$ G" V9 _
- itemCreateInput->setString("object_desc", "My Item Description", false);
9 r& w2 M6 l8 o4 R0 S% L) | W/ O - itemCreateInput->setTag("revision", revCreateInput->getTag(), false);2 U' d/ {0 z# p. X, r# P9 X
8 a: P K M7 q% b- // set Revision properties
! c7 y$ R. d G) v$ m( R - revCreateInput->setString("item_revision_id", "00", false);9 j) a8 y. ^/ L: [' ~
- revCreateInput->setString("object_name", "My Revision Name", false);9 R& z. T4 ]4 B2 d1 X
- revCreateInput->setString("object_desc", "My Revision Description", false);
2 L* x7 }, i% \ - 2 v& e, ?- f4 e, a8 y
- Teamcenter::Item *pItem = dynamic_cast<Teamcenter::Item *>(Teamcenter::BusinessObjectRegistry::instance().createBusinessObject(itemCreateInput));
9 z3 v6 z& \9 D7 ?1 t% l1 D - 1 {3 r1 M) X2 }3 z9 v# t; X' y
- ifail = AOM_save_with_extensions(pItem->getTag());
* A( u3 H, @ L0 F6 N! _
: A* M% R" a9 }! E: B/ z- // If the Revision is not saved it will inherit the Item's Name and Description.
5 x; f L6 Z' y7 ]+ ]' ~" n; }' @) L - ifail = AOM_save_with_extensions(revCreateInput->getTag());1 T) j3 W; c' x9 C9 S X
- }
复制代码 , m7 ? A- g9 }5 m+ n- V d5 l6 ^
$ ~ z+ }! c/ Q3 p6 S
|
|