|
请使用QQ关联注册PLM之家,学习更多关于内容,更多精彩原创视频供你学习!
您需要 登录 才可以下载或查看,没有账号?注册
x
0 P7 H/ L& Y: t7 _
Teamcenter C++二次开发源码分享:创建item和item版本
- M6 P4 b3 Q5 d1 K3 |0 H" d3 _6 G1 S% i4 R
, G$ p* E1 Z% }% g' d- k通过创建businessobject 指定的createinput 完成对象的创建; Q5 K+ r1 v$ V8 C
/ G5 n8 N. U; @/ ]# l4 V7 F# ^% F" M
q" M) L# ~$ y- #include <constants/constants.h>
# R- R* c( x7 a - #include <TCcore/Item.hxx>" S+ k7 c( H# [' C$ ]( _# S0 H! ]
- #include <metaframework/CreateInput.hxx>
) w6 L5 A& O* v$ l# a - #include <metaframework/BusinessObjectRegistry.hxx>- w, A+ |! H5 e" H5 n
- : M5 {, V' o/ L# v& j4 o
- using namespace std;' u+ v9 A+ e2 O& P5 s
* d, A- p6 i8 U' ]- static void createItemAndRevisionWithDifferentNames(void)2 N$ R2 d$ a! Q; y' O: g8 d) s
- {) x/ p9 \" t+ k g+ k/ }; u( T
- int ifail = ITK_ok;0 s- i. E: @5 b# n r- x n$ ?5 B/ k8 n0 y
( |/ ^" R$ ?: E! g! T. o" z- char type_name[] = "Item";
0 m4 C1 k, ` j1 n4 w# J2 O - Teamcenter::CreateInput* itemCreateInput = static_cast<Teamcenter::CreateInput*>(Teamcenter::BusinessObjectRegistry::instance().createInputObject(type_name, OPERATIONINPUT_CREATE));
R5 f/ I1 P/ N3 \ U; _
8 A: G" a; @4 N6 ~- //Revision type name is not always <item type name>Revision
/ ]3 c, d' y$ l, `4 u, { - char *revision_type_name = 0;
6 J4 o3 `9 @7 c; t+ T - CONSTANTS_get_type_constant_value("ItemRevision", type_name, &revision_type_name);
/ m: _4 _8 p$ X4 R* t E
$ y2 J. O4 B) G: x- Teamcenter::CreateInput* revCreateInput = static_cast<Teamcenter::CreateInput*>(Teamcenter::BusinessObjectRegistry::instance().createInputObject(revision_type_name, OPERATIONINPUT_CREATE));3 z6 J( S8 ?2 \
- & \7 A9 q/ Y: k" y; \/ @; y/ m
- MEM_free(revision_type_name);* `+ f, v9 L: F6 Z/ m* |
- z5 L, ?$ d" i. N8 R* Y; o- // set Item properties, X, _/ ~# q; ]$ K( C1 M
- itemCreateInput->setString("item_id", "1234567", false);
' |+ c* G }+ w9 U4 A2 X - itemCreateInput->setString("object_name", "My Item Name", false);# g6 y, U# t1 s# W
- itemCreateInput->setString("object_desc", "My Item Description", false);( \) j/ f9 }% B& `" e8 X8 P
- itemCreateInput->setTag("revision", revCreateInput->getTag(), false);
5 h3 t* a9 p+ ^" s - 8 X2 l* d3 ]! ]3 ?+ S
- // set Revision properties
2 |: F6 B) S9 ~" b2 h- O3 N; m2 K9 G - revCreateInput->setString("item_revision_id", "00", false);5 Z. `2 E1 e' b
- revCreateInput->setString("object_name", "My Revision Name", false);
* C: a0 u; J9 D - revCreateInput->setString("object_desc", "My Revision Description", false); N& p) ?+ {$ x/ R
- ) \" ]' r! o; G
- Teamcenter::Item *pItem = dynamic_cast<Teamcenter::Item *>(Teamcenter::BusinessObjectRegistry::instance().createBusinessObject(itemCreateInput));
M0 ]7 x: t6 @# G$ y6 v - 5 S# }. K6 b8 \2 O" I
- ifail = AOM_save_with_extensions(pItem->getTag());/ o, p1 u3 d; o$ @. W# q" ?, |: c1 t
- / h% Z/ N p9 r" n% i- R Y
- // If the Revision is not saved it will inherit the Item's Name and Description.
/ n2 ]& }+ n' f' Z" i* ^% d - ifail = AOM_save_with_extensions(revCreateInput->getTag());$ L4 H0 R, u& k. ^$ M/ ~
- }
复制代码
, t- m! d( T0 U* g
0 U. B; o$ y2 v |
|