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

Teamcenter二次开发源码分享: Revise 版本 升级版本方法

[复制链接]

2020-2-8 09:27:38 3007 0

admin 发表于 2020-2-8 09:27:38 |阅读模式

admin 楼主

2020-2-8 09:27:38

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

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

x

/ i6 H6 N5 L9 rTeamcenter二次开发源码分享: Revise 版本 升级版本方法6 J% @- a& K" }; |7 O8 U5 E/ U

0 d+ w* j, f% f+ F7 `5 q( T# \: C$ C' F3 h; W  u& g2 S% x8 ]
[mw_shl_code=cpp,true]#include <TC/emh.h>
# }$ j8 t, ]' ^+ d/ G3 |" J#include <tc/tc.h>/ l3 `' o; }, B2 ^7 t+ J
#include <tc/tc_startup.h>  {+ W  }4 d: p7 l
#include <tccore/aom.h>
% a" z( u5 z; x* C, }0 w8 P#include <tccore/item.h>
2 t6 k: l* g8 i/ }# O" a: n
6 v3 x. Y: k% ^$ |& L- m- x$ {- C. G/ ~#include <iostream>, q+ f: z% m+ u7 L, R4 p4 Y
#include <vector>
0 K0 Z) x: Z/ ^#include <base_utils/IFail.hxx>; b4 M7 J( j2 [) L
#include <base_utils/ScopedSmPtr.hxx>5 i7 Q9 @) a9 }* b
#include <base_utils/TcResultStatus.hxx>6 z1 ^+ ^1 ]7 U/ h  |
#include <metaframework/BusinessObjectRegistry.hxx>$ A, ^  E  j- I' z9 {
#include <metaframework/ReviseInput.hxx>
& x! a) g# r$ c#include <mld/logging/TcMainLogger.hxx># M7 p5 s) O3 P' ?2 d
#include <tccore/ItemRevision.hxx>8 w( ?, b- w5 C! Z) F0 Z1 u
#include <metaframework/BusinessObjectRef.hxx>. `9 y3 z8 }' K9 N& d
#include <metaframework/BusinessObjectRegistry.hxx>, B( A% f( `# S
#include <metaframework/ReviseInput.hxx>
- N, X- k% c- K
4 ]1 u+ Y8 M' ?. @  C* nusing namespace std;
& `8 F9 A4 Z6 t$ Susing namespace Teamcenter;
5 a6 ]( K4 y: u* R, g2 o- U8 dusing Teamcenter::Main::logger;/ {* v) F( k7 p
$ G$ t) x6 a  R  s+ U1 _
int ITK_user_main(int argc, char* argv[])
& N' g2 i7 V/ W+ n+ I8 _" m{0 C: p3 w2 k' ^+ ^" c% F; n: v
    int ifail = ITK_ok;( o0 U8 T5 g+ T$ O* @9 M' a( T# t
    ResultStatus stat;: O+ d3 N8 |8 \. f* |
    try+ B( M' a7 Q4 |( `+ @
    {
7 h5 z8 z3 T1 t5 s. V" l7 H        stat = ITK_initialize_text_services(ITK_BATCH_TEXT_MODE);         & O+ Y4 ^1 G7 P& A
        stat = ITK_auto_login();                                          7 h$ i- b/ ~' W7 b! z) ?
        stat = ITK_set_journalling(TRUE);' }/ X# h" f1 p. Y
        " [; b. ]( B2 D4 i
        char item_id[ITEM_id_size_c +1] = "0000000";2 p- r# M3 P3 _6 T' n
        char *i = ITK_ask_cli_argument("-i=");
0 p7 |1 ?& @- N$ U; \  X. s        4 N) [* M3 U% d) [& i7 y) P0 j* C
        if (i != NULL) strcpy(item_id, i);0 `' }1 `% V' m0 T
        cout << endl << "    ID: " << item_id << endl << endl;
6 l+ B) n/ N; k) ^% s$ N        + Y8 K  e$ g  A* }3 R
        tag_t tItem = NULLTAG;2 J) P# r) }. I
        stat = ITEM_find_item(item_id, &tItem);
; T5 P) q' l0 o  F0 W& A1 _) k( O+ H+ g9 s
        tag_t tLatestRev = NULLTAG;
5 P& g$ O7 k  V5 S7 ^3 ]        stat = ITEM_ask_latest_rev(tItem, &tLatestRev);
, I& Y1 p* P8 m8 A( v8 l4 _* N$ Q; s" P2 V+ A4 c) c8 N% h
        char *pszType = NULL;& V' g! `# J9 t
        stat = WSOM_ask_object_type2(tLatestRev, &pszType);: w1 g* a9 p! Y; T; x  _* Z" a+ v
5 r) J1 \+ [1 S9 e
        BusinessObjectRegistry& boReg = BusinessObjectRegistry::instance();. m+ i" h1 H" B4 W1 m( s5 P) Q
        
) Z' U& Z# I0 H5 t& p& L, F! L        string revOp = "Revise";
( O* I3 \7 k" c" e1 A        ReviseInput* pReviseInput = . x4 M+ ^+ M5 [
            dynamic_cast<ReviseInput*>(boReg.createInputObject(pszType, revOp));1 j# y: O- A# o9 \

: x# G4 m7 g' a' Z' h        BusinessObjectRef<ItemRevision > boLatestRev(tLatestRev);
* \* d9 z* b& m2 B4 C" H8 |        ' K$ R! u. a# Q: }/ l$ m' k) v
        vector<Teamcenter:eepCopyData* > deepCopyData;
  e+ T8 u3 n7 }        boLatestRev->getDeepCopyData(&revOp, &deepCopyData);/ U8 r/ n; \8 K2 q) o9 N; B; t
        
' r* V3 G0 F- G: m3 L        pReviseInput->setLogical("performDeepCopy", true, false );
/ k& w8 m4 u& s1 u7 E2 X# B        7 y5 C$ Z  U; M/ N& n; @, O: F2 s
        tag_t tRev = NULLTAG;
! S" `: l0 M# p) e1 b0 E        boLatestRev->revise(pReviseInput, &deepCopyData, &tRev);7 r- o' E0 J$ _) A; s6 [

$ A( N" r9 h2 Z: c) r        stat = AOM_save_with_extensions(tRev);& S8 t  t% S) T8 D% M- b; w
        
9 w% f" y  |/ L        char *pszId = NULL;9 a$ y2 C$ \" n7 e, A
        stat = WSOM_ask_object_id_string(tRev, &pszId);2 i9 @" ~) E& G$ f: s3 P- l
        cout << endl << "    Object String: " << pszId << endl << endl;
% C5 _4 t: x& D. V# \        ! Q( @# T8 p5 g2 V0 F0 z# U1 v
        if (pszType) MEM_free(pszType);1 v/ I8 `1 E+ }( K. A
        if (pszId) MEM_free(pszId); / H+ Z8 N) s; W. k3 f
    }
" D7 w! ?  x$ c9 W" a9 K) B0 @    catch( const IFail &ex )
! @( i# e3 o9 j  j. G% D" K; r    {
& I" g0 g! B' J& B" x        logger()->error( ex.ifail(), ex.getMessage());: T  _( @2 f! i
        cout << ex.getMessage()  << endl;/ d% B) c5 h- z4 l6 R4 K( Z8 m; |
        cout << "error " << ex.ifail() << endl;        
# |0 v0 i4 y" u6 g, K" N    }
1 A3 Z4 p4 R$ `4 N2 k! L0 F9 s0 C& Z    const char* syslog_path;
5 ^3 Q9 E2 g# \! T    syslog_path = EMH_ask_system_log();# j7 z5 j& O& Q5 J' Y2 F+ w
    cout << endl << endl;3 V0 h5 p+ Q: p3 A7 X1 |, H
    cout << syslog_path << endl;
; [0 P! N' W% K7 n1 s0 {* Y
; L) \# @3 U. J7 ^& e1 m) I: g    stat = ITK_exit_module(FALSE);                                        " p6 i9 h+ `( x1 N
    return ITK_ok;
' r0 t8 R) M8 X5 k& r}[/mw_shl_code]3 x4 T& C) O" u1 D1 v1 W6 g, D! d- ^) |
上海点团信息科技有限公司,承接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二次开发专题模块培训报名开始啦

    我知道了