|
Tag到NXObject的转换2 B/ B3 r2 m+ v
M2 f7 n2 C: J
/ n0 n) D8 G+ p1 X% \$ wufun 里的Tag 转换成 NXOpen 里的实体对象" y' h/ g. G- @8 @
( U! L: t% Z+ ?" |C++) t7 t, W& l: G- ^% e+ s1 v
5 B+ I( E7 K7 n0 B( Y9 d1 ^% f; y5 q2 s$ I7 _$ |
tag_t obj=NULL_TAG;9 t- ^/ ` C$ T7 `; Q
! L [3 J- e7 c9 O$ v6 k
Body *body1(dynamic_cast<Body *>(NXObjectManager::Get(obj)));
6 f) m% r( M+ p* m$ I+ @( T+ c7 V( x: w% [# N0 z/ o
Assemblies::Component *component1=(Assemblies::Component *)NXObjectManager::Get(obj);$ I, i, w' ~7 b, _, w( K
# u, I6 x* O$ ?5 S5 F q
0 t& Y. b( }: \3 K
6 w7 Z+ x' E% o+ G& C4 n9 @4 V
5 \' z: ]$ `; a, q7 @4 l+ q3 M* U$ n: J2 r
=====================================================================
0 f% p7 Q4 K& p: m v; x
! B9 r- b, }( f! X) Y1 o9 o" UC#
2 ]6 V7 b; C' Q: h' q( _ /// <summary>5 W* Z* f$ u) I
/// Tag到NXObject的转换
- `, s8 C8 y8 v /// </summary>$ S- b& R0 U6 z6 {" X( o
/// <typeparam name="T">NXObject的类型</typeparam>
( [3 C1 l! g' p* e, E /// <param name="tag">tag号</param>% V) s! q9 }/ B. C* V9 A/ [
/// <returns>NXObject</returns>, F7 v" c$ @1 k' R- t- U3 F3 J
public T Tag2NXObject<T>(Tag tag)! D4 Q/ n- }6 N
{
& [& Q% T9 U8 _! e4 m% y% J try$ t3 `! D2 e3 T& J* J
{
- V/ i5 V( l1 i9 } object to = NXOpen.Utilities.NXObjectManager.Get(tag);
D# c5 O! s- C8 h* Y; j+ p return (T)to;
+ A) S8 `: z2 n/ {4 o) z }
& {" V; H. A# N% ? catch (System.Exception ex)
6 r7 \% N m+ B4 v {
$ z8 H' A. O/ m5 w( U: ] UI.GetUI().NXMessageBox.Show("Message", NXMessageBox.DialogType.Error, ex.Message);
* y$ X' G- n# S return default(T);- i; T% z6 Q; g
}
$ y- @# w3 g1 O }
* t; {! H" S1 U/ p4 v2 T! N; V8 U$ n! _6 W
* P- J; [6 S7 @0 ?% m |
|