|
|
请使用QQ关联注册PLM之家,学习更多关于内容,更多精彩原创视频供你学习!
您需要 登录 才可以下载或查看,没有账号?注册
x
! s( ]1 l, J# `& VTeamcenter C++二次开发源码分享:创建item和item版本/ C) J: M3 M* f+ T' B/ \! d% I
$ E3 Q$ L3 I7 X1 s
6 q ^% y3 X2 k6 V, U8 Q0 e通过创建businessobject 指定的createinput 完成对象的创建: P2 }) u5 {/ [5 K+ w3 b' K
( U9 d5 N5 _- ?! j5 L6 M6 Y! \- s
6 {! _: a4 C$ x7 J8 r- #include <constants/constants.h>* ^/ h4 }* v V' a0 g) y
- #include <TCcore/Item.hxx>
. ^" ^, S t3 ^. s2 U - #include <metaframework/CreateInput.hxx>
0 d0 U" [( ]1 U( b/ F j, R - #include <metaframework/BusinessObjectRegistry.hxx>9 Q' N) Z! h F& L& |# \, O. ?
* H6 D' j+ L; j7 h$ N4 Y, R- using namespace std;
7 x$ }! M/ a* V$ M( }
" m) p0 K& O+ X4 B( R1 ?- static void createItemAndRevisionWithDifferentNames(void)6 H; j. t1 O$ Y* \5 U
- {
4 f! B5 ?1 \3 `' [- m - int ifail = ITK_ok;- ]1 j+ f8 i$ A Q
- & H' R3 U+ q1 y
- char type_name[] = "Item";
: S7 L& } f R - Teamcenter::CreateInput* itemCreateInput = static_cast<Teamcenter::CreateInput*>(Teamcenter::BusinessObjectRegistry::instance().createInputObject(type_name, OPERATIONINPUT_CREATE));& [+ n" l$ o, h7 k" O8 ]( k
/ \$ {8 ^1 ^4 Y4 d- l {0 T- //Revision type name is not always <item type name>Revision3 M) P ~! p4 j( b+ v* p
- char *revision_type_name = 0;
8 m" O% J& W( \' c5 \& n - CONSTANTS_get_type_constant_value("ItemRevision", type_name, &revision_type_name);
( `1 d; ]2 a3 y( L) ^' C/ }$ L - # j6 [9 k' \2 w) T# {$ D V" I9 Q
- Teamcenter::CreateInput* revCreateInput = static_cast<Teamcenter::CreateInput*>(Teamcenter::BusinessObjectRegistry::instance().createInputObject(revision_type_name, OPERATIONINPUT_CREATE));$ m! z0 s8 p g, w' w
- 5 W: ?5 P( I9 r' O# \; H- Y, L
- MEM_free(revision_type_name);- w6 ?' [8 g7 W1 e6 f
. m2 g8 i @5 Z2 M! v& x. ^- // set Item properties
; c+ n* t _# \6 ~ - itemCreateInput->setString("item_id", "1234567", false);
( V2 c2 M t$ f8 A/ q ^8 m - itemCreateInput->setString("object_name", "My Item Name", false);
" q' W- V6 a( O* \8 a - itemCreateInput->setString("object_desc", "My Item Description", false);
4 s5 y4 W. C: n' q" _1 @' G - itemCreateInput->setTag("revision", revCreateInput->getTag(), false);8 t5 i$ T. Q% [$ w
- $ n$ ~" |$ C) o
- // set Revision properties& Z' D- l; ^4 {% C8 j. y: J8 ~7 e
- revCreateInput->setString("item_revision_id", "00", false);5 s4 v! c! c9 g) V! O5 {8 H" x
- revCreateInput->setString("object_name", "My Revision Name", false);
2 w0 z( u' o6 n2 C% g& W/ a. _0 |3 z - revCreateInput->setString("object_desc", "My Revision Description", false);/ y4 E8 ^+ z8 t8 \3 l
- , d- Z# y4 W( N2 B: j! x
- Teamcenter::Item *pItem = dynamic_cast<Teamcenter::Item *>(Teamcenter::BusinessObjectRegistry::instance().createBusinessObject(itemCreateInput));/ a! h6 {% p- Y0 X2 c
9 C3 @" M0 k+ H: r- ifail = AOM_save_with_extensions(pItem->getTag());
& L9 M9 @7 R& k6 z" Z - ' i) p; b: l3 a5 x2 b
- // If the Revision is not saved it will inherit the Item's Name and Description.
' f# T4 e# B, l3 o9 ]% u - ifail = AOM_save_with_extensions(revCreateInput->getTag());* `. @# ?8 }7 P, @& w; a4 i; u: N$ X
- }
复制代码 & Z1 U0 e( d4 m9 T* D3 Y; M
( j7 K1 [* v& T0 d- m ?1 M" q
|
|