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

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

[复制链接]

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

2470

主题

1275

回帖

8万

积分

管理员

PLM之家站长

积分
82172
QQ
发表于 2020-2-8 09:26:33 | 显示全部楼层 |阅读模式

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

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

x
2 N( g0 w6 i) `8 O9 k0 W
Teamcenter二次开发源码分享: 创建Item Create Item方法
+ i: q+ X2 S& W4 t, t* `3 i, s. y! k8 O5 N& F
[mw_shl_code=cpp,true]#include <TC/emh.h>
8 F9 X8 J7 _1 V#include <tc/tc.h>3 L1 Q- J  R+ i: F! {2 P0 c
#include <tc/tc_startup.h>
; f( p& F2 e. s#include <tccore/aom.h>
4 _" o8 d" O5 {  i4 q* ^1 U8 ~9 R& |' ]
#include <iostream>( }1 w& `* w7 o+ H) F
#include <base_utils/IFail.hxx>
8 G) i# q6 r6 ~; F0 }# y#include <base_utils/TcResultStatus.hxx>
$ ]7 h# T9 s3 f% k) P#include <metaframework/BusinessObjectRegistry.hxx>7 ?' w; A/ x, g4 U: {6 k
#include <metaframework/CreateInput.hxx>" _% I- T9 U+ T  v/ Q3 E9 A
#include <mld/logging/TcMainLogger.hxx>
' G, L" u. p' V2 S#include <tccore/Item.hxx>
  |! T! w% Y9 P2 W+ X8 u) Q. e% s/ b/ _' }7 A) _. x; z& p/ J) @( s7 l
using namespace std;4 p: @% m+ D. r1 p# [. d
using namespace Teamcenter;
9 I) F( \6 t. Ousing Teamcenter::Main::logger;
3 O/ ^6 v& g, f( @( v/ n* k5 u! P: G  L/ E
int ITK_user_main(int argc, char* argv[])
; Z; |6 ~+ L( N$ [! z{# d6 }  N: m- s/ L' x; M5 W* S, O
    int ifail = ITK_ok;% Q: V* \. [! Z; E  ?  I
    ResultStatus stat;
5 w* s' m7 F7 n( A, y$ N" U    try6 g& T0 s1 K2 h6 Z0 Q; \/ h2 q
    {% x- w  `; x. O( _- D: P2 L
        stat = ITK_initialize_text_services(ITK_BATCH_TEXT_MODE);         ; h/ q6 N, I" w8 ]% ^7 k& a' u
        stat = ITK_auto_login();                                          
1 Y9 b1 F" O  ]! a        stat = ITK_set_journalling(TRUE);; [7 R% j% W7 r0 t, w$ C7 d' m
( i9 u9 y2 W) f/ Z5 f
1 I5 }! }" d" @( G+ t5 x! P8 y
        BusinessObjectRegistry& boReg = BusinessObjectRegistry::instance();3 ^6 l( |4 D9 A3 L% F% {
        CreateInput* pCreateInput =
2 o2 ]. f) P; t0 H9 N( Q* h            dynamic_cast<CreateInput*>(boReg.createInputObject("Item", "Create"));2 r3 c, b) L4 S
% u5 B8 v! l% j7 E. P5 F( g7 y
        Item *pItem = dynamic_cast<Item *>(boReg.createBusinessObject(pCreateInput));$ r8 U( f# h( s$ B: x" K

( S! V4 J: j$ G* ^! d8 `; S% j  n        tag_t tItem = pItem->getTag();
6 A$ u3 w& {* O" h4 f- Y6 S/ N3 ?+ G, ]4 @  N8 l% ~
        string sId;9 m/ k2 d4 n! ]  S& x2 q
        bool isNull = false;
  Q, w4 E% z+ p) _        pItem->getItem_id(sId, isNull);
+ u% J8 ?: W( ~" h        
3 l  B& l: H4 k* z& Y& ?        pItem->setObject_name(sId, isNull);2 d; O; J5 C1 o& s9 Z8 V
        * j; C6 T: h2 }# ?
        stat = AOM_save_with_extensions(pItem->getTag());
" W+ ]! R0 ~' q* O7 M& D8 t& D; V2 j+ Z8 f& d6 Y- Z6 P6 d5 Q
        cout << endl << "    ID: " << sId << endl << endl;% g% U; Y! [/ {8 u3 d- r. i
    }
! R# c1 G9 s' x! b* E    catch( const IFail &ex )
+ s2 r8 h2 X- ~/ h    {
$ ]. c3 L  Q2 `/ v% s        logger()->error( ex.ifail(), ex.getMessage());
. Y3 P5 x" _  C( f1 Z        cout << ex.getMessage()  << endl;( M, l7 I1 H- L, t
        cout << "error " << ex.ifail() << endl;        
; B# a6 d$ Q3 Q$ F+ j) s0 _    }' c& N9 q! F+ M% T0 x
    const char* syslog_path;
! m: m& J  O/ c$ f# `' D/ A    syslog_path = EMH_ask_system_log();& Q; ?. |- Z3 Y" i* U2 r
    cout << endl << endl;
; J0 M2 j3 z9 ?9 c0 R    cout << syslog_path << endl;. I' m. N1 |: a# |& E. u: Z1 L
3 t$ f& i: D/ |( J
    stat = ITK_exit_module(FALSE);                                        0 c! r9 v! I/ n( g% x
    return ITK_ok;, v0 s8 r& E6 c$ E: Z
}[/mw_shl_code]
6 j2 a; n6 U* ?; @" L, I' u6 q; J6 _0 n
上海点团信息科技有限公司,承接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二次开发专题模块培训报名开始啦

    我知道了