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 3701 0

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

admin 楼主

2015-2-3 09:18:14

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

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

x
Teamcenter SOA开发中关于变量声明,转换等代码的新处理方式
# U1 S6 o& ^+ s: y1 {7 Q# Y
5 y( y0 J% W7 w. L- a+ b/ S8 a

* n* T+ c* [  H) r1 k& W& k1 变量声明
' Z+ I* H1 G- j' x( k6 J. Z7 n, j7 E4 v, `
- r  n$ p' o3 @. [
o Old way/ @5 T% e, o# }" L" U
// Declare pointers for an Item, Form and vector of ModelObjects
/ P( w3 k  o5 r4 u' C// initialize to NULL
. G0 a) z2 o* q3 J8 CItem *theItem = NULL;
6 f' A- ~, Y0 I% I- b9 G  }Form *theForm = NULL;0 ~2 J- O3 Y2 y2 f
vector< ModelObject *> objects;
5 k2 j6 b% B% W, s- e2 h6 B...( w* Y5 r. N/ Z) E! x) N* k* C
// Use the Item
( B: @( T9 _5 Z( M8 htheForm = theItem->get_item_master_tag();- n0 \  \( F1 H; d6 x0 v
objects = theItem->get_revision_list();
( N$ m; @( f' F2 W  K+ G# l- jo New way* Q, z* x$ U  z8 _; g
// Declare AutoPtr for an Item, Form and vector of ModelObjects
5 _: I$ O0 F& N) {: h  Q& n5 e// all AutoPtrs are instantiated as NULL
' ?$ f' o/ ^; `0 STeamcenter::Soa::Common::AutoPtr<Item> theItem;
# Q, R. ~5 g! y& g6 \3 ?( e' gTeamcenter::Soa::Common::AutoPtr<Form> theForm;
5 j3 r+ K5 y. c" gvector< Teamcenter::Soa::Common::AutoPtr <ModelObject> > objects;% r( h: H' J, H& D3 s
// Use of the ModelObject variables remains unchanged
5 A9 i  T+ Q4 E% e2 _. ctheForm = theItem->get_item_master_tag();% N" P6 T. Z# F! Y# a) E; X2 a( Z7 Q
objects = theItem->get_revision_list();
2 n' {( [3 W8 g9 u9 D5 I' Y( {2 z& J' K4 [. ~) H
' `. e4 i5 J' Z5 V
2 类型转换 / s) `4 j5 m1 `2 f2 ?
6 \6 ?; g! a8 e  ^9 @2 R% g
o Old way
. p3 ^- @& A0 z% q/ ?// Declare the variables! B4 m" J3 g( [! |' d. j4 S- C7 V
User *user;
' Z: f* }, P2 X4 ~5 \ModelObject *anObj;
9 w2 D9 @( ^; ~. Z: j) bFolder *folder;6 A% |) }% S% y: R
user = sessionService->login(name,pass, “”,””, descrim ).user;) i  i8 Q% z. ]  {, R5 `$ S1 K
// Cast to the base ModelObject class
: }$ J, H, x7 u3 xanObj = (ModelObject*)user;$ M  A$ N1 C. k% G
// Cast to a speicfic sub-type, if not NULL
/ C  @; m& i8 A' _2 O! x; S! O// do something with the new pointer( M% `" V1 k2 Q7 I- z* t: ~
user = dynamic_cast<User*>(anObj);
: V" N, J1 T5 X7 f) x' F) ]if(user != NULL)0 n% L9 w7 `. x3 m( l
{" A9 J( P: U, b) j
folder = user->get_home_folder();2 n6 t3 X9 F% f/ h
}8 Z9 i. C3 c7 g1 C' e" E; v
o New way" p1 y& g$ y) J6 j
// Declare the variables
1 P: P: }: l' }Teamcenter::Soa::Common::AutoPtr<User> user;
5 [& [& {! W9 `0 Z5 R( _& eTeamcenter::Soa::Common::AutoPtr<ModelObject> anObj;
7 b6 a) B7 b- U/ a7 P7 @! WTeamcenter::Soa::Common::AutoPtr<Folder> folder;( A; V  l+ E' i$ e8 Q* |7 W3 Q
user = sessionService->login(name,pass, “”,””, descrim ).user;
. R2 g$ U. x3 S% ^// Cast to the base ModelObject class  U4 Z# r9 V) S( c
anObj = user.cast<ModelObject>();: O3 s( c( u- v, k& P
// Put the cast to a speicfic sub-type, in a try/caTCh block
* @- U6 G4 d3 C! L# m  a// if std::bad_cast not thrown, then cast was successful# l- y; Z& B$ u0 Y4 x, ?
try
' S8 q' e! E% z1 {- l2 N{
& s& X8 Y  h2 N  u, G% ?' `user = anObj.dyn_cast< User >();
! s0 Q6 U# k# t4 n2 Dfolder = user->get_home_folder();
+ @/ x1 G! Z# r. o5 |}+ L# h( n0 c: _/ V9 ]9 G# R) \( _( H
catch(std::bad_cast&){}' m8 ?- o; h6 b5 P* \" ~
, y2 a* u: Y6 C  F; \3 N

$ b7 D7 P/ r7 _  k0 q  N; i/ w3 关于NULL 赋值' h9 U, a* Y: N8 K: M

( V) c' s4 \  _/ y6 Qo Old way5 g( s3 @/ @, \* y; g# Q% D' @
// Declare the variables* x( d. E. O; i
LoginResponse response;
' s/ Y0 o( o9 ?& t" EUser * user;7 l  T) m) d, }9 A
// Call a service that returns a ModelObject (User)
) ], I2 H/ e+ c( r, P; i- e8 z/ r/ d1-28 Services Guide PLM00076 Jresponse = sessionService->login(name,pass, “”,””, descrim );$ I) m3 c4 R! x. @" r
user = response.user;
  l7 F9 V5 U! F1 [  b" l// Test that instnace against NULL1 j* y1 r0 Z, s) X& z# o! c. r
if( user == NULL), K, o9 g* S/ B9 o, V# W2 x
{
! p* `2 H! }0 T' m...
$ m  p8 U" H9 e, E9 l}7 K7 A0 R' l6 u  V4 e* Y2 u0 G
else
% t) b+ \+ X/ M& i+ c- U{
: T$ w' ~+ k3 c( w6 v// Assign NULL to the pointer: R$ c8 k# D' Y& j8 g
user = NULL;
7 Z1 R5 f3 t; J  k$ g% ?) r}$ }! `) x! j' X/ s$ p! G( ~% S
o New way6 [, m" {1 v4 H5 Y' m7 ?
// Declare the variables+ X' S) e8 s7 A- R3 e3 n
// The service data structures do not change, only2 i" W5 R! j0 t/ Y7 U6 F% @
// references to ModelObjects* f$ p0 {4 X6 N
LoginResponse response;  w1 Y# r& G2 @/ w4 b0 i8 J% x
Teamcenter::Soa::Common::AutoPtr<User> user;2 j: \7 }9 f* O/ V; e
// Call a service that returns a ModelObject (User)
2 A$ i1 G# G" a, yresponse = sessionService->login(name,pass, “”,””, descrim );: M% G* M) q2 f. J
user = response.user;7 [6 ]( W1 q( ^  _
// Since we are not dealing directly with pointers,
" N  Q: w3 n( z( q4 F// NULL does not make sense here, use the isNull method from the
0 F: {: B- n! W- B# I0 f, \: ~  E// AutoPtr template class.
+ j* e  U$ V- ?if( user.isNull()): C+ l) I2 _5 s
{
# T/ |" V2 ~* m" c( D5 \! e7 c2 ^...
' a0 f4 T9 Z5 z  l' v7 e}  x  o4 I) I  _, T- C4 a4 U' V
else
$ X/ u! a: p8 Y0 P" ^# w9 B3 ?) F{8 D" E& k$ }; r
// Release the instance and8 i7 u# h; j% U$ N* @" s1 w
user.release();
8 d) ]' ]! H$ Q7 r6 F}
" Z  I+ e7 C. d
: A7 U3 t7 Z2 l. {. F* u

2 B+ x( y  P# T& N* p) O# @
上海点团信息科技有限公司,承接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二次开发专题模块培训报名开始啦

    我知道了