|
请使用QQ关联注册PLM之家,学习更多关于内容,更多精彩原创视频供你学习!
您需要 登录 才可以下载或查看,没有账号?注册
x
9 Q1 s' c& L2 ]9 n$ S% e
Teamcenter C++二次开发源码分享:创建item和item版本* C1 {- j, Z4 v2 o A2 ~1 N
8 ?" T3 [) H) _* Z- T
/ y& i6 J1 P, U7 [: ]4 L" t7 _通过创建businessobject 指定的createinput 完成对象的创建
" q/ n" x0 Q( h% H
4 ?- G4 F5 a" ?* u2 S% _/ o3 g6 Z! ~, Y5 j' h5 T
- #include <constants/constants.h>7 G9 a( y6 {; f) [' e
- #include <TCcore/Item.hxx>( F# c+ p0 v' n8 b+ f
- #include <metaframework/CreateInput.hxx>
8 m R7 {+ J, r i1 M - #include <metaframework/BusinessObjectRegistry.hxx>
4 n$ {# b$ ~! R2 O - - [8 [1 ]/ y" _: I0 n1 t
- using namespace std;% Z, R5 ~* @, L$ o B5 }
- ( h* g, n( X9 B$ b; G9 V) S
- static void createItemAndRevisionWithDifferentNames(void) m: }! N0 s* t- o- r
- {
# d7 L- o) g a! b) b - int ifail = ITK_ok;$ E1 r, t, n$ ^) p- F# o' u) v8 J
- " u6 |! v, m0 i* i" u. a
- char type_name[] = "Item";
1 i: J6 m4 j$ B% B6 K, S6 d - Teamcenter::CreateInput* itemCreateInput = static_cast<Teamcenter::CreateInput*>(Teamcenter::BusinessObjectRegistry::instance().createInputObject(type_name, OPERATIONINPUT_CREATE));1 R S4 i7 o, }9 P G5 k; X
$ y+ x( r3 j- D9 @. N+ [- Y- //Revision type name is not always <item type name>Revision. f: \; T0 D& h) I
- char *revision_type_name = 0;. z* k# n9 e) R. z1 N
- CONSTANTS_get_type_constant_value("ItemRevision", type_name, &revision_type_name);
1 j4 o: {0 e2 a9 F - 7 Y& U+ H- Z5 B8 j9 v
- Teamcenter::CreateInput* revCreateInput = static_cast<Teamcenter::CreateInput*>(Teamcenter::BusinessObjectRegistry::instance().createInputObject(revision_type_name, OPERATIONINPUT_CREATE));
4 w9 }" k0 q9 y+ T/ ?+ o4 t8 h -
; |( h( U% s6 _: F% K1 U9 I - MEM_free(revision_type_name);, [6 C! s. a3 x
- $ x- b7 q/ S: c5 ~ v9 G( ~; ]
- // set Item properties4 {9 E/ U* ]2 x# x7 l6 B
- itemCreateInput->setString("item_id", "1234567", false);1 t' `. m6 k9 t Z
- itemCreateInput->setString("object_name", "My Item Name", false);$ `: ^( I0 H$ j* h: ]5 F
- itemCreateInput->setString("object_desc", "My Item Description", false);/ `; u& h/ K' K& N4 W. f0 Z+ B
- itemCreateInput->setTag("revision", revCreateInput->getTag(), false);! V! R3 ?8 @: D3 c8 Z; o6 K9 f
- 8 j2 G7 o- j; w9 `& l8 e' \
- // set Revision properties0 f' V z! E3 h# e% e
- revCreateInput->setString("item_revision_id", "00", false);3 W/ Y0 r8 i2 S" a
- revCreateInput->setString("object_name", "My Revision Name", false);
& [+ G# T, T3 K# H - revCreateInput->setString("object_desc", "My Revision Description", false);% J2 }( m7 R- O# o! Q( H3 b
- % ]) f2 i. V4 y& M
- Teamcenter::Item *pItem = dynamic_cast<Teamcenter::Item *>(Teamcenter::BusinessObjectRegistry::instance().createBusinessObject(itemCreateInput));3 M4 o& z7 Q5 h+ o$ u* f
; N: z; X1 ]4 W( B6 L$ o6 X# { H- ifail = AOM_save_with_extensions(pItem->getTag());' @- O9 d& ]* [5 d
- 2 s& f. ~. t. i" q! @0 Q
- // If the Revision is not saved it will inherit the Item's Name and Description.
7 R$ m/ i9 m; v! Z. s7 k- h - ifail = AOM_save_with_extensions(revCreateInput->getTag());
$ q7 o$ R/ e H' B - }
复制代码 $ P( i$ q/ P+ l1 `
* {0 F+ w, T. y) A |
|