|
|
请使用QQ关联注册PLM之家,学习更多关于内容,更多精彩原创视频供你学习!
您需要 登录 才可以下载或查看,没有账号?注册
x
( \8 e1 i/ v/ J& f+ r( OTeamcenter C++二次开发源码分享:创建item和item版本
) J/ m h0 y! G3 W( e0 Z) h! M; P# y9 O& V/ M# x4 P
; h0 W3 r# t. [3 g, i4 ~9 `8 a; W- \* ^通过创建businessobject 指定的createinput 完成对象的创建3 P' }$ W+ g3 V) r
; u d& D+ }. }& U6 g1 t# G- D$ G8 A9 X$ A; d! ?' ~/ W
- #include <constants/constants.h>
0 g( l9 W* H8 D - #include <TCcore/Item.hxx>
+ k2 j2 `5 q4 s- v, X/ J5 w9 G4 U - #include <metaframework/CreateInput.hxx>
3 ?& u0 ?; o& y+ k5 B3 C - #include <metaframework/BusinessObjectRegistry.hxx>/ Z+ n- e: [5 ~! X7 @" N
- / r$ h6 S$ c+ G6 p) Q% @
- using namespace std;
7 E4 @8 j: U, y: i4 h! K. z
; e( Y+ d# O; y Y8 b- static void createItemAndRevisionWithDifferentNames(void)+ u6 \5 ]. l& H+ @& f4 d
- {
$ t) y. @ ?2 U. N3 R0 V* U - int ifail = ITK_ok;3 G% ^# \. |( [; F
( h* Q& e7 v, @. d$ i; I/ h% t- char type_name[] = "Item";
6 q2 D7 P6 U% f - Teamcenter::CreateInput* itemCreateInput = static_cast<Teamcenter::CreateInput*>(Teamcenter::BusinessObjectRegistry::instance().createInputObject(type_name, OPERATIONINPUT_CREATE));& M" V& C0 |: z4 G( {
- 3 ]$ W: ~9 X" t& q7 ]+ N
- //Revision type name is not always <item type name>Revision
; l9 x! H: m6 |1 \ - char *revision_type_name = 0;8 P s8 a* s$ [7 M8 o
- CONSTANTS_get_type_constant_value("ItemRevision", type_name, &revision_type_name);* @; L# `0 E6 r+ a. V6 v# @! Q
- % `+ B0 \( B5 Q# c+ d9 D
- Teamcenter::CreateInput* revCreateInput = static_cast<Teamcenter::CreateInput*>(Teamcenter::BusinessObjectRegistry::instance().createInputObject(revision_type_name, OPERATIONINPUT_CREATE));( P, M' \, t6 z% o
- & ?) n& Y1 I& u) v1 @1 C0 N
- MEM_free(revision_type_name);
* R1 }3 u" i1 n- {, t, K/ N - 2 U5 r7 ^+ f# x& U
- // set Item properties; {, X4 U. }3 L, s" i' g2 ` d
- itemCreateInput->setString("item_id", "1234567", false);
6 H8 t$ X1 l6 s. } ~2 F8 ? - itemCreateInput->setString("object_name", "My Item Name", false);
9 N" ]6 E6 A4 \$ A - itemCreateInput->setString("object_desc", "My Item Description", false);
7 Z) Y2 U3 z# e: u; \6 t' Y' I - itemCreateInput->setTag("revision", revCreateInput->getTag(), false);
- s* N3 T' E. `/ o8 g; O1 q0 o - 9 I6 u' ~1 _: l4 l& {9 c0 e
- // set Revision properties
( d: f( ]9 p+ [( l* \9 G - revCreateInput->setString("item_revision_id", "00", false);9 M6 Z: [3 t& l% N# x$ o& |$ B
- revCreateInput->setString("object_name", "My Revision Name", false);
- a& p8 c5 m0 m6 b. H; h9 P' P - revCreateInput->setString("object_desc", "My Revision Description", false); X1 z; {8 d1 W* C9 z" O2 }; D
- ( ?+ B# @$ f0 \2 _, `' K8 ~
- Teamcenter::Item *pItem = dynamic_cast<Teamcenter::Item *>(Teamcenter::BusinessObjectRegistry::instance().createBusinessObject(itemCreateInput));% e! W3 W; i% q* m1 F" r- N
" V) c) c" q# K# _8 |& Z- ifail = AOM_save_with_extensions(pItem->getTag());! U. r5 G8 f% i5 s: |$ o, K+ g5 X* H
- 8 h) ]# ^; _3 M0 X- G8 z2 M6 b
- // If the Revision is not saved it will inherit the Item's Name and Description.
. | v% m# a# T/ u2 I/ u* ` - ifail = AOM_save_with_extensions(revCreateInput->getTag());8 _, [) o$ ~8 X5 a6 c/ K
- }
复制代码 * [. g( c8 T7 j5 V
0 Q& v" h& M3 u: @
|
|