|
|
请使用QQ关联注册PLM之家,学习更多关于内容,更多精彩原创视频供你学习!
您需要 登录 才可以下载或查看,没有账号?注册
x
! t4 p( H! Y, D% t- Y* jTeamcenter C++二次开发源码分享:创建item和item版本
- Q" i0 B% x f# Q! [( } W& c) P5 i
/ ]7 v6 I& R/ q; r% Q8 n2 K8 c2 ~$ S) I
通过创建businessobject 指定的createinput 完成对象的创建. E; o* n/ ]3 T2 U
9 \+ H$ }) i, g- K2 F8 {( U% }; K1 k/ A5 }8 }4 Y7 r
- #include <constants/constants.h>
O1 A0 L* v% L' M) l - #include <TCcore/Item.hxx>
$ y& v) o$ G& e" U+ d' B ~. v! S. A - #include <metaframework/CreateInput.hxx>
3 q/ Q v3 B2 U2 d4 L1 S6 U - #include <metaframework/BusinessObjectRegistry.hxx>9 l4 x) ]9 a5 t$ I
- 3 F7 E# j3 m" T3 S0 @; U, y/ [
- using namespace std;' r( J/ r5 E Q) r, ^ [
( t# H4 |, B! F- static void createItemAndRevisionWithDifferentNames(void)% B( G3 M6 Y4 y9 R; l
- {
3 [1 J$ ]1 X* f+ A$ {! A( s - int ifail = ITK_ok;& J$ Q z+ Q& g, X
: h5 r" U h" ?/ H- char type_name[] = "Item";
0 s" O7 k/ |: h3 a. s( N, O - Teamcenter::CreateInput* itemCreateInput = static_cast<Teamcenter::CreateInput*>(Teamcenter::BusinessObjectRegistry::instance().createInputObject(type_name, OPERATIONINPUT_CREATE));- a; T* J; H7 p7 [4 y2 p* ]
- 4 p$ V* l- f+ M+ v& g: _
- //Revision type name is not always <item type name>Revision
* W! B: J. v1 d8 B4 I6 M- x - char *revision_type_name = 0;; L' y) y7 H1 z: T9 X: Y
- CONSTANTS_get_type_constant_value("ItemRevision", type_name, &revision_type_name);0 _+ G. L) T8 [1 y9 r$ p
- ! L! ] @% O* p( X K0 \
- Teamcenter::CreateInput* revCreateInput = static_cast<Teamcenter::CreateInput*>(Teamcenter::BusinessObjectRegistry::instance().createInputObject(revision_type_name, OPERATIONINPUT_CREATE));
" y5 |8 H. ^3 G9 n6 L+ C) e - , K! k5 j# k( |$ }; j T/ z1 ~
- MEM_free(revision_type_name);
& I0 b0 R/ d1 u1 D6 Q - 6 s9 T# E; {9 x! U
- // set Item properties
( O: A, G# A8 P2 C/ o - itemCreateInput->setString("item_id", "1234567", false);
9 p3 o# c) ~; ] - itemCreateInput->setString("object_name", "My Item Name", false);- T0 u; s% S2 y: | i7 S! K: O q
- itemCreateInput->setString("object_desc", "My Item Description", false);
9 N+ N: }8 Z2 ?$ m% v; A - itemCreateInput->setTag("revision", revCreateInput->getTag(), false);- o! Y y- l& c, m2 O/ C5 a
- - g8 C7 k4 t! n" j& \. w$ x
- // set Revision properties* v8 p) S4 g* F6 Q* L7 t2 T
- revCreateInput->setString("item_revision_id", "00", false);) W4 a# y! s' b* ?6 i9 t
- revCreateInput->setString("object_name", "My Revision Name", false);% s& O! Y j" p- q% I5 t+ p' ^/ @
- revCreateInput->setString("object_desc", "My Revision Description", false);' m- Y# M; B- y2 V
- + E7 w* f9 F, v5 P" f0 B: `
- Teamcenter::Item *pItem = dynamic_cast<Teamcenter::Item *>(Teamcenter::BusinessObjectRegistry::instance().createBusinessObject(itemCreateInput));
% l# W; _! ]0 b" M4 |8 U
- s, l0 C$ V4 ?- ifail = AOM_save_with_extensions(pItem->getTag()); C( W& o+ y% |$ r- N; c. A1 P) f
- . |# z+ M3 `& \2 i& @
- // If the Revision is not saved it will inherit the Item's Name and Description.+ H( V1 h7 _. G) C/ y A
- ifail = AOM_save_with_extensions(revCreateInput->getTag());; X& S/ ~3 M" V/ Z3 G8 R( v7 }
- }
复制代码
/ \- R; Z$ R9 e: K3 S, p2 Y4 s* t F& f* w; W3 Y" k
|
|