|
请使用QQ关联注册PLM之家,学习更多关于内容,更多精彩原创视频供你学习!
您需要 登录 才可以下载或查看,没有账号?注册
x
在集成环境中,NX和Teamcenter的集成中,获取当前用户的组group 和角色 role。
4 \0 G I' M5 |
" n) M$ V3 X6 U. [- #include <stdio.h>
+ k; |7 k9 n- K5 q. H8 ?, s - #include <string.h>: C3 T4 ?& c3 `7 J+ O# k
- #include <uf.h>
3 \# k* Z4 f- f) y% _ - #include <uf_ui.h>+ d2 } @ n; e) f" ^) m
- & s4 N' X) s) j: }* m1 V
- #include <NXOpen/NXException.hxx>
G+ O9 k2 d3 R( t* X4 Z - #include <NXOpen/Session.hxx>
3 [2 \1 \1 l; X; g4 z$ V - #include <NXOpen/ListingWindow.hxx>. R% z$ }4 ?0 I C/ B. W% v1 Z
- #include <NXOpen/LogFile.hxx>
. B1 _+ Z% s6 z7 Y) q - #include <NXOpen/PDM_SessionSettings.hxx>
! D: N: U" r0 [ y" X/ ?6 T3 m - #include <NXOpen/Part.hxx>+ o/ x% c% h" O: e
- #include <NXOpen/ParTCollection.hxx>+ w0 H& e' p/ z w, X9 L3 S4 C
- #include <NXOpen/Session.hxx>2 D! }# h1 n% T6 ?5 v
- % l- ]0 e9 _ X# D7 m0 e
- using namespace NXOpen; // <== Very Important!
! y$ [5 F# r4 p( d& k- J- }$ t
% Y8 w: c, \! c2 w J8 M9 t! _- #include <stdarg.h>9 v! N6 t/ I: ~ f7 _/ t- N' r/ c
2 q I/ W7 F$ U- X. F- N- static void ECHO(char *format, ...)' ]8 r, ^4 y3 O& f- M8 l, b. M
- {9 x8 d! k, V+ b$ B5 l
- char msg[UF_UI_MAX_STRING_LEN+1];
. |$ x+ l( U, H- C - va_list args;: V4 g1 t( m' r$ A/ W
- va_start(args, format);' ^8 S8 p5 q3 ?5 d+ \% ]: Q3 d
- vsprintf(msg, format, args);
. _' t/ ^- B) E/ M+ e" H - va_end(args);
0 ^& ^; V4 [3 l3 C5 A2 h# `4 j6 l - UF_UI_open_listing_window();
3 m" c1 C+ w( a" A9 J" _1 p - UF_UI_write_listing_window(msg);
# M5 Y: H" J8 }* ?8 }) r - UF_print_syslog(msg, FALSE);4 p. F! H. d+ Q0 F0 j" m
- }
- @: n# \- b! C
0 |% [& ]% l! ?% T4 W& H- #define UF_CALL(X) (report_error( __FILE__, __LINE__, #X, (X))); \- a. y3 g; P% b0 O" e
8 u7 o/ M9 v' J8 Y- static int report_error( char *file, int line, char *call, int irc)
/ Z3 ]3 F, k( O( g6 H - {
9 |1 z3 J0 o+ d9 z: v% ~- ~ - if (irc)! Y! m# o9 C$ b; h; B6 @! I/ [
- {" _9 N$ a1 M$ Y! o
- char err[133];* V" p" V) [: c" X% D( o
4 o' y6 c+ v+ S8 [# C0 A- UF_get_fail_message(irc, err);6 l5 s6 e5 e. S" J2 Q$ ~
- ECHO("*** ERROR code %d at line %d in %s:\n",/ r; {# s5 R2 w$ z, x1 I: Y
- irc, line, file);' L4 z! P* I( s3 E
- ECHO("+++ %s\n", err);
; V& `" u$ e8 c( b9 q5 d7 a - ECHO("%s;\n", call);' p4 L7 \; n$ M! u
- }
7 Q0 c4 K2 m3 H) U" b* E0 s - 7 H' F8 T5 c8 X' B* l
- return(irc);3 Q% H% R9 y/ n1 S0 S
- }0 ?1 q0 z/ L! K* d1 Z y# Q' ]
7 R: j) h9 O2 A* K T2 Y- 0 b( U2 w( @3 x
- static void do_it(void)
4 J! \/ T/ [5 D, ? - { i5 w2 y) S, i4 u% R' N1 }2 L- i' ~- |
- Session *theSession = Session::GetSession();
+ Y: E1 o0 Y+ N5 Q - Part *workPart(theSession->Parts()->Work());
2 `- E' k& @& X" u; {- g# m - Part *displayPart(theSession->Parts()->Display());
9 E& p. D8 b" Q% Q1 Y; c! T - / F" x$ H9 q4 p- c8 S j8 ?
- PDM::SessionSettings *sessionSettings1;" ~8 U" s7 Y+ W8 v$ H) [
- sessionSettings1 = theSession->NewDatabaseSessionOptions();
6 R9 S% Y+ ?5 \/ h5 i -
5 B' ?! q# X! P9 _ - NXString CurrentGroup;
g5 e+ t' N. d3 d - CurrentGroup = sessionSettings1->Group();0 m( g) M+ D5 U
-
/ Q4 x4 c8 M- P/ g0 \ - NXString CurrentRole;
1 W, D) q" e# d' ?' L, U - CurrentRole = sessionSettings1->Role();2 y/ c' a' L, L. L; C" d
- 4 C( Y- N+ B0 y, R# E
- theSession->ListingWindow()->Open();4 b/ E7 Y! |6 ?8 [! J8 V4 v. Y8 D1 P
-
; X3 n5 X8 i0 F# v7 I: u - theSession->ListingWindow()->WriteLine("Current Group: ");
% j/ [7 U8 ~7 G, B& o* M5 b. U& ? - theSession->ListingWindow()->WriteLine(CurrentGroup);
: x$ s* o/ q4 y% ?& f - # {3 x0 g; G$ p
- theSession->ListingWindow()->WriteLine("Current Role: ");
; B- x1 Z# p: O) g* u - theSession->ListingWindow()->WriteLine(CurrentRole);
- b' J( q) B1 Q) i - ' M# _2 W. h1 }" x) {$ q6 }, b
- }. O' T. A' }2 o# n: j
3 Y7 X2 L3 K9 o$ l: a4 K( y- /*ARGSUSED*/
, M- }4 @5 {" e3 }& z! ~ - void ufusr(char *param, int *retcode, int paramLen)
" p4 p" w6 h9 P5 W1 ]3 w - {1 \) b1 I' w+ I9 T% v( C+ u
- if (UF_CALL(UF_initialize())) return;) t2 A2 k6 y" Y4 O$ P
- do_it();$ k- _) s4 m) V; x! R
- UF_terminate();
9 f8 s" b% k E8 N/ v - }! V; R+ A" S, c
- ' W: A: r0 [8 C& i# j9 S
- int ufusr_ask_unload(void)- _ r% ^+ E% w9 r! |5 [
- {
- ?- ~; o: d4 z: c; }, T7 {4 G - return (UF_UNLOAD_IMMEDIATELY);
/ o$ p$ I r4 {3 u" \6 f - }
. Q2 {8 m5 i2 X+ [) u- W& t" @
复制代码 |
|