|
Tag到NXObject的转换: R/ R6 t5 j# t) \0 L& B
. m- R. F* x- A( v9 d% H' e, C+ {2 H3 [" X" F) h& C+ ?! Z3 l; x
ufun 里的Tag 转换成 NXOpen 里的实体对象
/ K/ m' m) y8 t+ A7 U- O7 w5 {; V( f6 s( k7 C5 v
C++6 c, U: k1 y- ^! T2 G
0 F0 J* }/ v, g/ v* \8 \2 M$ r' U0 R0 n# R# S3 M3 t
tag_t obj=NULL_TAG;; C* m8 L+ F" K+ h5 b+ I, c
! S7 X) W# _ w% L( Y% l2 m( U. t; oBody *body1(dynamic_cast<Body *>(NXObjectManager::Get(obj)));& b. O3 ^9 C) M6 Z, i
. K- ]. a# v+ i
Assemblies::Component *component1=(Assemblies::Component *)NXObjectManager::Get(obj);: n# R- n6 A+ a. p7 R0 ]9 f2 N
+ J5 X. z1 r8 D6 @% S
2 f" Q8 l- D' W# M0 _. M1 Q8 d2 R4 s0 ?7 j: V
9 W* U: ` W ^2 O. u. p$ R
& _* n: w# c; L+ \4 ~=====================================================================
6 r' j0 p* h, @/ i0 P' j! b* ?- K
7 [- ?9 h2 v! K& R- ]C#
' R; H4 p8 `$ L% c" @5 _ /// <summary>2 @6 u6 ~' a0 W" P
/// Tag到NXObject的转换- a- q6 b' i" l; Q/ T
/// </summary>- h/ V& b0 k( p* z& G5 l
/// <typeparam name="T">NXObject的类型</typeparam>
$ q8 D' E6 r! ~+ z /// <param name="tag">tag号</param>7 t( O$ [4 p3 A1 w
/// <returns>NXObject</returns>
" U. q5 t7 @' A2 U- y! N; X+ {. N: k public T Tag2NXObject<T>(Tag tag)) B$ R& U/ s3 Q* @; T( _( e) q3 l
{
' {* l% K+ R# w8 Z' N% m" w) _ try
" ^) g* r" P/ k3 J$ W9 V {
" Q9 d0 T( P4 j9 O% w+ W object to = NXOpen.Utilities.NXObjectManager.Get(tag);5 ^5 R c3 M9 ?) y# s8 {1 w7 ^
return (T)to;& R# }* m2 V' v3 @& S
}' f3 }$ v9 D( H; \+ L) ]
catch (System.Exception ex)7 H' w0 v5 n! J2 K
{1 q6 ? O" D* [1 ~
UI.GetUI().NXMessageBox.Show("Message", NXMessageBox.DialogType.Error, ex.Message);! w$ H# d7 d7 O& i+ O+ x
return default(T);4 P& T" H# _ t# O4 A
}
) S6 p- Q9 N5 s }
' f2 p8 S# l) r/ q
0 K# v/ c! A; @" |% C- f. S/ w7 K! K$ N
|
|