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

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

[复制链接]

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

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

admin 楼主

2020-2-8 09:27:38

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

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

x
* L8 R5 u* j! g' m3 x
Teamcenter二次开发源码分享: Revise 版本 升级版本方法+ s+ y' ?$ h* ^9 y

3 z$ V; f( [1 D5 Q2 I% @* N& X+ x7 C' P* Z8 l
[mw_shl_code=cpp,true]#include <TC/emh.h>
3 f6 B! O# _& ?1 E& l8 w  k#include <tc/tc.h>
" ~5 t' F) Z5 p- a8 d( @+ N1 [. C6 F#include <tc/tc_startup.h>' z# D' {# C' o- Z
#include <tccore/aom.h>/ Y3 k& s5 }, a* L7 b
#include <tccore/item.h>2 H7 @: W/ v: N' M. A# o

! E( t4 M) Y( ]% O. Z#include <iostream>; V' Q9 X5 c7 W1 q( c
#include <vector>0 D6 ^, C& Z6 N3 \
#include <base_utils/IFail.hxx>1 ]# V) g9 P, c" f0 B
#include <base_utils/ScopedSmPtr.hxx>
# @' ?* |( z4 K: d% n4 C4 D#include <base_utils/TcResultStatus.hxx>
( o4 E' b* f4 @#include <metaframework/BusinessObjectRegistry.hxx>
5 Y+ x3 }4 Z1 O#include <metaframework/ReviseInput.hxx>5 ?& J' Z, X! D" H8 Y% i
#include <mld/logging/TcMainLogger.hxx>
  \* G( Y& L3 ^1 |# _( Q3 n! x#include <tccore/ItemRevision.hxx>7 j! i% U9 I2 N0 ^7 m- u
#include <metaframework/BusinessObjectRef.hxx>
$ ^8 X$ y+ u4 i. ~/ C#include <metaframework/BusinessObjectRegistry.hxx>7 x8 u1 |8 f5 ?4 `3 e
#include <metaframework/ReviseInput.hxx>
% U+ ?) l9 @$ `: w% [7 `  O% d7 J; S4 X; n# k+ @7 X# {; X
using namespace std;# r* H" w: W( M$ e
using namespace Teamcenter;; B  K8 X/ Q% q/ ]4 D
using Teamcenter::Main::logger;
6 K6 U' c) p* n2 r5 i1 r+ k
6 D! |. |! z, P7 A* kint ITK_user_main(int argc, char* argv[])
2 r  K- `* W  x3 M" U9 o3 Z; C{/ l; k4 q* `, v$ H2 I
    int ifail = ITK_ok;  A1 B3 s3 {0 U
    ResultStatus stat;4 Y0 C. r7 I4 o- I0 ?% N
    try2 y5 ]. ~/ t# M# l. D
    {
/ }! W0 @7 H7 q$ ]" b, J        stat = ITK_initialize_text_services(ITK_BATCH_TEXT_MODE);         
2 F' B( T: r$ k/ O$ |( [) I        stat = ITK_auto_login();                                          
' D3 j3 c" A; I7 N        stat = ITK_set_journalling(TRUE);+ B( _1 R% X) J( I/ D  }
        % X2 ~& R8 n/ S" g' G
        char item_id[ITEM_id_size_c +1] = "0000000";0 B3 d* t  }: u4 }( y
        char *i = ITK_ask_cli_argument("-i=");
9 I$ _& d! D5 J        
3 ~' J" d- @, y8 A7 x; z4 g3 c        if (i != NULL) strcpy(item_id, i);
4 \7 b& W/ f. c3 @# q5 K1 m& M. R        cout << endl << "    ID: " << item_id << endl << endl;
2 b& b( O2 ~& V% x+ D' l" }        + b. P! m, {) {+ g" t. K) u3 R
        tag_t tItem = NULLTAG;8 `7 K3 P: g2 v2 `" |+ Q- S
        stat = ITEM_find_item(item_id, &tItem);
, {! k+ {$ `4 B6 @" @9 w
. |6 a, }. m9 k" Y' m- B% d        tag_t tLatestRev = NULLTAG;
5 X9 z8 T3 N1 p3 e1 n! Q        stat = ITEM_ask_latest_rev(tItem, &tLatestRev);   e) s2 z) x3 l% R
8 ]; K) Y) b3 G& m7 J: Y4 H( p0 M
        char *pszType = NULL;: D( x* w; Q1 ^* X
        stat = WSOM_ask_object_type2(tLatestRev, &pszType);
& L! l( B7 J) b7 z3 j7 ~( [# ]" @9 D: `. f+ K
        BusinessObjectRegistry& boReg = BusinessObjectRegistry::instance();
2 |# |4 a! o6 M4 G0 P# A) G        9 N- M: x' V6 k
        string revOp = "Revise";
) B9 y4 Y4 ^" R+ S/ X+ f8 x        ReviseInput* pReviseInput = * U* a( ^9 f2 _1 @5 q9 [4 T! q
            dynamic_cast<ReviseInput*>(boReg.createInputObject(pszType, revOp));
; w% L& \. o! \! k- l3 m; v+ x- j% h, |' w
        BusinessObjectRef<ItemRevision > boLatestRev(tLatestRev);& X( W3 ^$ ~$ c# ]5 l0 R7 A
          T1 N, L2 R) H7 D6 I4 _/ k9 @2 ]
        vector<Teamcenter:eepCopyData* > deepCopyData;3 {: ^  h; h( S' q# p7 _" p  \2 S  j
        boLatestRev->getDeepCopyData(&revOp, &deepCopyData);( e4 h. C8 w% o- w% I
        4 G2 u; [& x- O* V
        pReviseInput->setLogical("performDeepCopy", true, false );
! p0 ~! Z+ x$ ]  H, l* D) P        
( e- ^% \: n0 j. s- z* u        tag_t tRev = NULLTAG;
$ g- m! G% {9 M5 m: A, k        boLatestRev->revise(pReviseInput, &deepCopyData, &tRev);4 H& |& m$ T% P

' h: J! f' F8 S4 o7 @1 ~' [        stat = AOM_save_with_extensions(tRev);
2 g% J6 c) h3 f8 e- q" Y) H1 S8 S        
2 M8 F5 D4 K8 N4 Y        char *pszId = NULL;; {. y! A0 }& h, y
        stat = WSOM_ask_object_id_string(tRev, &pszId);0 n( Z5 A% [" e! U9 [
        cout << endl << "    Object String: " << pszId << endl << endl;2 e9 J! _+ e3 ^% z3 U
        , u& {8 k' G# I
        if (pszType) MEM_free(pszType);- L$ f) v: C9 |/ h2 K* u
        if (pszId) MEM_free(pszId); % r8 k- s% g  y
    }
) R  U- ~/ ]1 Z& I    catch( const IFail &ex )
( }# f9 ^7 }, T3 k: i* ]- `    {
8 S! ^" Z7 J" ?. X1 ^, S: |/ N* B( |        logger()->error( ex.ifail(), ex.getMessage());
' |! B; n% m# Y; S" M0 _2 m        cout << ex.getMessage()  << endl;
5 i9 A# D3 o$ q0 t( P        cout << "error " << ex.ifail() << endl;        
) t1 O1 M8 ]0 k; F/ S% K    }) N$ S' v  S: N1 `# u
    const char* syslog_path;2 a6 H8 ~# S0 h$ x+ A% r; Q& x
    syslog_path = EMH_ask_system_log();: I: N+ I9 |, H; G- P
    cout << endl << endl;
2 }" i9 u' Z) {$ O7 y! f! i- Y    cout << syslog_path << endl;2 r  B9 \0 Q' b) k
$ H$ f( V# G- Y9 F' E
    stat = ITK_exit_module(FALSE);                                       
6 M: f8 o1 j; J5 G$ C4 g    return ITK_ok;
) D- x, t2 f8 Z}[/mw_shl_code]
! w' {8 Z. l3 Y- O5 N: [1 q
上海点团信息科技有限公司,承接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二次开发专题模块培训报名开始啦

    我知道了