|
请使用QQ关联注册PLM之家,学习更多关于内容,更多精彩原创视频供你学习!
您需要 登录 才可以下载或查看,没有账号?注册
x
0 f; Q* s& {) E6 R& y8 dNX二次开放源码分享: 获取装配下所有的实体+ W+ u) _# q6 C
1 C2 M0 D+ F: x. \* f( P8 D
3 {9 s* c- j, E; J, L
- s8 g) v1 n( gpublic class report_all_bodies_in_assembly_level4 J9 ?1 D) g9 N* I
{% f- U5 q$ J5 [! i$ }/ d2 [* ^( h
public static void Main(string[] args)
3 e X0 E1 v5 X7 i$ E" F9 a; a {- |7 W0 _. g2 _3 o- @. V
Session theSession = Session.GetSession();
! e( \5 O/ s- L( Q8 `) ` UFSession theUFSession = UFSession.GetUFSession();
4 x" \4 i+ P! a ListingWindow theLW = theSession.ListingWindow;
2 W6 ~- Z/ u1 A" b& I& ?
+ L4 I, A& W/ y0 ~0 r7 O4 N, R y4 b4 Y/ k" S( v8 a
Part theDispPart = theSession.Parts.Display;
! h$ F. e! c+ ]2 F. n" i9 O7 t List<Body> theBodies = new List<Body>();
8 U6 k" p- Y u3 d' J* [ Tag aTag = Tag.Null;
1 P6 g5 M7 I$ _) M F% e int type = 0, subtype = 0;
) K4 `" E4 b% p/ [" O) p) a8 n- S
_+ _. i3 _- b9 p! q
theLW.Open();
/ s. X' r9 h: i/ I do3 l! B; Z' o4 k/ n
{0 M: Q, N: S: Q9 i5 u
theUFSession.Obj.CycleObjsInPart(theDispPart.Tag, UFConstants.UF_solid_type, ref aTag);
1 E: c+ k0 [, `3 } if (aTag == Tag.Null) break;
+ d) g& b* U+ w) s theUFSession.Obj.AskTypeAndSubtype(aTag, out type, out subtype);' u' j: K; S! `6 g! k1 _* C0 ~
1 \, |) O1 B x: m% ~; T. f3 {
! c1 s* l% g/ q8 {9 M- p+ q6 V if (subtype == UFConstants.UF_solid_body_subtype)- i1 @( M7 d/ w
{
( }$ \8 U. X& k: W) C1 v" a Body obj = (Body)theSession.GetObjectManager().GetTaggedObject(aTag);
# U# {' k: n2 `! c) [' V if (obj is Body) theBodies.Add(obj);7 p, y2 [# _0 Z1 K8 j! {
}
0 f0 c9 u# D/ z1 i! c+ A5 x } while (true);
# w; W) Z% ~6 |: Z0 g0 t# U+ \3 `) [# X. O- ?/ t) I
* R% g5 v8 M9 A/ i theLW.WriteLine("Bodies in the list: " + theBodies.Count.ToString()); o: M+ d* S0 m- ?. v/ o
foreach( Body theBody in theBodies )
8 q( d1 D- f ?& l& B {& P0 U3 p4 Y# p" [& q
if (theBody.IsOccurrence)- W7 e; L1 ^# Z; Q: J
theLW.WriteLine(String.Format("Body: {0}, Layer: {1}, IsOccurrence: {2}, Component: {3}",3 w* m& ?- e% m: W
theBody.ToString(), theBody.Layer, theBody.IsOccurrence, theBody.OwningComponent.DisplayName));" N4 w) l7 y1 w8 q& w
else* W, ?5 q y) E8 P( X. B7 d3 s v" @
theLW.WriteLine(String.Format("Body: {0}, Layer: {1}, IsOccurrence: {2}, Part: {3}",, a. S# N# x0 C
theBody.ToString(), theBody.Layer, theBody.IsOccurrence, theBody.OwningPart.Leaf));: r x4 f2 Y! @1 ]
}
' z9 r# P0 h( n$ e$ A# V }& `1 s. I0 X; O7 s/ i
}
! B- y: N5 \! w, }6 K) S# i% v2 v. q7 V
|
|