|
|
请使用QQ关联注册PLM之家,学习更多关于内容,更多精彩原创视频供你学习!
您需要 登录 才可以下载或查看,没有账号?注册
x
1 s/ z8 a( m: i
NX二次开放源码分享: 获取装配下所有的实体
) b+ i6 `: z" o! Q
8 V$ a) V p0 | _7 O. [
9 u, j4 k/ b* W' v2 [8 r3 Y* r
7 |/ @+ X* [* x, `* Epublic class report_all_bodies_in_assembly_level1 b7 |4 ~$ ~- T7 c
{
1 _, B# {/ q1 |# I* b. T public static void Main(string[] args)' I2 v3 K0 w3 D n" e' \: |/ E" Q
{4 }" s/ z5 a0 s2 e5 S
Session theSession = Session.GetSession();
: {* l4 r$ I2 M! c5 j' m7 b9 X UFSession theUFSession = UFSession.GetUFSession();
) ?1 ^8 P& @, E ListingWindow theLW = theSession.ListingWindow;3 G+ I0 \# O" u
8 f, M b { K8 ]8 V) e. E
) \3 w" l, \! i8 p Part theDispPart = theSession.Parts.Display;
9 Y4 h$ ], T8 j' A: W9 A' s) b; ^ List<Body> theBodies = new List<Body>();2 k B) @9 b) |; ~% u$ i# P
Tag aTag = Tag.Null;
4 H: U1 F+ P3 u6 L7 y0 k int type = 0, subtype = 0;% ?. X8 N& P) q" E4 d
D2 h/ x2 b) `* u, I
) M3 }! q$ g( R! B0 z; d* l$ u theLW.Open();
! ]8 \( V: A$ M6 C% F' s C: A" k do
, o& t5 R) T6 [1 `+ a* P) J8 S {
) d: g. ~/ N$ K theUFSession.Obj.CycleObjsInPart(theDispPart.Tag, UFConstants.UF_solid_type, ref aTag);: `. S8 }# b5 p
if (aTag == Tag.Null) break;
& q4 f& W' y7 H+ e4 t/ B* y, p* [ theUFSession.Obj.AskTypeAndSubtype(aTag, out type, out subtype);
" A; d# g3 q0 P& M) U* V0 n
9 m; o( @# o! W* E" V1 e) l' _6 k# q+ I
if (subtype == UFConstants.UF_solid_body_subtype)6 Q: z7 K+ m8 w3 w- L
{& u8 s+ f1 d2 @1 V( y
Body obj = (Body)theSession.GetObjectManager().GetTaggedObject(aTag);
+ |. {/ V* T/ L% e* w% C if (obj is Body) theBodies.Add(obj);' W3 M0 e! d0 U9 C/ M
}$ ]: w8 u" r; q/ L( q
} while (true);
# q/ M7 l" b, k e) K1 r* R
1 N! |( n: A, t6 p( h: B$ i- T% O( e5 @ V$ t% i
theLW.WriteLine("Bodies in the list: " + theBodies.Count.ToString());) v7 ] n; [& U
foreach( Body theBody in theBodies )4 b/ D3 V- }8 v5 n8 J0 i: G1 }
{! H1 k! Y K9 q n3 k- ]; @8 k
if (theBody.IsOccurrence)% W. P" I0 L9 T
theLW.WriteLine(String.Format("Body: {0}, Layer: {1}, IsOccurrence: {2}, Component: {3}",% I$ v7 H9 Y4 W0 x
theBody.ToString(), theBody.Layer, theBody.IsOccurrence, theBody.OwningComponent.DisplayName));
4 I( t- K3 q* |* g else
% o3 T z c2 a" F: | theLW.WriteLine(String.Format("Body: {0}, Layer: {1}, IsOccurrence: {2}, Part: {3}",
. H) Q a9 p) `# J5 N! Q theBody.ToString(), theBody.Layer, theBody.IsOccurrence, theBody.OwningPart.Leaf));
2 U: ^9 L( b2 a/ K( h' j* b/ H# Z }
/ [0 z$ C) v$ Y6 N7 X2 r& v: L. \6 N }- c5 i! v2 V* s- K2 r$ o# G0 R/ Z) C
}
) j0 E' b8 R9 C# q: e& Z0 g0 M
`/ v% S6 J1 F4 A8 E; Q. {5 `9 n: Q& o |
|