|
请使用QQ关联注册PLM之家,学习更多关于内容,更多精彩原创视频供你学习!
您需要 登录 才可以下载或查看,没有账号?注册
x
; S$ L0 L9 r* |* p* G' Z( q
Teamcenter C++二次开发源码分享:创建item和item版本
) X. W: q4 l6 w: _( G
2 V( ], `! M6 r: B a) v o g* W
! ?4 J# S0 U* @0 E! e7 P" ?通过创建businessobject 指定的createinput 完成对象的创建. }$ y9 G& e' [- `/ ^3 H
3 j5 p; k* D& z/ K8 W c: E- c9 v6 }8 j8 ?# t; v* ~1 h, @1 p
- #include <constants/constants.h>
! `4 V5 ?' b; P2 O f) G - #include <TCcore/Item.hxx>( k# v5 z% r% `! [/ q% T+ W# K
- #include <metaframework/CreateInput.hxx> X" g6 M5 X# P9 c- L
- #include <metaframework/BusinessObjectRegistry.hxx>
; a$ N) o: t! q4 ~
& P6 Z6 T1 Q" X; w: l! l( m- using namespace std;" q2 ?* g% j* |
2 h. V; I9 c6 G% H+ e- static void createItemAndRevisionWithDifferentNames(void)
" ^5 t0 N4 N1 O8 u8 {0 N* P - {
+ l \! X1 X6 E' w - int ifail = ITK_ok;, b8 b' |- k1 K; H
- 4 r1 l" o: u/ w# A G" G
- char type_name[] = "Item";
+ i; T6 L0 U2 X$ L4 K5 Z - Teamcenter::CreateInput* itemCreateInput = static_cast<Teamcenter::CreateInput*>(Teamcenter::BusinessObjectRegistry::instance().createInputObject(type_name, OPERATIONINPUT_CREATE));
( p% A/ Q# R5 [; q# C% \7 I* S
! m0 \% O' A: C. ^- //Revision type name is not always <item type name>Revision
' C/ r! f9 e) U/ p4 l0 V - char *revision_type_name = 0;; s2 x( V V3 N
- CONSTANTS_get_type_constant_value("ItemRevision", type_name, &revision_type_name);
( ]' G1 o( w6 F7 i- M3 {" e - 4 w! |! K4 m: _, @* {
- Teamcenter::CreateInput* revCreateInput = static_cast<Teamcenter::CreateInput*>(Teamcenter::BusinessObjectRegistry::instance().createInputObject(revision_type_name, OPERATIONINPUT_CREATE));1 t& U: H4 c% r3 A
-
5 |$ Y# }3 j3 w# {% o; V9 o4 z - MEM_free(revision_type_name); l) @0 {; V7 [1 a2 @
- 3 l. l% B* ^, y( p
- // set Item properties
/ |: z8 y0 b! {) W$ E - itemCreateInput->setString("item_id", "1234567", false);
: Y; @$ J; @6 v( G/ s - itemCreateInput->setString("object_name", "My Item Name", false);2 p/ Y8 g' }7 L6 ?, {' r# z5 s( x
- itemCreateInput->setString("object_desc", "My Item Description", false);
}' `7 H3 r& q$ D- F4 b" @ - itemCreateInput->setTag("revision", revCreateInput->getTag(), false);
/ d& f- [& {% [" H( n" R6 i) Z3 T9 @
& D4 \) x) v, y$ }0 w% f" E9 S# `- // set Revision properties
2 U4 U! t& @1 ` - revCreateInput->setString("item_revision_id", "00", false);( \: Y B9 v" R! Q
- revCreateInput->setString("object_name", "My Revision Name", false);+ d* P) g& [% {
- revCreateInput->setString("object_desc", "My Revision Description", false);
! M) m% G, \) m- G
0 c' t& y `8 F* f# Q0 m3 E- Teamcenter::Item *pItem = dynamic_cast<Teamcenter::Item *>(Teamcenter::BusinessObjectRegistry::instance().createBusinessObject(itemCreateInput));! z& v1 b! ]0 P3 j1 ^
- - l+ P: G7 p9 ]
- ifail = AOM_save_with_extensions(pItem->getTag());
3 m! i# ] _. Y5 ]
: h/ o8 O- X8 V( H- // If the Revision is not saved it will inherit the Item's Name and Description.: t9 T4 l# M' t8 `
- ifail = AOM_save_with_extensions(revCreateInput->getTag());/ D2 Z0 v- B- `: u
- }
复制代码 3 {% B; H! m/ Z
" ?, W0 \( F- S9 N1 }' ^" G
|
|