UGNX二次开发源码分享:Teamcenter集成环境下,报告角色和组0 E+ k% ?0 P4 e! r$ U
通过NewDatabaseSessionOptions,可以获取teamcenter当前账号的组合角色!1 @4 v, v+ g* t$ f+ u
这个类也可以实现设置组,角色,获取卷等操作! 4 e" h' ^: |& s. ^: M- [/ F% @# z7 Y- R0 C" s
! ?" ~3 k" S' @& x
std::vector< NXString > GetGroups () 1 k5 z6 e5 |. e# Y7 Q1 ?6 @ Gets the names of the Teamcenter groups to which the user belongs. - V6 u. P/ n) L! K( }2 ?) X8 L
. q" X' [$ g( G3 B7 l3 ~3 V
% H. D5 P3 v3 @- }+ Tstd::vector< NXString > GetProjects () # P7 ~" b3 \! A5 d
Gets the names of the Teamcenter projects to which the user belongs also the first entry of the returned projects list is always empty. , P& q+ C( g0 y i3 X) ?) B ! Y6 G8 x7 t8 A* P" T, N- Q5 h! K
) `4 b/ `# |, M* {std::vector< NXString > GetRoles () ; d: j0 L1 `% g3 t9 W Gets the names of the Teamcenter roles in which the user may act, given the current group returned by PDM::SessionSettings::Group . 1 u! ]7 @' H, g6 _/ {
& X0 \- p/ K$ i7 M% W4 ?5 w
! {" a7 X) h/ t. j% W2 ]std::vector< NXString > GetVolumes () 0 r* [) T8 z( X( I* L Gets the names of the Teamcenter volumes which the user may use, given the current group returned by PDM::SessionSettings::Group . 5 ?8 F/ v' R- v4 ~, W, m# w% X* u; ^4 U+ }4 E( h
2 d* H- S" ^1 [& C1 X, j* o( w+ { X+ c8 ^5 K
static void do_it(void) 6 Q' }( |' ?- F! \) S2 C# Z; M{ ! O m" g/ P- \( R, C Session *theSession = Session::GetSession(); 1 ~ S- W* w0 K( Z, L1 K Part *workPart(theSession->Parts()->Work()); 7 N, Q4 O1 ]$ [+ B( y Part *displayPart(theSession->Parts()->Display()); 7 w( y8 ?, e) ` E / x: M3 o) X/ a: [5 s6 r- ? U PDM::SessionSettings *sessionSettings1;8 Z3 |2 a9 V& g; l1 ~5 ]3 S
sessionSettings1 = theSession->NewDatabaseSessionOptions();; h/ L, k9 v* s6 U
% H9 G5 n& ?% A# V" W- b# ^
NXString CurrentGroup;5 d! W! @9 B: r" R' ~/ i
CurrentGroup = sessionSettings1->Group();0 N D# R$ l# m+ x
+ A! O& d+ A" f4 x$ _ ^' e. n
NXString CurrentRole;& s5 P& p3 Y# n' ?1 b& |3 N" K {
CurrentRole = sessionSettings1->Role();5 x2 l- A/ y6 K# y
. P: g/ c |0 l7 f- ?) j theSession->ListingWindow()->Open();! D% c/ |- B$ r) R" u8 j7 }' v
( f3 q( O: v8 A8 U8 S# G, x
theSession->ListingWindow()->WriteLine("Current Group: ");7 }7 D$ H1 L( c/ C% _# A* A4 T
theSession->ListingWindow()->WriteLine(CurrentGroup); ) H. L! \# v6 ~0 |* {* w + E+ R( e2 E: g$ K* H. f: E# B. U theSession->ListingWindow()->WriteLine("Current Role: "); 1 X; Y8 y1 t' w/ _$ V; F
theSession->ListingWindow()->WriteLine(CurrentRole);( B1 y5 t9 L6 w- S: ^
7 R; q q5 a* k2 j: z; W9 i. N
}5 T3 @' ]( ]9 k1 ]2 F