|
Tag到NXObject的转换
* r! w1 t: F; j$ S6 J
6 ~. G1 [. m# y6 p8 m' [6 d( \7 v; n5 x) R1 E7 o- u/ u6 V2 F& |
ufun 里的Tag 转换成 NXOpen 里的实体对象3 I; {- U; @6 k4 B( H( w
' B7 G' Q7 q3 B; LC++! i. n9 N0 r* F* B0 h7 F2 p0 L; n
/ v# @/ K% N. G) v! B
# a' N: m% j! t3 m! }. U1 \ Otag_t obj=NULL_TAG;
; S+ u: J0 A& c0 D, C. w& o; F. d: K& j' a
Body *body1(dynamic_cast<Body *>(NXObjectManager::Get(obj)));
( Y9 c* p4 L# d2 k. O- e; [: ~& \; \2 o5 C
Assemblies::Component *component1=(Assemblies::Component *)NXObjectManager::Get(obj);0 Q7 r e" u+ H5 b, j- K- h
5 E3 `- M# a% Z, y7 I) b
- e; u' i$ c0 F( O
. e3 e6 {- s7 Y
* E2 q" C: v3 A$ Q" g
2 N" g. M# A! A4 q=====================================================================4 a: @- [3 B) t$ s5 R
2 |: o! F7 @, ^( bC#& m& e( w" [7 U v
/// <summary>+ L' s) j' T2 n9 G+ P' x7 x
/// Tag到NXObject的转换
: d0 w2 R: ]7 k p# M /// </summary>4 |. @) p& g9 N) g% P) L/ n
/// <typeparam name="T">NXObject的类型</typeparam>; ~, l" ?0 P/ e, k5 f. C- s. z
/// <param name="tag">tag号</param>5 I0 y0 \6 H" |' {) q4 Z# ~$ }* y
/// <returns>NXObject</returns>
1 L) P9 z; d8 J8 M7 ?7 R/ R; D public T Tag2NXObject<T>(Tag tag)
2 l1 x6 o" Z: D6 Y& D0 H {6 @: g7 j; j# l* ?
try- j" `7 M4 K* e. u6 ^, X
{" @! s- A. B0 I, T# {
object to = NXOpen.Utilities.NXObjectManager.Get(tag);7 S7 S9 {& S2 |1 o9 Y$ U
return (T)to;
9 ~' s8 g1 n; u2 h! |" H; D }- k9 T2 F/ v. f5 j
catch (System.Exception ex)
k R1 w1 H3 h! `2 d& \0 P. s {
4 ]+ d& t" r: C/ X! P UI.GetUI().NXMessageBox.Show("Message", NXMessageBox.DialogType.Error, ex.Message);* e2 o# {# E7 G5 o% C* y
return default(T);
/ s4 m( I! b8 D }
& \ z; e0 O( L( { }
$ H9 R P; n: F$ _# w' p' z4 b& D2 X/ a
- i; C5 p. U7 b& O" c* G( @' R6 H: W |
|