|
|
请使用QQ关联注册PLM之家,学习更多关于内容,更多精彩原创视频供你学习!
您需要 登录 才可以下载或查看,没有账号?注册
x
. d* w$ r4 t2 `3 b* p
Teamcenter C++二次开发源码分享:创建item和item版本: L; L! g( J5 n# j5 z( A4 X# U3 R, G. ?
8 ?, H5 {* e: C7 L' R
: l+ a5 o) T' Y5 n4 U通过创建businessobject 指定的createinput 完成对象的创建& R* a6 Q) g, n) u1 B4 @
( L! f" z9 \: G) o' |7 |6 X) o# m) t6 f6 Q! e: d
- #include <constants/constants.h>
& y7 U3 j- P+ h& B$ N - #include <TCcore/Item.hxx>5 c! `; e/ Q! G+ P5 c- _
- #include <metaframework/CreateInput.hxx>
6 U4 _) f! n z4 x& g3 ]: W6 U - #include <metaframework/BusinessObjectRegistry.hxx>. J; }- ?. E. D5 y+ ?) L6 v, U
7 q; ^1 @: s& |, Z# j1 u- using namespace std;6 Q, b7 r) V* |
- ) j$ c% E( i3 T" [
- static void createItemAndRevisionWithDifferentNames(void)
! B6 E9 t' R, L7 s8 _ - {
# U. x! G# P1 q' P - int ifail = ITK_ok;
0 d; g# `9 l) i
$ w0 P& r( m5 b0 k- char type_name[] = "Item";6 L: [2 g; s i g2 T$ q5 T
- Teamcenter::CreateInput* itemCreateInput = static_cast<Teamcenter::CreateInput*>(Teamcenter::BusinessObjectRegistry::instance().createInputObject(type_name, OPERATIONINPUT_CREATE));
2 {3 W, b- v, ^0 A0 S3 j, _+ d - : \8 h3 K( n. L+ L$ w' e5 V" b
- //Revision type name is not always <item type name>Revision
$ j: [/ z6 Z( A1 N - char *revision_type_name = 0;4 x2 r: |; u9 ^; g# z9 g
- CONSTANTS_get_type_constant_value("ItemRevision", type_name, &revision_type_name);
8 S1 g- o3 d5 o9 {6 U' z% v n/ E
3 B, L* }: g' Z/ I- Teamcenter::CreateInput* revCreateInput = static_cast<Teamcenter::CreateInput*>(Teamcenter::BusinessObjectRegistry::instance().createInputObject(revision_type_name, OPERATIONINPUT_CREATE));0 y0 Z4 b( G' G9 y; f F9 I4 [ Q
-
4 Z: x7 ~$ A; }5 g# S( H6 B5 K - MEM_free(revision_type_name);
9 ^* N. ^: {3 w4 P - ' o. ` X% X0 `6 c- Z) G
- // set Item properties4 N" z3 W4 h) b- g1 \6 ]- F
- itemCreateInput->setString("item_id", "1234567", false);$ v ]6 C) Q( v% o& R
- itemCreateInput->setString("object_name", "My Item Name", false);! C0 Z: c. a; l+ W9 B
- itemCreateInput->setString("object_desc", "My Item Description", false);
. ^/ p0 n5 @2 ^; Z: U5 ? - itemCreateInput->setTag("revision", revCreateInput->getTag(), false);
, z! U' x' Z- a' s6 { - : G# p2 p5 T, N8 ?/ U, M
- // set Revision properties
' U; A1 ?: f8 S. T2 r* i - revCreateInput->setString("item_revision_id", "00", false);
! c& H+ _% s: h" ~+ n: u% A - revCreateInput->setString("object_name", "My Revision Name", false);
2 E& O/ O ]7 Q9 g9 [3 `6 n0 r - revCreateInput->setString("object_desc", "My Revision Description", false);
, A4 [& K+ \ {% y( @6 v - % L7 J; e% n' S9 x5 k
- Teamcenter::Item *pItem = dynamic_cast<Teamcenter::Item *>(Teamcenter::BusinessObjectRegistry::instance().createBusinessObject(itemCreateInput));
! A' T: N3 K3 D9 I6 w4 k# W: T
" P: {( `! T$ ?* e; b( n. Q/ }% U- ifail = AOM_save_with_extensions(pItem->getTag());
2 J1 b) ^; X8 C6 e( Y) o
) j0 z& J. Z- h8 V- // If the Revision is not saved it will inherit the Item's Name and Description.
, e- T9 O5 ?, }+ ]2 e - ifail = AOM_save_with_extensions(revCreateInput->getTag());) }5 i& f2 w. `# M6 N4 G, C) e2 k
- }
复制代码 Z. R- {0 C P" s) }
' b+ l4 W* b/ @ }6 W |
|