PLM之家PLMHome-国产软件践行者

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

[复制链接]

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

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

admin 楼主

2020-2-8 09:26:33

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

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

x

  R1 n5 q  ~2 c9 @; Y# H6 `# |Teamcenter二次开发源码分享: 创建Item Create Item方法
/ r& {3 U: t( T- ]. r, \- [# [* H1 V' G
[mw_shl_code=cpp,true]#include <TC/emh.h>; a2 F( o$ M5 U
#include <tc/tc.h>
7 Z+ w% J! n3 b/ n, |; O- p9 {" N9 y#include <tc/tc_startup.h>( ?6 X* G9 w# X5 d! r
#include <tccore/aom.h>
! D1 [' ], G3 ~- @$ A& |, x; n
& o8 E1 ?# L. @- ^' i#include <iostream>2 M- `4 C- d' Y& P
#include <base_utils/IFail.hxx>! ~+ ~" S( d# H0 C" T
#include <base_utils/TcResultStatus.hxx>
& C1 G) G% q5 c1 ^: n, Z#include <metaframework/BusinessObjectRegistry.hxx>% q3 z% m3 X( Q; p
#include <metaframework/CreateInput.hxx>
# ]+ C( B: ]0 Z2 u) q7 x#include <mld/logging/TcMainLogger.hxx>
+ K3 j! O' u' L) q9 s* ^#include <tccore/Item.hxx>
; T" f. V. O& `- v6 S1 F  Z" D, O9 d; A- h* F6 K: o3 u
using namespace std;4 R- ^9 _" [8 _6 i
using namespace Teamcenter;
( u& P, ^% q! uusing Teamcenter::Main::logger;- O- U3 o+ [4 a: x7 J4 k+ ~

" c* b: x2 h* b6 eint ITK_user_main(int argc, char* argv[])
% L" u9 w. q2 y. g9 D{' ~* n- [; o% A4 P# h" X- {7 e% n
    int ifail = ITK_ok;
5 w7 P" B4 z1 v4 M5 Q    ResultStatus stat;
5 z5 f$ ?' h+ {" d1 j% R, v    try/ r; E* l! S8 B  u- l$ @3 |
    {# a2 ?" l: o8 Q5 N. c2 h# x. h8 b
        stat = ITK_initialize_text_services(ITK_BATCH_TEXT_MODE);         8 z$ v: E3 n% n5 K3 I
        stat = ITK_auto_login();                                          3 y0 c1 R. j- v( {. D) \! p
        stat = ITK_set_journalling(TRUE);
# Q: [3 ^" z" `: Z% ~. t: ~$ l
; ?; z6 a0 b3 q& D$ L5 \4 \9 \" Z3 j& T2 \, H
        BusinessObjectRegistry& boReg = BusinessObjectRegistry::instance();
/ G& S# v- u# b4 u        CreateInput* pCreateInput = 9 f# B: w/ E9 F
            dynamic_cast<CreateInput*>(boReg.createInputObject("Item", "Create"));( P* ?( D1 a, g$ X# w- m; K1 R

4 d& U; A) H: k4 {4 Q2 _* {        Item *pItem = dynamic_cast<Item *>(boReg.createBusinessObject(pCreateInput));( m0 P) _* f* j  F
( u. T' q! Q- h3 Z" \
        tag_t tItem = pItem->getTag();: y. a3 }' r% h2 ]* I% S( s5 q

- U1 ]6 h1 N$ X2 Q. _        string sId;
! [3 R) D' W# O        bool isNull = false;
. t) K5 d" W. |8 E/ |3 C        pItem->getItem_id(sId, isNull);
3 V% U: U; k* q/ E6 L4 }& A        
* R% Q. l* U! a5 \: U' y3 R        pItem->setObject_name(sId, isNull);
6 k1 e3 z6 `8 \: T) X; }- I        
( Z/ D0 [, f: K8 g! E+ T  s        stat = AOM_save_with_extensions(pItem->getTag());
: c. M0 Z6 G  P1 t* i; {
+ v; R% E' N$ U, s0 D4 G& w4 X        cout << endl << "    ID: " << sId << endl << endl;2 y- o! q* q- j) h* ?
    }
+ ?) S9 x2 A7 n+ o. O    catch( const IFail &ex )) t8 m2 \) b/ |* B  Y
    {
0 Z, j% f6 K/ h8 H/ e$ q: N        logger()->error( ex.ifail(), ex.getMessage());9 K$ t; {6 m8 K1 F, X/ |# Q
        cout << ex.getMessage()  << endl;
1 ~0 e" J; B; I* s  {, Z7 v, \        cout << "error " << ex.ifail() << endl;        ) A, v9 `8 C% \6 Z, Q
    }) x: g8 A3 x. N0 T
    const char* syslog_path;5 \0 V6 i9 U- Z4 E0 R" j
    syslog_path = EMH_ask_system_log();! \' ]$ R, o/ ~# u7 R
    cout << endl << endl;7 \9 {" p( V, ~% b) G, Y
    cout << syslog_path << endl;* e- B: S3 N8 }7 R) n) K+ r2 U

0 B' @2 Z4 b* }    stat = ITK_exit_module(FALSE);                                        ) y5 p7 o5 p- u9 F7 y
    return ITK_ok;
8 v! p' }* A% D- r/ N# T5 L}[/mw_shl_code]
7 Z1 c. q5 e1 d3 N2 R% V' 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二次开发专题模块培训报名开始啦

    我知道了