|
|
请使用QQ关联注册PLM之家,学习更多关于内容,更多精彩原创视频供你学习!
您需要 登录 才可以下载或查看,没有账号?注册
x
! [. y, l9 E& K1 B# Z, i2 Z
Teamcenter C++二次开发源码分享:创建item和item版本
! ]$ X/ ]/ d2 \6 ~* S6 @9 @+ z) B, G) p
/ I/ K" u8 O6 U0 q) u
通过创建businessobject 指定的createinput 完成对象的创建
6 F: i$ K, W, j' c# A V$ n6 S2 M1 e% E$ |
, i0 f2 N: p1 Q. e6 V1 e+ W$ {- #include <constants/constants.h>
# ]0 s. @8 g, N8 x5 P8 B$ ~4 Q - #include <TCcore/Item.hxx>3 \& L+ [: ^8 F* z
- #include <metaframework/CreateInput.hxx>
% c8 }7 k1 k0 D& P; d: P - #include <metaframework/BusinessObjectRegistry.hxx>
6 H# j* u4 |( i2 U" m1 Q
8 Y% t6 M+ L% z: E- using namespace std;* y" S7 A4 ?# D4 x7 O+ N! E6 U
- 6 B( E1 m7 R! [
- static void createItemAndRevisionWithDifferentNames(void)6 m" i8 b |/ j! N! c' |: W
- {; s8 C# T d- S9 h1 U8 c: n0 _
- int ifail = ITK_ok;# N9 D [- [; X" o7 h
- ( g( [7 Z$ F$ s# V y
- char type_name[] = "Item";* M0 K+ ?; g) m
- Teamcenter::CreateInput* itemCreateInput = static_cast<Teamcenter::CreateInput*>(Teamcenter::BusinessObjectRegistry::instance().createInputObject(type_name, OPERATIONINPUT_CREATE));
. t: a+ q$ V5 ?2 k* g4 p! g! U; W- Z3 c2 _ - $ C& N2 A8 Z0 F1 ^; p
- //Revision type name is not always <item type name>Revision
0 q! ^ U% b1 b8 I2 k( T! C$ X/ ^ - char *revision_type_name = 0;
! t" @) H' S5 Q, D" B/ L - CONSTANTS_get_type_constant_value("ItemRevision", type_name, &revision_type_name);4 |) P; L/ B& w8 z# A/ h
- $ p$ F* y2 [" y* M$ u
- Teamcenter::CreateInput* revCreateInput = static_cast<Teamcenter::CreateInput*>(Teamcenter::BusinessObjectRegistry::instance().createInputObject(revision_type_name, OPERATIONINPUT_CREATE));6 `* `/ D8 i- H4 h c, {4 V
-
' P: b7 r& O h - MEM_free(revision_type_name);, p+ q6 n5 f9 c2 l
8 [* \2 t' l1 ^- // set Item properties
* D& n2 f% T& j1 |2 ]" M# a+ F1 N - itemCreateInput->setString("item_id", "1234567", false);
# R' b+ A/ ?; q8 J% J( S - itemCreateInput->setString("object_name", "My Item Name", false);
- B! R7 i8 N5 h" | - itemCreateInput->setString("object_desc", "My Item Description", false);
# h2 ]6 b5 d6 `& |) ` - itemCreateInput->setTag("revision", revCreateInput->getTag(), false);
& P9 [' ~3 X# q+ L9 d/ }- u
V, L) m. Q$ V: l- // set Revision properties
G6 L( Z4 l7 H1 C6 b" n8 N - revCreateInput->setString("item_revision_id", "00", false);
, m0 c3 @+ d4 T5 N O* e- k. N/ f# u - revCreateInput->setString("object_name", "My Revision Name", false);
% v9 G; L9 v& A- x# t% N/ S @ - revCreateInput->setString("object_desc", "My Revision Description", false);- T% c9 V! T3 A$ ^# D! `6 g
- 4 v) k8 R3 G+ @, o
- Teamcenter::Item *pItem = dynamic_cast<Teamcenter::Item *>(Teamcenter::BusinessObjectRegistry::instance().createBusinessObject(itemCreateInput));1 r* d' S0 ]) O: [9 A2 {
4 t5 G" F4 g6 ^, ^- ifail = AOM_save_with_extensions(pItem->getTag());
) ?9 l7 p! i: t1 D) X8 C3 _
* ]6 l0 ]. J( z# [* r* A& [; b- // If the Revision is not saved it will inherit the Item's Name and Description.
! W1 B6 P4 }) O# ` - ifail = AOM_save_with_extensions(revCreateInput->getTag());
- |& V" @- ]- E$ H* Q6 N - }
复制代码 $ g) W" {% s) f- M
6 j4 ]. r% N8 B
|
|