PLM之家PLMHome-工业软件践行者

Teamcenter二次开发源码分享: 创建Item Create Item方法

[复制链接]

2020-2-8 09:26:33 2186 0

admin 发表于 2020-2-8 09:26:33 |阅读模式

admin 楼主

2020-2-8 09:26:33

请使用QQ关联注册PLM之家,学习更多关于内容,更多精彩原创视频供你学习!

您需要 登录 才可以下载或查看,没有账号?注册

x

! d  T8 J) b& z* PTeamcenter二次开发源码分享: 创建Item Create Item方法! U6 ^/ |- C8 M% e  j) a

4 `# _( f3 q  E& y[mw_shl_code=cpp,true]#include <TC/emh.h>) Z, |8 H4 T5 y& {$ y; v& ]
#include <tc/tc.h>
. _* d/ D$ K) Z8 l+ Y#include <tc/tc_startup.h>. w; V7 N, t8 l$ b6 U. y
#include <tccore/aom.h>( w' w" d' `- t1 L# E1 j3 X  ]! u

; `/ _' s3 N, J#include <iostream>' u; t# I2 |! u* X( l  d/ {2 r
#include <base_utils/IFail.hxx>
( A5 B& ]5 g& D2 @% c#include <base_utils/TcResultStatus.hxx>( D! p8 ]4 t' V& F4 T7 X
#include <metaframework/BusinessObjectRegistry.hxx>  n. P" P' v+ z% p7 h
#include <metaframework/CreateInput.hxx>
9 i8 Y$ J2 P4 O$ E#include <mld/logging/TcMainLogger.hxx>
; Z& y# d$ T5 }#include <tccore/Item.hxx>
5 }+ w0 ~3 D+ [3 p! z- Z6 l# _$ W8 k  Z+ |8 `- P7 \
using namespace std;' j9 z. _7 H. {7 c( o
using namespace Teamcenter;
' e- p# z" w2 ~5 a6 o% t/ r5 g! wusing Teamcenter::Main::logger;
% M0 ~$ S2 k# u7 v" Q) Z) t# e5 a7 `% h8 N$ p: S5 L* d
int ITK_user_main(int argc, char* argv[])
* J: n$ w7 A: a! J0 j+ U{
1 h# y% u; v& a3 F; i" G, S    int ifail = ITK_ok;2 Z& ~/ q. R; y- L$ r4 V) D
    ResultStatus stat;
! W# Y! v- E2 t, K" ]6 B) d6 X% D    try: g; M, Y: V3 q
    {
* `: E% H9 r8 j9 f! l% B: X        stat = ITK_initialize_text_services(ITK_BATCH_TEXT_MODE);         4 L. L  [* P+ ^& A0 e7 r% L7 a
        stat = ITK_auto_login();                                          - O) P+ d: ]8 x
        stat = ITK_set_journalling(TRUE);0 M- E" h# q4 K: i& |

" c3 K' o; d. N2 M1 `9 t; ?& ~8 h( A; m" B" ^* u1 `1 k3 c
        BusinessObjectRegistry& boReg = BusinessObjectRegistry::instance();( C/ p5 K: K( q2 S. }
        CreateInput* pCreateInput = 1 V3 w$ O! V5 ^
            dynamic_cast<CreateInput*>(boReg.createInputObject("Item", "Create"));( R1 G! _9 E) P8 g5 G0 o7 m
' C5 u9 [. u0 Z
        Item *pItem = dynamic_cast<Item *>(boReg.createBusinessObject(pCreateInput));& \# v- X' A; Q4 e0 P$ f

- V$ i% h3 @: Z) ~. g' I        tag_t tItem = pItem->getTag();
- U, q1 v3 M" m- r) s1 R7 U- J9 l. J" a6 e* L& z
        string sId;8 e% X6 D# w1 C; J! w
        bool isNull = false;
: G2 W. e2 R9 I        pItem->getItem_id(sId, isNull);7 b- B* k% o4 V( \0 d& G7 \; [
        $ F" }- \4 K7 k+ p( b
        pItem->setObject_name(sId, isNull);) H6 r& Q% Q' E+ n% R! ]' j
        ' [: T9 Y4 J" B, ?" U6 R! n
        stat = AOM_save_with_extensions(pItem->getTag());9 a, ~4 B1 l* G5 F% @$ @
9 D- R  H8 u: T$ A- t$ k
        cout << endl << "    ID: " << sId << endl << endl;
- }0 C5 y* |5 E5 H0 f, u9 k    }
, C5 `& ~- p3 _8 m6 X* C0 c- n; m    catch( const IFail &ex ): f7 B+ H4 Q# d; F
    {
* [. M# R8 J# d: c        logger()->error( ex.ifail(), ex.getMessage());5 ~9 c, `. _) ~) y/ P# Z+ _# j
        cout << ex.getMessage()  << endl;
) D6 x. `- T& N6 a- N( s- c( Q        cout << "error " << ex.ifail() << endl;        & T4 J* R' M3 ~- {$ y" }
    }/ i+ t4 F2 A1 ^2 R% M% c; z" p
    const char* syslog_path;
/ D8 B& a# G* l/ l% x    syslog_path = EMH_ask_system_log();
  A$ _# Q0 V- x( h" n2 a    cout << endl << endl;$ y( k0 M: P3 s1 U- ?8 N0 |
    cout << syslog_path << endl;+ T; ~! c  ?, `, @) c$ O
, g9 D+ N4 v( Y1 x. }, d: ?1 {" F
    stat = ITK_exit_module(FALSE);                                        " [! u0 W' `( J0 p3 c; q% }  y
    return ITK_ok;
  Z( h" {' R7 O; b; G; D2 ~4 {' ^1 s  M}[/mw_shl_code]8 k  m' e! P, Y7 s$ i$ A
上海点团信息科技有限公司,承接UG NX,CATIA,CREO,Solidworks 等CAx软件,Teamcenter,3D Experience等PLM软件,工业4.0数字化软件的实施\二次开发\培训相关业务,详情QQ 939801026 Tel 18301858168 网址 doTeam.tech
回复

使用道具 举报

发表回复

您需要登录后才可以回帖 登录 | 注册

返回列表 本版积分规则

  • 发布新帖

  • 在线客服

  • 微信

  • 客户端

  • 返回顶部

  • x
    温馨提示

    本网站(plmhome.com)为PLM之家工业软件学习官网站

    展示的视频材料全部免费,需要高清和特殊技术支持请联系 QQ: 939801026

    PLM之家NX CAM二次开发专题模块培训报名开始啦

    我知道了