|
|
请使用QQ关联注册PLM之家,学习更多关于内容,更多精彩原创视频供你学习!
您需要 登录 才可以下载或查看,没有账号?注册
x
! b) }# T5 ~4 G) }5 ]Teamcenter C++二次开发源码分享:创建item和item版本
/ f+ t: K7 h6 s9 _8 E
7 q) t7 M8 h# r% j6 u f
; j' w: v9 ]# }& m! B通过创建businessobject 指定的createinput 完成对象的创建
9 M8 O: M* H2 ?* `9 {6 a/ V, Y
: I' b. b6 k+ Z8 ~, u
4 i {0 s/ |' X1 h- #include <constants/constants.h>+ y4 C. j% {! _8 r: n
- #include <TCcore/Item.hxx>
" A+ r: p) @, M/ C# @3 w7 T# L - #include <metaframework/CreateInput.hxx>6 v# p8 X8 z- G
- #include <metaframework/BusinessObjectRegistry.hxx>7 w9 |: w3 ~0 R
C: L6 L, a! s1 p9 H6 U- using namespace std;
0 W- b$ p s8 Y' r5 p) T
B4 V2 v5 J0 K) k- static void createItemAndRevisionWithDifferentNames(void)4 p7 Z- C4 D' l& { R5 Q
- {) U) J9 p& U0 n$ b0 `, U
- int ifail = ITK_ok;
6 l: v6 u, O; z1 G1 _8 G - 8 m+ ^( m) y# w3 z( R' y$ S% t
- char type_name[] = "Item";
, F1 V. O. A3 O$ ^ - Teamcenter::CreateInput* itemCreateInput = static_cast<Teamcenter::CreateInput*>(Teamcenter::BusinessObjectRegistry::instance().createInputObject(type_name, OPERATIONINPUT_CREATE));
1 g' F% F, n+ X) I9 _! t3 r - 3 h! C, U$ M2 n$ E0 }. s9 @1 q
- //Revision type name is not always <item type name>Revision9 Z6 s- g) _" J, ~
- char *revision_type_name = 0;9 ]5 N' L* [2 A/ T8 W% D& H
- CONSTANTS_get_type_constant_value("ItemRevision", type_name, &revision_type_name);1 p# n5 K; P& y7 h
- + T/ S! ?9 t ~, N! @3 x
- Teamcenter::CreateInput* revCreateInput = static_cast<Teamcenter::CreateInput*>(Teamcenter::BusinessObjectRegistry::instance().createInputObject(revision_type_name, OPERATIONINPUT_CREATE));
1 Z+ q1 S _& O; U" c! T7 ?0 w4 m7 w -
1 r1 B3 C. V [6 Y - MEM_free(revision_type_name);
* s* M8 l& z& y1 i$ Z+ V' K
k$ A! i! u% U: Y0 @8 b) F- // set Item properties' _1 s3 C. L2 x/ t, W
- itemCreateInput->setString("item_id", "1234567", false);3 Z, p: h' X2 y
- itemCreateInput->setString("object_name", "My Item Name", false);2 ?. z% c' d7 H# b! d# @
- itemCreateInput->setString("object_desc", "My Item Description", false);9 k, u/ I2 L$ u/ j) w- b# v
- itemCreateInput->setTag("revision", revCreateInput->getTag(), false);
# b* R3 i; r5 x: d$ m# U7 ~. K - ) k3 J* `( s1 v8 ?& R/ _2 ~% _7 r
- // set Revision properties
: z4 q/ X) \. O U% } - revCreateInput->setString("item_revision_id", "00", false);
5 k- O! Z- B* S+ [3 r* J* @ - revCreateInput->setString("object_name", "My Revision Name", false);
# w2 `* @4 x" a/ t - revCreateInput->setString("object_desc", "My Revision Description", false);
: @2 u6 o0 n, M% L( f - + ~* q: d/ L3 A: ]. ]9 W3 H
- Teamcenter::Item *pItem = dynamic_cast<Teamcenter::Item *>(Teamcenter::BusinessObjectRegistry::instance().createBusinessObject(itemCreateInput));
8 A6 p4 i& [/ Y3 Y l+ ], G8 }% j - ( |9 s& o0 M. S/ g# M" g! K. P
- ifail = AOM_save_with_extensions(pItem->getTag());( ?1 a- [# @' s7 x
( [+ e% t' `! [3 l5 }- // If the Revision is not saved it will inherit the Item's Name and Description.
3 r6 ^! d' Y" K7 ^ - ifail = AOM_save_with_extensions(revCreateInput->getTag());+ e" c( L; E2 v5 ]! e
- }
复制代码 % E) P$ \7 }; d6 r6 ?3 W
( A: q/ j; n4 c8 L/ q+ \
|
|