查看: 3285|回复: 0

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

[复制链接]

6

主题

4

回帖

60

积分

管理员

积分
60
发表于 2020-2-8 09:27:38 | 显示全部楼层 |阅读模式

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

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

×
- u9 d0 B6 E5 V! H) N0 h
Teamcenter二次开发源码分享: Revise 版本 升级版本方法
6 q7 u' d8 G  {$ Y' E7 b% \$ E5 b2 g6 h* A- T

7 b/ u$ _3 n0 d: Z  I' t/ `[mw_shl_code=cpp,true]#include <TC/emh.h>
/ [5 f1 F! h0 [/ L. \8 b#include <tc/tc.h>
# y( n) S1 b/ z#include <tc/tc_startup.h>
$ m: d& R3 w# Z3 Y9 U; l5 U#include <tccore/aom.h>
; `! n! n( [0 x( z6 V& u#include <tccore/item.h>
6 w/ ~' a2 }  W5 v  e' ?9 o' p  ~: u
#include <iostream>
" Y! E# Q# z! r- Q#include <vector>
, h/ [$ L. Z$ t2 h+ t. b) ~# f/ E#include <base_utils/IFail.hxx>
# h) t- p$ A3 H#include <base_utils/ScopedSmPtr.hxx>
: {) l# ?4 P; A! }0 j#include <base_utils/TcResultStatus.hxx>8 ]+ @3 r' j: B2 \; K" f. m
#include <metaframework/BusinessObjectRegistry.hxx>) n2 B4 Q, T+ t' i( i
#include <metaframework/ReviseInput.hxx>2 r0 l2 F" N8 i# j/ R( c) K
#include <mld/logging/TcMainLogger.hxx>: Y# Q4 o& s+ [; J4 w
#include <tccore/ItemRevision.hxx>
0 m: C: R- v9 }: R( B* U#include <metaframework/BusinessObjectRef.hxx>
; ]* y: [" G+ H* U$ w#include <metaframework/BusinessObjectRegistry.hxx>2 N& R% G- T" z+ ]8 K
#include <metaframework/ReviseInput.hxx>
% ^  i; E& C  |+ C3 X
& ^* v( j4 N( ]+ @5 U# Wusing namespace std;3 C* d: {0 q$ t9 L, \2 N5 B
using namespace Teamcenter;
" ^# S' y$ M. K, I" B5 Wusing Teamcenter::Main::logger;
1 t) F- I" h) b) p1 r8 D! N. `& o( s: ]3 ~
int ITK_user_main(int argc, char* argv[])6 _3 s: E% C3 K% J2 d8 Q
{
4 D+ y2 v- R9 m! f$ A; o$ f    int ifail = ITK_ok;3 y; u% a- o4 Q$ R0 I4 x7 H( T
    ResultStatus stat;; q) J8 n- y$ @3 X
    try
! h. y# c2 N6 l    {& z: k0 n. y$ E2 {5 W* K, t+ j4 I
        stat = ITK_initialize_text_services(ITK_BATCH_TEXT_MODE);         
: m4 C2 L+ ?' [8 W        stat = ITK_auto_login();                                          
6 a3 s/ [2 P. R        stat = ITK_set_journalling(TRUE);
, w- W3 y2 t* A        
1 P; |- F7 n* J$ a/ H% ^& d        char item_id[ITEM_id_size_c +1] = "0000000";
. f: i+ H& \; c5 ^3 j/ h, p        char *i = ITK_ask_cli_argument("-i=");
1 B" W+ h3 i& G  S7 a        
5 n$ o. {$ K! \) r        if (i != NULL) strcpy(item_id, i);
; v+ j' ~6 f! ?: \8 ~        cout << endl << "    ID: " << item_id << endl << endl;
4 d: p5 o* ]) T7 {: U; }        # q- D$ D) y% j! O4 ~! a. {
        tag_t tItem = NULLTAG;
2 L" D! ?; ^+ h" U1 W        stat = ITEM_find_item(item_id, &tItem);
9 K  ~% x" }- q& Z6 h8 `1 E! @. L% C! x2 B$ N
        tag_t tLatestRev = NULLTAG;
# o# p0 y; c9 v        stat = ITEM_ask_latest_rev(tItem, &tLatestRev);
' R0 d7 w( k& Z+ s" s
: N. }' ^( |5 {* u- d        char *pszType = NULL;, Z9 P( J6 I* z/ u
        stat = WSOM_ask_object_type2(tLatestRev, &pszType);
+ Y; P- N2 x5 V6 Z+ j
3 Z3 s: v: a2 I+ f  v        BusinessObjectRegistry& boReg = BusinessObjectRegistry::instance();' |& A6 u- ~' Z& a
        . J( m; w- l; T2 S% t  _3 R
        string revOp = "Revise";
9 {5 n  |# H8 p. ]% f        ReviseInput* pReviseInput = ( a9 P# O$ t$ z! y1 l: t
            dynamic_cast<ReviseInput*>(boReg.createInputObject(pszType, revOp));
( R8 _7 C' J" e' X) O% j( p" c0 v' c* Y
        BusinessObjectRef<ItemRevision > boLatestRev(tLatestRev);+ e, [! c6 z- ?' m
        
6 Q% R' l; Z% A1 @% H4 s        vector<Teamcenter:eepCopyData* > deepCopyData;1 k2 \& ~" W0 `; j" Y% T
        boLatestRev->getDeepCopyData(&revOp, &deepCopyData);
$ @# a) W3 g2 S4 M4 x        9 L9 S5 Q* l# J2 T- I
        pReviseInput->setLogical("performDeepCopy", true, false );
5 t# G1 O+ H- l& N: {: b" L        
5 t2 d/ U2 w. n: p; p5 n, j# W        tag_t tRev = NULLTAG;0 j1 a5 y5 e( e% z
        boLatestRev->revise(pReviseInput, &deepCopyData, &tRev);1 z/ I; c9 ]# j5 g/ g
  s% j5 }6 p# ~
        stat = AOM_save_with_extensions(tRev);
% J" H$ v( H9 V: K4 c        
: S) |8 L- m5 d- _# |" J4 q1 H        char *pszId = NULL;  h0 N! V$ c, Q4 ^7 d
        stat = WSOM_ask_object_id_string(tRev, &pszId);- n1 X4 p: d% I9 _
        cout << endl << "    Object String: " << pszId << endl << endl;; h& g% D) Q. y) D' A- L8 U
        : e% Y: ^8 k+ Y4 c8 z
        if (pszType) MEM_free(pszType);
3 l6 _+ }- J& g7 G        if (pszId) MEM_free(pszId); $ g2 J! G+ t% f- J* U
    }
8 Y( ?! {* u- A) g5 K8 G' g    catch( const IFail &ex )8 P+ C; G' {. t. I- C. \
    {0 p# t* s9 C" N
        logger()->error( ex.ifail(), ex.getMessage());9 E# _* K. y! j' D, d. t" j- f% `
        cout << ex.getMessage()  << endl;
) ?- B& N1 [( W- U5 H' Y( Y. q        cout << "error " << ex.ifail() << endl;        
2 v/ v+ T, z" D8 l- t    }- n* `% \; t, @1 W+ _
    const char* syslog_path;( s  Q* j: N' u1 Y$ a
    syslog_path = EMH_ask_system_log();
5 E% s( S' i2 s3 h* a    cout << endl << endl;
4 g. a9 t4 H( ^( i* ]9 A    cout << syslog_path << endl;4 p( q/ w3 N+ N3 |. t5 w5 M
8 W  \6 V7 T% C! s
    stat = ITK_exit_module(FALSE);                                        $ t: l; ~/ N8 V! x+ _, c& Y
    return ITK_ok;
# c  f: w7 m6 C4 h8 D( c0 V}[/mw_shl_code]
1 P* j# E; [% J7 L
上海点团信息科技有限公司,承接UG NX,CATIA,CREO,Solidworks 等CAx软件,Teamcenter,3D Experience等PLM软件,工业4.0数字化软件的实施\二次开发\培训相关业务,详情QQ 939801026 Tel 18301858168 网址 www.doteam.tech
回复

使用道具 举报

您需要登录后才可以回帖 登录 | 注册

本版积分规则

在本版发帖
关注公众号
QQ客服返回顶部