|
请使用QQ关联注册PLM之家,学习更多关于内容,更多精彩原创视频供你学习!
您需要 登录 才可以下载或查看,没有账号?注册
x
, N" B6 V( e7 h$ |. h% R# l
Teamcenter C++二次开发源码分享:创建item和item版本
5 _9 Z5 G! v6 f1 G% X/ l- G9 P
- R9 {8 I0 Q- ]6 R& O8 S8 `- h7 ?8 [8 D& T+ G& H
通过创建businessobject 指定的createinput 完成对象的创建+ c/ h- d) R( b! s6 F8 O
4 D0 l+ O0 ^' l9 p6 w
5 i+ q" Z) N. t4 Y# k/ e# @
- #include <constants/constants.h>4 C) a+ ^1 D# P1 Z8 O
- #include <TCcore/Item.hxx>
' T1 G4 P; |( m6 V; k - #include <metaframework/CreateInput.hxx>$ O! ?+ I( e/ E' A1 C+ I3 M
- #include <metaframework/BusinessObjectRegistry.hxx>
/ i0 L* r4 O, A) r' f/ [! A
! V6 l* I2 w* ^ _- using namespace std;
+ T% r8 Q4 M' b. W - , M" ?! ? Y6 W+ x
- static void createItemAndRevisionWithDifferentNames(void)
9 w, \; F2 M! [" |8 x - {
% M' L) q3 c# ]$ ^" ]6 C - int ifail = ITK_ok;$ O* S; [4 Z, v+ f Y; x9 }
- + ~! r& L" H m0 f- M
- char type_name[] = "Item";
5 ?3 L! } J8 ~6 G o! a8 n- w8 H - Teamcenter::CreateInput* itemCreateInput = static_cast<Teamcenter::CreateInput*>(Teamcenter::BusinessObjectRegistry::instance().createInputObject(type_name, OPERATIONINPUT_CREATE));
$ n4 h* k X. J" G, Y: p$ q - + V5 p$ F8 b& f; L$ |6 m
- //Revision type name is not always <item type name>Revision" a& I2 i0 u7 _0 E- _
- char *revision_type_name = 0;: u5 j+ v0 J2 `3 L5 U$ }9 g$ c2 N
- CONSTANTS_get_type_constant_value("ItemRevision", type_name, &revision_type_name);
: X7 p+ ^: r4 r
% O8 U$ a+ ?5 K- Teamcenter::CreateInput* revCreateInput = static_cast<Teamcenter::CreateInput*>(Teamcenter::BusinessObjectRegistry::instance().createInputObject(revision_type_name, OPERATIONINPUT_CREATE));
: [# S! E& F3 X* x' \" u5 f -
9 h3 Y3 C# I; N; y; M - MEM_free(revision_type_name);% {% n# u3 ^7 n- t1 D
# `! T7 A: ^' F. V- // set Item properties
6 Q t" O0 J$ } - itemCreateInput->setString("item_id", "1234567", false);3 u* @( n% a/ Q* r4 H, I! H2 ]8 ]8 _
- itemCreateInput->setString("object_name", "My Item Name", false);2 Z8 f* T3 y+ o, ]+ i# }
- itemCreateInput->setString("object_desc", "My Item Description", false);& I& n. Y* O: G6 K5 w) s" w6 n* Z
- itemCreateInput->setTag("revision", revCreateInput->getTag(), false);
4 `7 S( J& w5 |% p" X' e% `" ?
/ E8 a% i1 o6 `6 Y- // set Revision properties. ?0 x5 h# k8 `& f! K
- revCreateInput->setString("item_revision_id", "00", false);
4 ]& J' h/ i5 h* p - revCreateInput->setString("object_name", "My Revision Name", false);
$ v+ x/ _6 l; M& S- N; q, O' D* M - revCreateInput->setString("object_desc", "My Revision Description", false);
! Q( ^7 b: L1 c& e6 N! { - , U# y6 h1 U4 i% D
- Teamcenter::Item *pItem = dynamic_cast<Teamcenter::Item *>(Teamcenter::BusinessObjectRegistry::instance().createBusinessObject(itemCreateInput));
, V( p) l( n1 b
7 P: ]- ^' t# E% @- ifail = AOM_save_with_extensions(pItem->getTag()); ?; ?1 t: P' s: Z
8 M: ^# j/ t. N w5 e5 D- // If the Revision is not saved it will inherit the Item's Name and Description.2 `: ~* Y7 c/ y2 R7 I' ]8 P! r' V
- ifail = AOM_save_with_extensions(revCreateInput->getTag());1 s* m' ~0 }1 A5 w9 B
- }
复制代码 ! P: ]6 g, ~: |0 F7 Y
" O/ m1 S! Q. ?% {1 m& X/ t
|
|