|
请使用QQ关联注册PLM之家,学习更多关于内容,更多精彩原创视频供你学习!
您需要 登录 才可以下载或查看,没有账号?注册
x
5 K2 u( Q) j+ w. \Teamcenter C++二次开发源码分享:创建item和item版本
4 c2 y. n& Q% e& ?: Z' d& w5 p+ R
$ [4 o/ X* D; G$ ^, C' b P* v通过创建businessobject 指定的createinput 完成对象的创建
1 c* k/ B3 P/ d9 L; \. {% w7 W% a5 l% `3 @
% ?) `. s! N. L* ?. Y% ?: D5 P/ M5 f
- #include <constants/constants.h>
) I) j$ R$ b2 |, U3 i - #include <TCcore/Item.hxx>
( g6 R. n) S5 ]1 F0 [ - #include <metaframework/CreateInput.hxx>; }: ?2 C+ [, Q; W+ P: t* B7 Q
- #include <metaframework/BusinessObjectRegistry.hxx>1 }8 a* `. X& u( L A
- 4 c; \1 ^) Q( d' T
- using namespace std;
1 ]+ X0 s" z1 A+ d& r# z$ a - ( u3 S S0 [2 x- D. p% F0 q$ ]
- static void createItemAndRevisionWithDifferentNames(void)
7 L: e# A3 n' C" ?" l, D - {4 {' T! |0 C$ b( `. Y5 v8 B
- int ifail = ITK_ok;
9 W$ G: s1 w; N1 J% _/ ]( F
8 M" c) K; k) ^: H7 @& z- char type_name[] = "Item";; c7 D3 x7 R% b% U) i# D: O
- Teamcenter::CreateInput* itemCreateInput = static_cast<Teamcenter::CreateInput*>(Teamcenter::BusinessObjectRegistry::instance().createInputObject(type_name, OPERATIONINPUT_CREATE));
* \4 p8 [; O5 U# q9 Y2 R - 6 [$ t8 H$ |; u- |9 ]0 i$ Z
- //Revision type name is not always <item type name>Revision
# H X4 x' n. \, n- X- ? - char *revision_type_name = 0;( C5 G: `3 O* Q7 W8 |) s: J/ _
- CONSTANTS_get_type_constant_value("ItemRevision", type_name, &revision_type_name);
* l% {' n" r9 k) Y! n& I - ( ?7 c" o- ?, B& Y/ b2 L
- Teamcenter::CreateInput* revCreateInput = static_cast<Teamcenter::CreateInput*>(Teamcenter::BusinessObjectRegistry::instance().createInputObject(revision_type_name, OPERATIONINPUT_CREATE));9 U/ w' Q0 u( j4 q
-
; `( ^3 f1 z& i: e, O- B6 _) Q - MEM_free(revision_type_name);
: U5 K% V5 v1 W1 Z4 ]6 ?7 G - @! I& }# o$ p3 [
- // set Item properties& r$ Y! o1 d0 @0 n! V2 E' I
- itemCreateInput->setString("item_id", "1234567", false);% j" b8 J8 w' N' E% E# L
- itemCreateInput->setString("object_name", "My Item Name", false);
5 L2 |6 U7 z$ U4 f - itemCreateInput->setString("object_desc", "My Item Description", false);9 h7 T: X$ i9 o0 {- }6 D4 [+ X3 }
- itemCreateInput->setTag("revision", revCreateInput->getTag(), false);7 } Y% g8 c& g, j( O; J
) F, V- |6 D' D* y4 m% O- // set Revision properties4 k2 x6 L+ `3 s* u8 M' S
- revCreateInput->setString("item_revision_id", "00", false);
% w3 [0 t6 D; B% b - revCreateInput->setString("object_name", "My Revision Name", false);
% e, {, M5 b7 X& t6 n% x! w - revCreateInput->setString("object_desc", "My Revision Description", false);/ ~3 t: r4 N3 c7 h
- ' n- S9 w) I- q, K5 e
- Teamcenter::Item *pItem = dynamic_cast<Teamcenter::Item *>(Teamcenter::BusinessObjectRegistry::instance().createBusinessObject(itemCreateInput));, q5 z( Z" J( y+ z/ e
- 2 l$ P5 f; Y" |, |& E, b
- ifail = AOM_save_with_extensions(pItem->getTag());
& w: U! |0 H2 ~* k* A' z; i - * V3 h8 T- ]9 T
- // If the Revision is not saved it will inherit the Item's Name and Description.+ a+ S1 H! {1 e# l r
- ifail = AOM_save_with_extensions(revCreateInput->getTag());4 J+ W6 M! ~9 Y* A3 ~) P5 n
- }
复制代码
1 B1 {. t" d4 a, A$ b+ X' I( N$ { n- e, Z+ w; [
|
|