PLM之家精品课程培训

PLM之家精品课程培训

联系电话:18301858168   |   QQ咨询:939801026
NX二次开发培训

NX二次开发培训

UFUN/NXOpen C++和实战案例

适合初级入门或想深入了解二次开发的工程师,本培训结合ufun,NXOpen C++,大量的实例及官方内部的开发技术。
公众号二维码

关注公众号

点击扫描二维码免费在线高清教程

课程详情
Catia二次开发培训

Catia二次开发培训

市场需求大,掌握核心技术前景广阔

Catia二次开发的市场需求大,人才稀缺。掌握开发技能潜力巨大,随着经验积累将在汽车、航空等领域有所作为。
B站二维码

在线原创B站视频

点击关注工业软件传道士主页

课程详情
Teamcenter培训

Teamcenter培训

全方位培训,从基础应用到高级开发全覆盖

涵盖用户应用基础培训、管理员基础培训、管理员高级培训及二次开发培训等全方位内容,由多年经验讲师打造。
QQ群二维码

加入同行交流

点击扫描二维码加入QQ群

课程详情
×

PLM之家plmhome公众号

课程涵盖: PLM之家所有原创视频

×

关注B站视频

所有高清视频一览无余,全部在线播放学习

×

加入PLM之家QQ群

同行交流,疑问解答,更多互助

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

Teamcenter SOA开发中关于变量声明,转换等代码的新处理方式

[复制链接]

2015-2-3 09:18:14 3684 0

admin 发表于 2015-2-3 09:18:14 |阅读模式

admin 楼主

2015-2-3 09:18:14

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

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

x
Teamcenter SOA开发中关于变量声明,转换等代码的新处理方式3 J3 h; h3 m- l/ I% F6 U+ |

( M7 v% k- Q* [  B* d

( W% N4 A# D; ^0 _! q: v2 ~) x& |1 变量声明6 j. P/ p; }8 H& v/ ^

( h' H* f! d2 p% m/ }' _4 H

# P, ^$ f' x" n1 Ko Old way
. Q3 K: ^* {3 C6 Z7 N. a* ^// Declare pointers for an Item, Form and vector of ModelObjects3 d9 t) ~2 L6 T7 a" V
// initialize to NULL
3 f/ n# m& r) a6 CItem *theItem = NULL;, @; q' s$ v$ Z: V) ]3 g. W9 A
Form *theForm = NULL;; ^9 l. U: R4 ]
vector< ModelObject *> objects;
" R: W# D/ S: i3 B...$ P0 A( U) l6 ^9 p
// Use the Item. N, Y( Y/ X) m; I9 Y. T
theForm = theItem->get_item_master_tag();% W, K- {; R. E+ p: l! ~7 i+ w, u
objects = theItem->get_revision_list();- m( P8 d2 j0 Y2 M/ I. G# Z5 X0 q
o New way& W3 j0 J* D' |
// Declare AutoPtr for an Item, Form and vector of ModelObjects
& `$ C: ?& W# G0 G) {+ I// all AutoPtrs are instantiated as NULL/ G' W* a, i% s) U1 j- a8 x3 N
Teamcenter::Soa::Common::AutoPtr<Item> theItem;
5 p) C2 D. @9 e" STeamcenter::Soa::Common::AutoPtr<Form> theForm;
: e* J& q% `) }* H4 O$ q/ uvector< Teamcenter::Soa::Common::AutoPtr <ModelObject> > objects;
/ A5 k* b* U/ N' o// Use of the ModelObject variables remains unchanged
4 ~. w1 q, I( a: H5 {: StheForm = theItem->get_item_master_tag();7 c9 l, @% F, O1 Z: k: U3 D
objects = theItem->get_revision_list();
1 K4 C9 Y( J; Q" q! H  T* Y& l" _! L4 Y- @1 R* j" N

  f' g/ y( ~  Y  q  }2 类型转换 2 ?8 X$ Z( f& L5 [

: I4 }  g3 q  z+ d% L/ A# Qo Old way
8 T* V; j7 V9 U// Declare the variables* B" D8 r( H' S
User *user;
: d. v) K4 }! S8 Y+ }  KModelObject *anObj;
; ?, I" }" F4 e- eFolder *folder;! S/ L& m6 m& k# f: D$ q
user = sessionService->login(name,pass, “”,””, descrim ).user;/ u0 l# a" X$ }
// Cast to the base ModelObject class
7 c4 b* J: D8 j" H( VanObj = (ModelObject*)user;
9 l6 c& s! q7 I, m, j) ^1 c// Cast to a speicfic sub-type, if not NULL
8 U! c2 E! d- Q; a$ X: E! r// do something with the new pointer! B( `$ ^% m# ~
user = dynamic_cast<User*>(anObj);
3 y* P9 @1 z' h& X3 M5 \5 sif(user != NULL)
; U% u3 ~. g  P  p/ I) e{  s4 A% P# ]: l+ T2 k
folder = user->get_home_folder();
" w" ~+ g5 C: P0 S: }6 `& j}1 P0 ]3 J4 g) Z7 N4 o9 b
o New way5 p7 Z: ]6 u9 a2 |; n7 r
// Declare the variables
" i/ ]& \8 r1 N3 s: t1 C' a& {Teamcenter::Soa::Common::AutoPtr<User> user;% L2 X& W/ |% V
Teamcenter::Soa::Common::AutoPtr<ModelObject> anObj;3 }7 N5 ~9 q  F5 ^. {0 b2 Z
Teamcenter::Soa::Common::AutoPtr<Folder> folder;: M3 w. p# q+ A6 Y
user = sessionService->login(name,pass, “”,””, descrim ).user;. i! \1 D9 t( }* g  }" j
// Cast to the base ModelObject class
3 b) ?+ X2 U& c% I# _anObj = user.cast<ModelObject>();
8 i' T8 M* u: l! C// Put the cast to a speicfic sub-type, in a try/caTCh block
0 ]1 E$ S- F3 h" ]" b/ }4 Q// if std::bad_cast not thrown, then cast was successful
, K: G% ~$ _% |" y9 jtry+ b9 ?+ J8 Q. T* W, e# a: J
{$ ^" l. B5 k" h, x- U1 |7 p8 ?9 g( }
user = anObj.dyn_cast< User >();
- g+ @1 S! O. `& s8 I) ^2 Dfolder = user->get_home_folder();
  T2 y0 f/ q2 ?$ j6 x* O4 Q4 O}
9 C- W: J7 Z8 T1 icatch(std::bad_cast&){}$ G( D9 Y9 G; A$ }$ j) j

9 u3 K4 t' v# H- D6 y, _
/ N% F7 J, @2 {8 }. s& Z% O9 `3 关于NULL 赋值' m% k7 q2 [% w9 l6 e2 F  r9 \3 a

0 |- u9 }7 C: _. ^1 Y/ Eo Old way
, O$ x( ^! N( K' r! p& n// Declare the variables8 C( C8 d; u1 r, x+ b
LoginResponse response;
% H; r# h9 c- Z0 Z* CUser * user;
  H) x) }1 Y4 E, k6 A# M+ a0 Z// Call a service that returns a ModelObject (User)4 T5 `, K% P( U# Y2 h# d; B
1-28 Services Guide PLM00076 Jresponse = sessionService->login(name,pass, “”,””, descrim );4 @( y5 F8 N+ v* H
user = response.user;' h1 {* a8 S: y8 n; K
// Test that instnace against NULL; [- A# z! U) O  c
if( user == NULL)
( K7 c" I: _/ h, ?{
* n. O3 R; q1 T- {. w; T...
8 e. G) m6 z4 Z2 A& @  h! U' @}4 R8 w) S7 L, h3 W  a/ s
else+ q6 T" M" C& Z
{
  q& P" {% f9 o// Assign NULL to the pointer) C$ I- x/ K* X) F2 ^% ]* I2 k% }
user = NULL;1 ]0 w, k* H1 r: _) [
}
/ K! ]$ ?& i9 K# d8 V5 S5 C- Yo New way0 y# h- ]8 ?' g( M: W
// Declare the variables/ Y$ _% P9 y5 j: _
// The service data structures do not change, only0 C% G3 [% p8 F7 s' m& S
// references to ModelObjects- i) w7 J, `6 u2 K% b( P
LoginResponse response;" C; q: l+ K1 h
Teamcenter::Soa::Common::AutoPtr<User> user;- m% T- c) }% j
// Call a service that returns a ModelObject (User)
$ ~8 u$ b4 c6 F9 H. a: u0 Cresponse = sessionService->login(name,pass, “”,””, descrim );
+ u, @1 [9 ~- p/ puser = response.user;
7 j$ }  v" ?7 B9 G0 a// Since we are not dealing directly with pointers,  r/ R  [+ Y! ^# B: n
// NULL does not make sense here, use the isNull method from the
: I; ?4 k( }# D0 Z! n// AutoPtr template class.
9 O& @+ z6 `( H) V, w; qif( user.isNull())
3 d; `* D0 ?. D{+ w! _; [# P; N3 {$ \" W
...% l+ u6 A1 ]; H4 e, a+ ]& W, ?- e; z
}& I9 v6 b# p; D% k# I- Y
else* l! A, B5 t) u  K, @/ S
{, Q8 Z/ @% ]: G7 ^' ^; r
// Release the instance and
! h1 m, j8 m, g! u/ Y# t8 Zuser.release();8 U' P. E0 `/ ^& _. i
}, ~& \+ Z; n' |1 x1 ]+ g( {
% d7 X0 e, i9 J( h

5 |, \7 x7 s" H, I
上海点团信息科技有限公司,承接UG NX,CATIA,CREO,Solidworks 等CAx软件,Teamcenter,3D Experience等PLM软件,工业4.0数字化软件的实施\二次开发\培训相关业务,详情QQ 939801026 Tel 18301858168 网址 www.diantuankj.com/ doTeam.tech
回复

使用道具 举报

发表回复

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

返回列表 本版积分规则

  • 发布新帖

  • 在线客服

  • 微信

  • 客户端

  • 返回顶部

  • x
    温馨提示

    本网站(plmhome.com)为PLM之家工业软件学习官网站

    展示的视频材料全部免费,需要高清和特殊技术支持请联系 QQ: 939801026

    PLM之家NX CAM二次开发专题模块培训报名开始啦

    我知道了