|
|
请使用QQ关联注册PLM之家,学习更多关于内容,更多精彩原创视频供你学习!
您需要 登录 才可以下载或查看,没有账号?注册
x
1 p& x. p, \/ w& x2 g q3 E
Teamcenter C++二次开发源码分享:创建item和item版本. K# c# k8 O7 s5 l
3 Y5 @; m, @2 x7 X0 J" k0 m5 J q D9 {" q0 Q
通过创建businessobject 指定的createinput 完成对象的创建1 z1 X3 W: o0 V+ D0 n6 d8 k
- d! o" B: t/ o3 `
8 Y8 }+ l; k7 j& v- #include <constants/constants.h>6 }9 j. q: G' @
- #include <TCcore/Item.hxx># B4 l( C& w. J1 j" K. T9 R
- #include <metaframework/CreateInput.hxx>8 V- M i/ h( h& t s* ^
- #include <metaframework/BusinessObjectRegistry.hxx>$ p, W& d- D* ]
- 1 F2 V9 S0 r& r7 j5 q# @* }
- using namespace std;
5 ~% C' ?3 k2 x6 t' W u! d* x3 S
0 b! a8 l4 @4 N) ^- static void createItemAndRevisionWithDifferentNames(void)
7 v+ e) n$ [2 }; I' G+ h - {' }( s" r! k' `. O
- int ifail = ITK_ok;
6 K5 f7 V/ a P: f& I, R$ y' E
1 E) Y+ h2 S6 w( U0 M v% q, a- char type_name[] = "Item";
4 j9 v2 ]3 j/ r) U) _3 h% q - Teamcenter::CreateInput* itemCreateInput = static_cast<Teamcenter::CreateInput*>(Teamcenter::BusinessObjectRegistry::instance().createInputObject(type_name, OPERATIONINPUT_CREATE));8 y! f1 Z- K3 o ^. b$ P
- : P$ Z3 M5 x4 }! l" V
- //Revision type name is not always <item type name>Revision. X8 S' d! G* P# J( N
- char *revision_type_name = 0;$ y7 g, T s! ]' v0 f
- CONSTANTS_get_type_constant_value("ItemRevision", type_name, &revision_type_name);
6 [& C3 C9 f- ^! n% o: P - : |' f( r* Y. i: X8 `4 i9 H
- Teamcenter::CreateInput* revCreateInput = static_cast<Teamcenter::CreateInput*>(Teamcenter::BusinessObjectRegistry::instance().createInputObject(revision_type_name, OPERATIONINPUT_CREATE));
+ P' m5 T5 G9 \' A9 l( z; l9 W1 r4 ? -
9 _6 D2 W+ k7 E* l2 q - MEM_free(revision_type_name);
6 M( y5 P1 N- i! P1 \6 q
k3 ^# v7 ?! {) T$ |; ]- // set Item properties
; }$ N$ k' i- e- i1 q, R - itemCreateInput->setString("item_id", "1234567", false);
8 n( k/ B+ l1 H: T' J ~$ J - itemCreateInput->setString("object_name", "My Item Name", false);$ B$ a( l3 {1 _% x# T
- itemCreateInput->setString("object_desc", "My Item Description", false);
- P; o# W- L8 y2 l& U - itemCreateInput->setTag("revision", revCreateInput->getTag(), false);
5 e4 S# u: e6 t' v1 x7 G - % e& X' i: e2 G2 s9 b" J _0 v
- // set Revision properties# [- y: G/ ?9 s; S
- revCreateInput->setString("item_revision_id", "00", false);
' K! n; M0 K; @! d# [* D. S - revCreateInput->setString("object_name", "My Revision Name", false); U! W% X8 [: ^4 c9 {
- revCreateInput->setString("object_desc", "My Revision Description", false);5 u1 _; }: X$ w- T" K; d
2 r& ~& C& ]& V; J( v. D k" G- Teamcenter::Item *pItem = dynamic_cast<Teamcenter::Item *>(Teamcenter::BusinessObjectRegistry::instance().createBusinessObject(itemCreateInput));
7 n+ a; W) d& f o5 _0 ] - , k1 q* u& `9 Q8 Q7 t
- ifail = AOM_save_with_extensions(pItem->getTag());0 ]+ R8 O; p* m6 j* {: ~* D, O. K; p; y
# p8 }5 b% w& d- // If the Revision is not saved it will inherit the Item's Name and Description.; a) g ?/ K1 `8 a4 V5 M2 e
- ifail = AOM_save_with_extensions(revCreateInput->getTag());8 T1 S8 Q2 M: J# b& Y. O9 u
- }
复制代码
' |/ E) F: E! w5 n$ h4 `5 m: I% g% M( v( J0 o$ C
|
|