|
|
请使用QQ关联注册PLM之家,学习更多关于内容,更多精彩原创视频供你学习!
您需要 登录 才可以下载或查看,没有账号?注册
x
8 Q% g( i2 O" ], w5 pTeamcenter C++二次开发源码分享:创建item和item版本
?5 L4 L+ H0 o* }. B- G
! U% ^; [1 \: k! ]8 o
# ]6 B7 Y& `7 h: O通过创建businessobject 指定的createinput 完成对象的创建
" n: x J3 [4 F# G; ?* S; z! v# f3 K V' G- c) S) b" S
) r3 \& p7 H# ?9 H3 _& ]4 l- #include <constants/constants.h>9 M# g, z* ?4 ]6 s
- #include <TCcore/Item.hxx>
: h/ j+ j O' \5 J - #include <metaframework/CreateInput.hxx>! _8 C8 q$ a; D0 T2 _
- #include <metaframework/BusinessObjectRegistry.hxx>
/ r }/ d9 h1 O c
& o- \# x1 d* ?9 B( X' w: A- using namespace std;
* f# x- T7 t9 j7 Y3 F8 b% Z - ( Z; M7 q: L, i0 A
- static void createItemAndRevisionWithDifferentNames(void)0 t" D8 J5 ~1 z' [* ~8 z( A
- {8 f; }8 z/ b2 ]$ @
- int ifail = ITK_ok;1 M# i$ N' {: E2 C; P( H, U
1 H/ e2 O3 K) [2 a8 h N- char type_name[] = "Item";4 i; g% c: X f1 j4 w4 ^8 C! x
- Teamcenter::CreateInput* itemCreateInput = static_cast<Teamcenter::CreateInput*>(Teamcenter::BusinessObjectRegistry::instance().createInputObject(type_name, OPERATIONINPUT_CREATE));
: |/ i' ^* h2 t - 4 B: X# q6 f6 W5 z6 @& M
- //Revision type name is not always <item type name>Revision
- R1 u/ b/ g0 z7 n& l, f. r+ b' _ - char *revision_type_name = 0;- z7 e/ r7 o6 R$ T8 {. X) p P
- CONSTANTS_get_type_constant_value("ItemRevision", type_name, &revision_type_name);, J8 _8 a$ q: H- P* ?; f
- 6 D4 x+ j/ U$ d3 B/ S1 w
- Teamcenter::CreateInput* revCreateInput = static_cast<Teamcenter::CreateInput*>(Teamcenter::BusinessObjectRegistry::instance().createInputObject(revision_type_name, OPERATIONINPUT_CREATE));
9 ]2 Z8 G. R A6 Z+ d8 R/ J8 | - - K+ D9 i* b' ?& N9 O5 v* Q
- MEM_free(revision_type_name);
! Q0 |2 N+ o/ ?9 j - 7 _6 j; O6 q x. w; K9 j
- // set Item properties! t O: w% \8 _& d2 {
- itemCreateInput->setString("item_id", "1234567", false);9 u3 [7 r {* w+ T7 a
- itemCreateInput->setString("object_name", "My Item Name", false);/ _& o) T8 D8 u2 R# ^1 @8 Y
- itemCreateInput->setString("object_desc", "My Item Description", false);6 t% O3 ?" W% t* a8 H, `# Z' E
- itemCreateInput->setTag("revision", revCreateInput->getTag(), false);
; ~4 b |+ n% m! C& l9 B: E9 t - 4 r9 M6 M q# L0 h
- // set Revision properties
; ^' t9 b# u* Q& Q( Z- Q7 ~+ O) ~ - revCreateInput->setString("item_revision_id", "00", false);( ^5 H7 S; L8 K# y
- revCreateInput->setString("object_name", "My Revision Name", false);
* A' w5 o5 @, V' O7 i - revCreateInput->setString("object_desc", "My Revision Description", false);
. ^; ?! n* E( L! W) D
3 n0 i! _' e! r0 n J- Teamcenter::Item *pItem = dynamic_cast<Teamcenter::Item *>(Teamcenter::BusinessObjectRegistry::instance().createBusinessObject(itemCreateInput));9 N: ]$ {* z' L/ L
, _) v; q, w( D) u1 B- ifail = AOM_save_with_extensions(pItem->getTag());
( I7 V, S: x* M) m* n9 j
; e5 i; e+ I# Z- c- // If the Revision is not saved it will inherit the Item's Name and Description.
: p8 V7 [2 w1 Y - ifail = AOM_save_with_extensions(revCreateInput->getTag()); l* E; b5 d- L8 @
- }
复制代码
7 E$ j* _+ F+ W1 ~1 u, W
) `1 o% l4 c+ Y+ L8 f |
|