|
请使用QQ关联注册PLM之家,学习更多关于内容,更多精彩原创视频供你学习!
您需要 登录 才可以下载或查看,没有账号?注册
x
* q8 P% S) h0 R
Teamcenter C++二次开发源码分享:创建item和item版本
7 |8 |: z1 B1 ]( w
0 M: B' u6 f) V; }0 R! C; |6 }& k
通过创建businessobject 指定的createinput 完成对象的创建# t2 Q. c5 [8 M3 h! V! X1 ~
+ P6 G F0 S3 L/ R
( C* C& O- K7 U( S) Z
- #include <constants/constants.h>
' B# F+ m8 T* l @7 N; O - #include <TCcore/Item.hxx>
0 X. z7 s4 P; ?, U% V6 d* n/ r - #include <metaframework/CreateInput.hxx>
# X3 e' D3 V* c( C/ i+ U - #include <metaframework/BusinessObjectRegistry.hxx> x+ l m6 g f: u+ Z
) `9 q5 F1 |* T: ^- A4 M$ B- using namespace std;/ e6 @5 t0 p6 z. G& g: c
3 [9 w# f& Q# j- static void createItemAndRevisionWithDifferentNames(void). P; L8 ]$ ?# W8 l- q2 f+ O
- {2 k- h3 B h7 C$ u# L+ e
- int ifail = ITK_ok;
6 ^0 I( k. r! T9 p! L2 a+ r/ _- ` - $ f" ^" }' d: {$ s" A
- char type_name[] = "Item";. A) P$ h3 b+ m2 p N; x/ ^
- Teamcenter::CreateInput* itemCreateInput = static_cast<Teamcenter::CreateInput*>(Teamcenter::BusinessObjectRegistry::instance().createInputObject(type_name, OPERATIONINPUT_CREATE));
( z6 m: S }3 q$ n2 Y: r
- ]+ o0 l) m" e5 L9 U G+ k. t1 y- //Revision type name is not always <item type name>Revision+ u& {- ?, k6 b: t( C. W
- char *revision_type_name = 0;
m" ]8 u U5 T* _ [ - CONSTANTS_get_type_constant_value("ItemRevision", type_name, &revision_type_name);
3 @/ S$ z3 M, q: O- f; i - 6 a, ~6 ^, ]5 b1 @$ }& \( f& |
- Teamcenter::CreateInput* revCreateInput = static_cast<Teamcenter::CreateInput*>(Teamcenter::BusinessObjectRegistry::instance().createInputObject(revision_type_name, OPERATIONINPUT_CREATE));9 B3 s( _- ~$ _
- ; r# B _& v' ]# ~1 N
- MEM_free(revision_type_name);
y- [' [6 p4 I) o
0 ~- U6 u0 P* g0 t* g2 Y' n T- // set Item properties
0 n/ m( B- K T: L: h - itemCreateInput->setString("item_id", "1234567", false);: x" N2 M+ ]9 k: T% \$ H
- itemCreateInput->setString("object_name", "My Item Name", false);' [. }" ]3 l5 m9 S& P
- itemCreateInput->setString("object_desc", "My Item Description", false);
" U/ a+ R: {4 d" d - itemCreateInput->setTag("revision", revCreateInput->getTag(), false);2 Z; H3 B# L* s: ]" u
% o& i. t" W2 r$ f% F% Q7 Y- // set Revision properties1 P( ]! N- l7 B1 g
- revCreateInput->setString("item_revision_id", "00", false);9 {. W8 i6 K# n, \3 ~3 l
- revCreateInput->setString("object_name", "My Revision Name", false);9 n8 h- |& s3 ?
- revCreateInput->setString("object_desc", "My Revision Description", false);+ q! E) m, V6 l8 s
$ D0 {; g" D; R9 ?: _6 h+ f% F/ t- Teamcenter::Item *pItem = dynamic_cast<Teamcenter::Item *>(Teamcenter::BusinessObjectRegistry::instance().createBusinessObject(itemCreateInput));
/ P" k" t3 N# O* z3 z$ g: } - + X9 f: i, K3 W7 I' e
- ifail = AOM_save_with_extensions(pItem->getTag());
: I! V* g1 h8 }9 z5 z: m - % P, ]' A- C; `7 Y% D/ W# a/ J
- // If the Revision is not saved it will inherit the Item's Name and Description.
! d1 \# n' v6 ^# F$ |3 X$ Y - ifail = AOM_save_with_extensions(revCreateInput->getTag());" _5 \0 G, y: Z& J0 U4 h) ? i
- }
复制代码 * U' C# N' I! J7 k4 f
( g* M6 g3 P6 C/ O% b |
|