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

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

[复制链接]

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

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

admin 楼主

2020-2-8 09:27:38

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

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

x
9 }" v+ a" a+ p) x, R0 g6 `4 _
Teamcenter二次开发源码分享: Revise 版本 升级版本方法( F: C/ `& `8 t* d) R
9 h  o$ F0 j9 l+ z: i" w

  A! ?7 A; d3 ?5 u5 c  J[mw_shl_code=cpp,true]#include <TC/emh.h>9 Z) _: m9 ]" Y: f
#include <tc/tc.h>
( B* e% s- T: a. S( h( L8 }#include <tc/tc_startup.h>
$ y; {  C/ n- [; N7 j  L#include <tccore/aom.h>1 d" L0 @" j) M
#include <tccore/item.h>
% P1 Z  }$ ]! o$ u/ N3 D! S$ |5 ~: v* \) z4 F. I+ X+ G4 {. @
#include <iostream>
0 f" K5 Z) i3 S/ k! N. P$ V#include <vector>
; M: f- Z( S' \9 p; P3 P- s6 ]* S#include <base_utils/IFail.hxx>0 b2 `' G0 a- M
#include <base_utils/ScopedSmPtr.hxx>8 e2 }, J% `& F; m/ ]/ L
#include <base_utils/TcResultStatus.hxx>
$ `; \" P: S; i& }+ z% M5 m#include <metaframework/BusinessObjectRegistry.hxx>
( u' ?  U9 P7 [; \1 m0 p) K#include <metaframework/ReviseInput.hxx>$ K" \6 {4 g. Z& u7 q% K" _
#include <mld/logging/TcMainLogger.hxx>9 I! y" u2 [/ [' z9 R" d
#include <tccore/ItemRevision.hxx>: f, H. a" i2 e% I* T1 v6 {
#include <metaframework/BusinessObjectRef.hxx>
( [( i% w) t0 }, x#include <metaframework/BusinessObjectRegistry.hxx>
0 ~9 p, j" r2 i0 E6 d5 Z- o$ x#include <metaframework/ReviseInput.hxx>
6 P" b3 v% I# N' c1 ^! X! Y% F, {! T# f4 p3 Q
using namespace std;" V( M# h1 |7 B- t1 U
using namespace Teamcenter;6 J' v  t4 }1 V. R7 ~5 k+ i$ t& l
using Teamcenter::Main::logger;
9 O* X/ w- y# l& o, l7 H# H7 W
* t+ i) r7 {, h$ y. ^1 R3 K8 ^int ITK_user_main(int argc, char* argv[])& n3 K! E$ h; l6 ^; [
{7 `3 a; ^4 Z* C+ c1 [$ w/ t$ A' i
    int ifail = ITK_ok;4 ?4 U. ^; E# e) \9 j' V  E
    ResultStatus stat;
- Z4 a3 F4 z  C1 `    try
! |% z0 o& H% w( M    {" D3 [% N  p. t8 L
        stat = ITK_initialize_text_services(ITK_BATCH_TEXT_MODE);         
+ B' j" V6 s% g! h/ I6 w5 c2 w        stat = ITK_auto_login();                                          & P4 I5 D( v1 w% n
        stat = ITK_set_journalling(TRUE);
  i; Y7 _3 e5 z        7 z) U' d6 K: T% z- z
        char item_id[ITEM_id_size_c +1] = "0000000";
: h% F! ^4 P# l$ X' z) F9 }        char *i = ITK_ask_cli_argument("-i=");
$ J8 ]8 f& m4 P- S8 x        4 A4 \0 n# T5 W6 Q* {
        if (i != NULL) strcpy(item_id, i);% i8 ?6 a2 b& u7 p3 B2 {& I
        cout << endl << "    ID: " << item_id << endl << endl;
- ?% B6 q6 [1 I        4 Z! X' N7 m7 @! O" Q  Y  M
        tag_t tItem = NULLTAG;
) e, x. G" Z9 X& X. f! z        stat = ITEM_find_item(item_id, &tItem);% f6 h- Y3 R& ~9 |' K" o$ ]
: `7 Q9 h' b3 O* {) U- t  c
        tag_t tLatestRev = NULLTAG;
& \/ z# L/ b+ R0 e# K9 H! q! [: |        stat = ITEM_ask_latest_rev(tItem, &tLatestRev); 8 q4 Z: e% z9 \) B3 G
% _$ W2 b& k- D: F) f3 k% j
        char *pszType = NULL;
) n% G. D, |3 v7 f7 |8 s- J        stat = WSOM_ask_object_type2(tLatestRev, &pszType);
- V  B, l/ c6 I/ L3 Y" u- w5 F3 |: N8 l; v5 s
        BusinessObjectRegistry& boReg = BusinessObjectRegistry::instance();
+ o' R7 n7 P  R. t$ w7 V  N        
# `4 ~8 u* g; Y        string revOp = "Revise";
$ }6 E7 \& C# b        ReviseInput* pReviseInput =
; k+ |; [: l+ W9 d5 U. s: O            dynamic_cast<ReviseInput*>(boReg.createInputObject(pszType, revOp));! R9 S9 p( w) m* B. R- m0 b1 j
* n9 |: g$ ]; G
        BusinessObjectRef<ItemRevision > boLatestRev(tLatestRev);
7 s( |" w/ ^8 v2 ^# K        
  U( u# W  q- p( D9 [        vector<Teamcenter:eepCopyData* > deepCopyData;
; g5 h1 W6 H2 P, o! e1 o* T        boLatestRev->getDeepCopyData(&revOp, &deepCopyData);2 K, C) K1 d9 @6 d& I
          g( u9 L* o0 L
        pReviseInput->setLogical("performDeepCopy", true, false );, q! u$ f7 b. a! u* D+ V% I! q+ _
          I0 q6 b, m  q$ @- y$ k
        tag_t tRev = NULLTAG;
, f( h2 r. \, ]6 m        boLatestRev->revise(pReviseInput, &deepCopyData, &tRev);( W( Z" g  F) \# _* X! h
( {9 s4 q% |: L6 C
        stat = AOM_save_with_extensions(tRev);
% i" f2 C2 d7 _3 O  u; ]        % j: G, a8 \8 t% v9 P9 X8 m( _
        char *pszId = NULL;
) A8 t) ?, g( X1 O+ B2 k5 \        stat = WSOM_ask_object_id_string(tRev, &pszId);
' p4 F5 I" b- M        cout << endl << "    Object String: " << pszId << endl << endl;8 ~3 S; J4 M* L" U* H
        
9 K+ M6 S8 a4 W6 R  b) N        if (pszType) MEM_free(pszType);
  i6 D& D1 l  p  u5 W  h        if (pszId) MEM_free(pszId);
- ^3 E% I" j2 K. l+ T8 ~$ t" o    }8 s( V4 t9 P% p  P* M3 I# O+ I
    catch( const IFail &ex )
) e* u) X+ ]; @  F! N) ]    {; U& g' A  L" D. q/ h. Y# f
        logger()->error( ex.ifail(), ex.getMessage());; A4 P8 X% A2 |/ m& e" K
        cout << ex.getMessage()  << endl;
  d& C+ S# k6 N4 _        cout << "error " << ex.ifail() << endl;        
. F9 B; p2 p: h" U$ D# K2 }    }
" Z/ Q5 `; q! C" E6 u1 T& I    const char* syslog_path;! i' E7 E. B$ k1 [8 J; g
    syslog_path = EMH_ask_system_log();
7 W; q1 j3 ]2 |* n- B    cout << endl << endl;$ ]2 T# c- u! K5 O
    cout << syslog_path << endl;
  s0 q8 ^9 M( J7 P' [& a$ Q3 W9 k5 x6 [8 H
    stat = ITK_exit_module(FALSE);                                        * |2 X9 r  Z/ g$ b. @: E
    return ITK_ok;  }' ?0 y5 {( l% k- M# c
}[/mw_shl_code]
; D5 ~# K3 w/ l* S; ~
上海点团信息科技有限公司,承接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二次开发专题模块培训报名开始啦

    我知道了