|
请使用QQ关联注册PLM之家,学习更多关于内容,更多精彩原创视频供你学习!
您需要 登录 才可以下载或查看,没有账号?注册
x
% s* l) e: \. c$ e' _% K
Teamcenter C++二次开发源码分享:创建item和item版本- S. ~' `8 Z& b7 [! f8 k$ s$ R
7 @- r; s" d% t: h" E
3 f' p# ]: Q( t" h1 a0 U
通过创建businessobject 指定的createinput 完成对象的创建
9 ?/ y( l6 d$ m. }+ F, T, _$ F& q% S, _5 N4 v5 O! J* s
6 o8 E9 k; f* K4 q9 E- #include <constants/constants.h>6 u9 D* y9 H, r1 b" j, {" b
- #include <TCcore/Item.hxx>
- y1 l* S: t0 D, y5 ~9 i - #include <metaframework/CreateInput.hxx>
2 A t! m$ R* B3 H! d! l - #include <metaframework/BusinessObjectRegistry.hxx>
, x W3 R5 q" M
3 L' b# Q9 k% O3 `! D, J- using namespace std;
% c: a! F& v* M+ |9 t8 S0 C
- O# x2 J6 `' ^% `1 H" \9 }. m9 B7 G- static void createItemAndRevisionWithDifferentNames(void)0 P6 D$ o+ U0 _
- {9 T, z9 d i% s+ u& L6 h
- int ifail = ITK_ok;
4 D* ~: L2 ?% q3 `, Q1 G
5 ^% B5 _" z$ U" ?0 S% c- char type_name[] = "Item";$ _0 y! B, ]+ F7 ]+ p* X% C3 Q
- Teamcenter::CreateInput* itemCreateInput = static_cast<Teamcenter::CreateInput*>(Teamcenter::BusinessObjectRegistry::instance().createInputObject(type_name, OPERATIONINPUT_CREATE));
! V% ?0 a, r: |! c
D; b4 N) P. o0 F- //Revision type name is not always <item type name>Revision( E+ a- p$ c- F% C. @' u! p
- char *revision_type_name = 0;
5 _' D. Q+ j% W2 { - CONSTANTS_get_type_constant_value("ItemRevision", type_name, &revision_type_name);
5 F% j5 I# S7 K
]/ v( `6 ?9 V8 y8 l6 N- Teamcenter::CreateInput* revCreateInput = static_cast<Teamcenter::CreateInput*>(Teamcenter::BusinessObjectRegistry::instance().createInputObject(revision_type_name, OPERATIONINPUT_CREATE));- P3 c0 \8 X% ~. w; \! l( X) H
-
7 {6 b1 H I0 r - MEM_free(revision_type_name);
3 Q# X, Z9 Z$ y" E$ J - z" u1 Y1 ~" w* p
- // set Item properties
# @2 f+ D% `5 }7 T( x - itemCreateInput->setString("item_id", "1234567", false);9 z0 N* J$ W$ r# o1 i
- itemCreateInput->setString("object_name", "My Item Name", false);7 U9 n+ R2 p$ Y) u" ~: n0 ?
- itemCreateInput->setString("object_desc", "My Item Description", false);
: ~6 ^3 x9 Q. @, m - itemCreateInput->setTag("revision", revCreateInput->getTag(), false);
* i+ x+ I! R4 _* M& _4 a - ) M/ Z4 U7 e2 h! h
- // set Revision properties, {# m* y! x# O+ f
- revCreateInput->setString("item_revision_id", "00", false);+ Q. y- k* w) D- X
- revCreateInput->setString("object_name", "My Revision Name", false);) u. C. W: Q! p* K
- revCreateInput->setString("object_desc", "My Revision Description", false);7 W3 z- c* ^% N1 U2 K! M7 h3 B% Z2 c
- T3 u/ z7 M( v& |4 ~- Teamcenter::Item *pItem = dynamic_cast<Teamcenter::Item *>(Teamcenter::BusinessObjectRegistry::instance().createBusinessObject(itemCreateInput));# T: B y/ B7 S4 s J
0 U. _; O/ m, X- }- ifail = AOM_save_with_extensions(pItem->getTag());1 x/ t% @$ W3 y! q5 }) b% d$ r
- $ R1 z5 Z* I6 U6 H8 Z' l0 q7 H/ D
- // If the Revision is not saved it will inherit the Item's Name and Description.2 }8 c- E' U+ a5 N/ l% b) e* F) W3 V
- ifail = AOM_save_with_extensions(revCreateInput->getTag());! i$ v/ f/ W- V( {1 ^& S G6 k
- }
复制代码
; Y2 I2 O. l ]# a2 Y* _5 g% u, [/ h1 F2 Z- ?4 C# L
|
|