|
|
请使用QQ关联注册PLM之家,学习更多关于内容,更多精彩原创视频供你学习!
您需要 登录 才可以下载或查看,没有账号?注册
x
4 X% I0 s; U4 O. T0 f- N8 sTeamcenter C++二次开发源码分享:创建item和item版本
/ ^! u: i4 `+ I/ r1 C( ?7 F; f+ l, ~- Y r# }! G4 R) }
) R" q: ?" f! x% W* J; T! a
通过创建businessobject 指定的createinput 完成对象的创建
; ~& o/ o" t9 X" h' p- ^
) B" G* o5 f7 F3 y/ ?4 c- T, _; O! F$ H0 B
- #include <constants/constants.h>
. C7 F3 C% u0 P( e% x8 x! B3 g) ? - #include <TCcore/Item.hxx>
: t2 |4 B1 x& z) z - #include <metaframework/CreateInput.hxx>
1 x% n5 V+ ? h1 C7 ~" x4 [ - #include <metaframework/BusinessObjectRegistry.hxx>
$ ?9 m8 c" r9 I2 b- }+ S) m - ' \' P. z/ r7 V* W+ K( a! @
- using namespace std;
. G+ q8 M3 e9 u+ R# K1 g4 |
6 ?( z4 G+ E+ j" D+ y- static void createItemAndRevisionWithDifferentNames(void)
- @0 o6 v+ r+ |; N - {; k- r8 |# u: v& n: T, f
- int ifail = ITK_ok;
5 `/ ^7 [% s' ?; c) t7 |
; o# N% O% O% |) a$ o; u$ @# S7 F- char type_name[] = "Item";
& \- B7 t6 D' u, `% D - Teamcenter::CreateInput* itemCreateInput = static_cast<Teamcenter::CreateInput*>(Teamcenter::BusinessObjectRegistry::instance().createInputObject(type_name, OPERATIONINPUT_CREATE));
# G7 _! Z7 A7 d3 S, q, C# H: N - 9 t( B" E. l! Q6 s# E3 ]- ^
- //Revision type name is not always <item type name>Revision
) R( p7 b) b# A$ ^' d0 [ - char *revision_type_name = 0;
# {2 a" k7 A+ j. z% K! c" h3 F. O - CONSTANTS_get_type_constant_value("ItemRevision", type_name, &revision_type_name);
/ l6 p+ \/ l4 z$ ]/ S4 c7 H: z7 |
7 V4 A* ~: S. N5 P' V( e7 M- Teamcenter::CreateInput* revCreateInput = static_cast<Teamcenter::CreateInput*>(Teamcenter::BusinessObjectRegistry::instance().createInputObject(revision_type_name, OPERATIONINPUT_CREATE));- X2 R$ ~1 y$ d: x9 [2 u6 m
- * e$ o, @8 @' y. s9 Q# F1 ^, S
- MEM_free(revision_type_name);# S6 K, \; W6 k: E
- % j" ?3 b! D+ s W3 L/ b* R
- // set Item properties) l" i, d- a k$ T! E+ U
- itemCreateInput->setString("item_id", "1234567", false);
6 ?; c/ r, Y( Z6 G - itemCreateInput->setString("object_name", "My Item Name", false);
# C$ K! j. K; s" Q9 ] - itemCreateInput->setString("object_desc", "My Item Description", false);+ S7 @. M! |6 U' O
- itemCreateInput->setTag("revision", revCreateInput->getTag(), false);( j% c1 U0 R, q7 M5 R a
# R: `* w6 h/ |, h$ Q' r- // set Revision properties
$ T s: b9 H3 V5 a7 c, V7 K - revCreateInput->setString("item_revision_id", "00", false);
& F$ @- S' X/ H- c% _; e - revCreateInput->setString("object_name", "My Revision Name", false);
& A" ^+ |6 u' ], C7 v - revCreateInput->setString("object_desc", "My Revision Description", false);, V5 n! J( d9 @ O* O3 B/ I2 e, J
- , ~% f4 P! x# K9 x {- U
- Teamcenter::Item *pItem = dynamic_cast<Teamcenter::Item *>(Teamcenter::BusinessObjectRegistry::instance().createBusinessObject(itemCreateInput));! T) G! _" _9 D+ d4 | Q+ p* W, F# o" d
; S. V- E: r! |- ifail = AOM_save_with_extensions(pItem->getTag());4 J1 i: C1 Q5 g9 H" }9 b% H V
; {. M! Z* Z' I, S. u# }% q; {- // If the Revision is not saved it will inherit the Item's Name and Description., t" [# n* W5 j3 ^# z, z' K
- ifail = AOM_save_with_extensions(revCreateInput->getTag());
$ u4 y* a, @+ \4 w0 W. J - }
复制代码
, I9 i: f& b4 ~4 y O, \2 G8 Q( ]" _) n3 \: i
|
|