|
请使用QQ关联注册PLM之家,学习更多关于内容,更多精彩原创视频供你学习!
您需要 登录 才可以下载或查看,没有账号?注册
x
( j0 {0 Q% C* P% ~9 j
Teamcenter C++二次开发源码分享:创建item和item版本
4 {! T! ?) D% l5 G4 V* z& f/ v2 h3 k9 Y
( @: r) _5 K4 X! `5 i) _5 h
通过创建businessobject 指定的createinput 完成对象的创建
" H v8 }, q2 Q5 |* V- K9 d5 ^. a
& ]2 A6 m; Z- r( V# l- h7 `. A" R& c! g F/ m8 a7 @
- #include <constants/constants.h>8 O) m- ^* u$ @+ x
- #include <TCcore/Item.hxx>
4 N7 d$ k5 w5 x' j. z - #include <metaframework/CreateInput.hxx>
- }5 F. c* n# B! ] - #include <metaframework/BusinessObjectRegistry.hxx>
% f, f0 D( X$ U! Z1 V - $ ]* V6 W, ^. d3 P2 W" { T% Q0 }
- using namespace std;, u" @% F3 i, R, i' W" U
) D# z; k ~- W% m! S- static void createItemAndRevisionWithDifferentNames(void)
0 O2 I# D o: w& W d( x - {
( o3 T3 X D) ^: f; h - int ifail = ITK_ok;: J7 P- F j* r& u/ C" @
- 6 r/ T" W! z0 n n0 Z7 J
- char type_name[] = "Item";. d3 ~% |/ N* Y, J5 e5 @6 h
- Teamcenter::CreateInput* itemCreateInput = static_cast<Teamcenter::CreateInput*>(Teamcenter::BusinessObjectRegistry::instance().createInputObject(type_name, OPERATIONINPUT_CREATE));1 O1 c& K3 G& w
- ! b8 L! p2 {2 x8 L
- //Revision type name is not always <item type name>Revision
* k0 c- ~$ G6 M5 y - char *revision_type_name = 0;. L+ A* K6 G/ O; n+ K
- CONSTANTS_get_type_constant_value("ItemRevision", type_name, &revision_type_name);
. _( d9 ]" g, {5 V# W, }. f
3 E" c# s# @ C% E: {. g- Teamcenter::CreateInput* revCreateInput = static_cast<Teamcenter::CreateInput*>(Teamcenter::BusinessObjectRegistry::instance().createInputObject(revision_type_name, OPERATIONINPUT_CREATE));6 l! i9 `1 t* H# K1 X) {' @) U( }
- & ]- w& k, a. I3 I. E
- MEM_free(revision_type_name);. u3 o8 W3 W) L+ P- w" {( O3 ~
- 2 N" \ F& D. I+ @- U6 n) d W
- // set Item properties
) s9 m# V, }1 ~+ c0 a - itemCreateInput->setString("item_id", "1234567", false);( |+ _. ^$ B% p9 \
- itemCreateInput->setString("object_name", "My Item Name", false);
5 C8 b3 z) q j! c- N - itemCreateInput->setString("object_desc", "My Item Description", false);3 {7 k* ^# l) P1 N. I- c0 J
- itemCreateInput->setTag("revision", revCreateInput->getTag(), false);
& Q0 R) t/ w$ N _
6 a1 y# g7 @3 `- // set Revision properties& g+ o$ L# A2 v' a |8 L
- revCreateInput->setString("item_revision_id", "00", false);* w. n/ q% }" [
- revCreateInput->setString("object_name", "My Revision Name", false);. W, C9 [2 L* ]3 L
- revCreateInput->setString("object_desc", "My Revision Description", false);/ S4 N% X7 \* C) Q2 Z8 x9 z( D" E
- 6 d# p g8 n. s; }5 S
- Teamcenter::Item *pItem = dynamic_cast<Teamcenter::Item *>(Teamcenter::BusinessObjectRegistry::instance().createBusinessObject(itemCreateInput));7 f. Y1 o7 o1 f, v9 A) X9 a
2 r( b! t8 M9 s( n( u- ifail = AOM_save_with_extensions(pItem->getTag());9 v8 e/ |9 M4 ~ a
- 1 R/ C4 A' F7 `. K0 a+ Y' z, n
- // If the Revision is not saved it will inherit the Item's Name and Description.
4 z2 ~6 q3 H1 L0 j# i% B& l" G - ifail = AOM_save_with_extensions(revCreateInput->getTag());5 {; }+ T# m+ ]& U7 k* Y& s1 C
- }
复制代码 - ^3 g8 Z# z G& Q
6 S3 M% _ j) z/ i# t: Z& h |
|