|
|
请使用QQ关联注册PLM之家,学习更多关于内容,更多精彩原创视频供你学习!
您需要 登录 才可以下载或查看,没有账号?注册
x
1 R8 g( M$ a! eTeamcenter C++二次开发源码分享:创建item和item版本
0 [! |& z/ n; |! X. Z6 l% w" c5 U3 A5 {. O3 K
9 h8 H0 A: c, F$ v" h
通过创建businessobject 指定的createinput 完成对象的创建7 M* M+ @: e! W4 I6 U" d, L& F
u, W- R7 I1 V N
. v* A7 d- [) U. i2 |- #include <constants/constants.h># N; D% X& B' N( u. h* y
- #include <TCcore/Item.hxx>
( S5 R6 i! G% C' W5 k- e L - #include <metaframework/CreateInput.hxx>
! P B( \* D$ Y r2 v7 ~ - #include <metaframework/BusinessObjectRegistry.hxx>& b$ ~+ g) s" w
- G8 s6 N ^% Z6 A# v4 Z
- using namespace std;
% R- [& L8 T- ~* B' Q - ; o) h+ e1 A6 _' Y: R% c1 r Q
- static void createItemAndRevisionWithDifferentNames(void)5 {# e: a5 L; p- j9 n
- {' l9 S; k8 J7 z
- int ifail = ITK_ok;" ~- E" r+ W* ]5 }
- 7 \7 T4 ^# a$ M
- char type_name[] = "Item";
) G1 }1 C' J' J0 L7 N - Teamcenter::CreateInput* itemCreateInput = static_cast<Teamcenter::CreateInput*>(Teamcenter::BusinessObjectRegistry::instance().createInputObject(type_name, OPERATIONINPUT_CREATE));+ a. s/ k5 S- W2 t
- + F6 u R% ?5 h- _. H, [0 o* r
- //Revision type name is not always <item type name>Revision
5 P2 H+ s+ k6 b3 _' i! Y0 k4 S - char *revision_type_name = 0;. r; e$ m" H6 `1 J* T
- CONSTANTS_get_type_constant_value("ItemRevision", type_name, &revision_type_name);
% E% z) v' i- e
1 L/ f6 ?1 f$ K- Teamcenter::CreateInput* revCreateInput = static_cast<Teamcenter::CreateInput*>(Teamcenter::BusinessObjectRegistry::instance().createInputObject(revision_type_name, OPERATIONINPUT_CREATE));
" c( [# X$ q1 d+ D: {7 p' Z -
* l$ D1 X, J$ ]4 W* D - MEM_free(revision_type_name);6 }" R0 H( a7 U* R
- * [* j6 r) Q" l
- // set Item properties
9 v7 N+ ^* z3 O0 g - itemCreateInput->setString("item_id", "1234567", false);
4 U' Z8 Q N( K% y! D n) T) ? - itemCreateInput->setString("object_name", "My Item Name", false);1 X% D7 X P" K2 L7 b/ X# j+ ?
- itemCreateInput->setString("object_desc", "My Item Description", false);" @( b- U4 `: [$ C- R3 @
- itemCreateInput->setTag("revision", revCreateInput->getTag(), false);( x' c6 Q, a, J* M
- B) }! {8 K7 [' {* n
- // set Revision properties
6 N I& w) }8 l - revCreateInput->setString("item_revision_id", "00", false);
8 c. v M' H( E0 x! s - revCreateInput->setString("object_name", "My Revision Name", false);
9 v K+ w9 ?8 p - revCreateInput->setString("object_desc", "My Revision Description", false);
$ C; X+ h! f- e; x
9 y7 i4 P8 Z6 Q5 p' G ]7 R- Teamcenter::Item *pItem = dynamic_cast<Teamcenter::Item *>(Teamcenter::BusinessObjectRegistry::instance().createBusinessObject(itemCreateInput));
1 h2 t0 g2 I4 `, ~+ P$ p7 c - 1 M7 A) H8 k+ t( ]4 X+ T
- ifail = AOM_save_with_extensions(pItem->getTag());
5 [ ]6 l) ]3 x" Y8 _ - 5 Z0 U. m( G$ B) A% d* u/ m
- // If the Revision is not saved it will inherit the Item's Name and Description.
4 ~3 P" Z! E/ e) H' r$ }% H - ifail = AOM_save_with_extensions(revCreateInput->getTag());
! ~0 O, |& J! |3 M - }
复制代码 . P8 A8 }, Y5 k. N V' S
1 k6 L* }& e. L* ]+ m* C# B$ C6 Y9 N |
|