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

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

[复制链接]

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

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

admin 楼主

2020-2-8 09:27:38

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

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

x

: z  F  e# w  i6 gTeamcenter二次开发源码分享: Revise 版本 升级版本方法
5 A0 ]' N2 K4 ^
# _7 @9 c) B* k# }% Q2 C$ E2 Y; t: K7 T& `
[mw_shl_code=cpp,true]#include <TC/emh.h>
# E! ?) _* N' Q3 O. K$ J/ l" O2 J#include <tc/tc.h>
0 b/ U/ o. e" h: ]8 V' d#include <tc/tc_startup.h>7 |) ^5 g* e: }2 r8 v7 y0 F9 v
#include <tccore/aom.h>
% u' @: X( _6 h1 B% `- @8 V#include <tccore/item.h>
9 P4 x* e; [: ]! `, d! q0 G$ X" l0 z" ?9 W
#include <iostream>
! e- Z1 e) s8 M& \  r#include <vector>0 D1 \8 `! k/ @, }! P
#include <base_utils/IFail.hxx>
% Y, J% H8 E' s0 G/ O/ c( W. ]#include <base_utils/ScopedSmPtr.hxx>
5 [; J4 I/ H5 W- e: g#include <base_utils/TcResultStatus.hxx>
5 M$ N0 r% s2 z#include <metaframework/BusinessObjectRegistry.hxx>
" ^" }1 X- M9 n& ?& L- C+ ]! H# r#include <metaframework/ReviseInput.hxx>
' |4 |0 B! M+ z7 D: q3 L& ?0 Z#include <mld/logging/TcMainLogger.hxx>, `" R( y8 c6 i1 e) n# T
#include <tccore/ItemRevision.hxx>$ F/ i& x7 {) o' X2 o% j# h% T
#include <metaframework/BusinessObjectRef.hxx>
7 q0 l4 H0 w4 t+ C0 J/ g  l#include <metaframework/BusinessObjectRegistry.hxx>
* m. K/ r8 y) q" m#include <metaframework/ReviseInput.hxx>
" P* S8 \6 v8 _- a: Z1 |" |/ p
! y0 C2 Q% c5 G7 [) C) e9 uusing namespace std;6 _4 ~$ d: @. o& z
using namespace Teamcenter;9 E( \; D; B( {9 u* D
using Teamcenter::Main::logger;# t6 K+ \' k/ ~8 ~8 R

6 |- T5 n0 ~7 oint ITK_user_main(int argc, char* argv[])6 h- a0 e1 x& h' Y0 v6 Q3 J
{! p6 x* e7 A4 ]$ q7 D1 l
    int ifail = ITK_ok;
8 {. T3 x& t7 e4 M5 Y. j    ResultStatus stat;8 w% Q, g) k$ `& j6 W8 R5 q
    try
8 c9 R7 K7 o6 f6 Q3 s    {/ B3 d( V3 O/ G5 {/ _: H: r1 d
        stat = ITK_initialize_text_services(ITK_BATCH_TEXT_MODE);         
- \! y1 C& k3 t3 B+ E9 |        stat = ITK_auto_login();                                          
1 X4 w; h- L$ a        stat = ITK_set_journalling(TRUE);
) D" R0 w6 |5 G8 V  ^        
) p1 L( x! B7 Z8 e7 ]        char item_id[ITEM_id_size_c +1] = "0000000";5 w. G$ q' u' R0 T# {
        char *i = ITK_ask_cli_argument("-i=");4 n, m0 j( p3 c5 ?/ t6 E" G
        8 J8 k) D: |; W2 m
        if (i != NULL) strcpy(item_id, i);! r( w' `* \  \% n2 i) g. M
        cout << endl << "    ID: " << item_id << endl << endl;( }1 \% a) l9 U9 L9 ~* b! _
        ( Q$ T# o9 y" v3 x. ~) H
        tag_t tItem = NULLTAG;
  k3 y9 ]. @& u: s( {4 u: W% C        stat = ITEM_find_item(item_id, &tItem);
0 W" t3 V  A$ o# M: c* M) |  G. Y, {$ Z$ P9 R7 w3 F& [& B
        tag_t tLatestRev = NULLTAG;
& C  R0 ^9 N) ?% E! H        stat = ITEM_ask_latest_rev(tItem, &tLatestRev);   J, s, }' m. f. y, ^& W* L6 q
4 H' y: |! i/ k
        char *pszType = NULL;
- A" g4 |; M9 w/ ?4 [        stat = WSOM_ask_object_type2(tLatestRev, &pszType);! x2 h  l8 [+ O$ j1 l  ~: {- x
' D! j! S3 E8 N1 u
        BusinessObjectRegistry& boReg = BusinessObjectRegistry::instance();; `8 m$ k, D2 F& c: Q% F9 r! L
        
5 g5 d# [# p8 `. {0 F1 @+ i        string revOp = "Revise";, E1 L  c4 i3 h/ }# |
        ReviseInput* pReviseInput = 0 {! K2 y1 c$ A; [
            dynamic_cast<ReviseInput*>(boReg.createInputObject(pszType, revOp));% w* l4 [# Z! W- c9 f1 }

' G( ]0 o1 G$ L! @. [        BusinessObjectRef<ItemRevision > boLatestRev(tLatestRev);! M) f0 `" V' ?8 b& @- S
        
  j$ M4 p. C8 C' K4 D        vector<Teamcenter:eepCopyData* > deepCopyData;
0 e' e! v* ]9 L7 [0 Q        boLatestRev->getDeepCopyData(&revOp, &deepCopyData);
8 O" l% b0 y" Y4 q' ^        
4 Y3 W# X% F  p& v+ T        pReviseInput->setLogical("performDeepCopy", true, false );
" E0 S1 G9 d; T* M' t! Q7 ?        # N- c0 _( {1 {) I
        tag_t tRev = NULLTAG;* b9 v1 U/ k7 C" W" K
        boLatestRev->revise(pReviseInput, &deepCopyData, &tRev);
/ i4 t" t5 F* z: f7 V% q9 j2 W8 [1 F1 h  D: ~
        stat = AOM_save_with_extensions(tRev);' d+ o: J! ]( G! B# n  K
        
6 [3 F3 w7 K& D- i9 Z/ B        char *pszId = NULL;
: J  W. V2 w/ Q2 l        stat = WSOM_ask_object_id_string(tRev, &pszId);
* Y/ e# s$ ?" C- D% F        cout << endl << "    Object String: " << pszId << endl << endl;
  J! q6 T) @! M+ s9 E  W6 H2 h        
+ C! g# [  U" k3 k* V        if (pszType) MEM_free(pszType);6 ~, z' D% D& Q( N8 m4 l/ J. l/ o
        if (pszId) MEM_free(pszId);
2 N! O% S5 A  [5 c    }( w" b8 D- N+ J- J. y
    catch( const IFail &ex ); Y* s8 M9 V9 w2 }, E
    {) i$ o+ }/ f/ a9 `# K" m4 a/ y
        logger()->error( ex.ifail(), ex.getMessage());; c- P2 v* w" \0 S7 X
        cout << ex.getMessage()  << endl;  {! a% W7 y( A  n+ I+ s
        cout << "error " << ex.ifail() << endl;        . ?! k8 z( @$ G. w" U1 J3 l
    }: h5 D! F5 Q' {5 L
    const char* syslog_path;
/ P3 n' X" a- `; b# l( S- ?    syslog_path = EMH_ask_system_log();
! {; t+ M, U& e    cout << endl << endl;( D* D6 y& m7 d) h
    cout << syslog_path << endl;* M$ t) k" ~+ L; k9 r
2 B' X4 u& ]/ f- T
    stat = ITK_exit_module(FALSE);                                       
' L+ Z6 I" e0 G/ T  r, f    return ITK_ok;
5 X' C# n/ W9 U8 V}[/mw_shl_code]
& Y4 \0 c# m  W) R! }- r
上海点团信息科技有限公司,承接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二次开发专题模块培训报名开始啦

    我知道了