|
|
请使用QQ关联注册PLM之家,学习更多关于内容,更多精彩原创视频供你学习!
您需要 登录 才可以下载或查看,没有账号?注册
x
# e+ K* y! E3 \7 @
Teamcenter C++二次开发源码分享:创建item和item版本
1 R3 X! m1 k" @: V( h$ Z
' P/ I2 Z. a1 ^- s. _( f5 `1 D m3 D3 y+ b _9 c H
通过创建businessobject 指定的createinput 完成对象的创建& ]1 e4 g) n2 @; m4 k/ }. E
1 M8 L6 @) T/ P5 {0 |; Y1 X) v
# V2 s4 ?& \$ g! o- #include <constants/constants.h>
. [+ E% F4 a; d/ L - #include <TCcore/Item.hxx>
+ M' c' _2 a" v- \% z0 d; Y - #include <metaframework/CreateInput.hxx>
1 I) H6 O" ^& ^! d - #include <metaframework/BusinessObjectRegistry.hxx>) ], F( @* ] B% p6 Q/ V
- " {2 R" p/ ] |* {7 n1 v/ l
- using namespace std;
; J1 B p6 l2 T: l - / d- O& j' v( @1 |( \, b) ?
- static void createItemAndRevisionWithDifferentNames(void)
) N% I% j( t" j U - {
. W* A/ M4 s4 p/ Y. g6 m7 Z - int ifail = ITK_ok;
6 w+ f! x1 U! |' R, `1 K# l" A
& j- x3 P; v3 a; T- char type_name[] = "Item";
: T. y d3 n8 v3 r% l) b - Teamcenter::CreateInput* itemCreateInput = static_cast<Teamcenter::CreateInput*>(Teamcenter::BusinessObjectRegistry::instance().createInputObject(type_name, OPERATIONINPUT_CREATE));
, a6 D. z+ e. E# v! {3 A# u1 d - Y. |0 H0 V8 o* r7 j1 E
- //Revision type name is not always <item type name>Revision
* ]8 O/ p$ j1 _: t) ?2 _ - char *revision_type_name = 0;
5 r" q; M9 S# Z4 q; ?. B - CONSTANTS_get_type_constant_value("ItemRevision", type_name, &revision_type_name);
8 v0 B! Q8 I1 R
! x* `1 g" f( E* f- Teamcenter::CreateInput* revCreateInput = static_cast<Teamcenter::CreateInput*>(Teamcenter::BusinessObjectRegistry::instance().createInputObject(revision_type_name, OPERATIONINPUT_CREATE));
' G& @. w8 s1 Q% O - ]/ u0 S8 q$ c; i1 n# s" ]
- MEM_free(revision_type_name);
1 L' j+ m ~, e7 |+ e4 Z$ ` - 9 X% Z1 N& J$ d6 E6 Q' w
- // set Item properties; R/ v7 N6 j9 e* }' A1 ^, t/ m! w
- itemCreateInput->setString("item_id", "1234567", false);; S' s! E( L; w
- itemCreateInput->setString("object_name", "My Item Name", false);
) s9 l8 W4 z3 Y: c- B: p - itemCreateInput->setString("object_desc", "My Item Description", false);) j" Y- s9 f% Z2 c( R
- itemCreateInput->setTag("revision", revCreateInput->getTag(), false);
: b( A1 _6 o. \. x. y- x
2 c2 z+ e/ u# U# L2 [- n5 Z2 v- // set Revision properties% r( g/ _. O0 B+ |0 |! V! V# E
- revCreateInput->setString("item_revision_id", "00", false);
% G; Q; K: H% J, q- T8 o) `1 g- H - revCreateInput->setString("object_name", "My Revision Name", false);! a! i- S4 `: v/ R, c# m$ [5 k# P
- revCreateInput->setString("object_desc", "My Revision Description", false);
5 e8 A0 o/ x! Z% j$ s1 p3 K* e* l - # i7 K8 L+ E8 D
- Teamcenter::Item *pItem = dynamic_cast<Teamcenter::Item *>(Teamcenter::BusinessObjectRegistry::instance().createBusinessObject(itemCreateInput));; R; J: z- h3 `' X4 Y( T( [. }6 e5 y; b+ M. H
- 2 A. p' o- n) r5 \; S
- ifail = AOM_save_with_extensions(pItem->getTag());
9 r9 R9 [0 y6 I q8 a7 r' M5 H - % V+ o3 k; o- b9 l' ]: C
- // If the Revision is not saved it will inherit the Item's Name and Description.
2 q+ g( j! D+ `5 a - ifail = AOM_save_with_extensions(revCreateInput->getTag());; T# l4 b2 h3 v2 _0 |: o( ]+ G% Z
- }
复制代码 ! \. g1 k$ u1 W
5 m' l; S1 |; T$ G7 |5 u
|
|