|
|
请使用QQ关联注册PLM之家,学习更多关于内容,更多精彩原创视频供你学习!
您需要 登录 才可以下载或查看,没有账号?注册
x
: ]. \# Y. ], x' f8 KNX二次开放源码分享: 获取装配下所有的实体
5 T& ]' L7 k4 A) q5 o* j( p+ x. U3 e2 W) [. V
v9 ~0 V$ H# e. }& j! y
7 Z2 a8 H2 r v2 O+ c3 k) Jpublic class report_all_bodies_in_assembly_level8 [$ Y3 B- D% v+ R% v7 d- `( b
{9 p9 Z, Q$ \ S
public static void Main(string[] args); q4 I4 u, E7 Y& p* [
{5 H4 F# W& b2 J3 T" E& E
Session theSession = Session.GetSession();8 n/ n5 B8 v/ f; l8 m L' C( x
UFSession theUFSession = UFSession.GetUFSession();
0 ?, H' W' Y0 O% B4 C* z ListingWindow theLW = theSession.ListingWindow;. Q' y0 T& o( x% E; f0 D
" |) H3 f( Y4 t" {
9 A1 M, `6 A! P2 } Part theDispPart = theSession.Parts.Display;9 f5 t# @3 K$ t* X. R1 Y( K
List<Body> theBodies = new List<Body>();$ Q w3 X3 ]- w7 I+ O0 R3 F6 y0 P
Tag aTag = Tag.Null;
- X N, y9 u! k! [8 i- r int type = 0, subtype = 0;
! x) n: Z% y) }$ i5 X
& Y: u9 j, ^+ _, w5 ~; P
" Q. D, U5 M: C theLW.Open();
* c- }/ f! G0 V3 c0 [ do
3 }7 P# @ E# u {
; u" O2 a, Y+ \0 @" d* y/ P theUFSession.Obj.CycleObjsInPart(theDispPart.Tag, UFConstants.UF_solid_type, ref aTag);
, a& a0 m ~( U8 `% B9 h1 } if (aTag == Tag.Null) break;: Y: }" v9 F: ^# a9 X
theUFSession.Obj.AskTypeAndSubtype(aTag, out type, out subtype);" I+ y4 `/ t F
6 `# u3 V P; d9 R1 W0 F5 q3 {4 u- u, B( m9 X9 r2 B" b7 z& J; j
if (subtype == UFConstants.UF_solid_body_subtype)
0 H( k* x0 [* f5 L, w& p {
" z. ?$ R/ `# e, }8 t# d: @2 ? Body obj = (Body)theSession.GetObjectManager().GetTaggedObject(aTag);6 u9 ^1 K y; d0 n* r8 d! a. v1 e
if (obj is Body) theBodies.Add(obj);/ T) R! e; _5 @/ k' {4 P
}% W0 c( @5 J1 D) u. {
} while (true);1 C) f8 B& n+ k
# |, L7 i3 H) P+ q9 F6 O4 H7 [
4 S+ C: L" O' b( e3 Q
theLW.WriteLine("Bodies in the list: " + theBodies.Count.ToString());8 Y5 S' v: ?9 D" W# a2 m. x
foreach( Body theBody in theBodies )
) A" z' }; W0 { {0 p7 v4 X% C, h& y/ a) v) i( P
if (theBody.IsOccurrence)/ L. n7 s1 k/ _3 h. e- ^9 v
theLW.WriteLine(String.Format("Body: {0}, Layer: {1}, IsOccurrence: {2}, Component: {3}",
+ ?, g7 H- ]7 i7 r* P4 l$ o3 e% B- h theBody.ToString(), theBody.Layer, theBody.IsOccurrence, theBody.OwningComponent.DisplayName));% H( D3 A, S5 \" _; f
else
4 I3 X, P3 q9 F: W, T& F theLW.WriteLine(String.Format("Body: {0}, Layer: {1}, IsOccurrence: {2}, Part: {3}",7 p5 I6 m1 j" D
theBody.ToString(), theBody.Layer, theBody.IsOccurrence, theBody.OwningPart.Leaf));
& J" ]2 C9 n. _' n9 C }! a* } A4 W, @ \9 _7 ]( K
}* A1 W. c: V" o# n
}
2 V. U8 e- a1 V8 x
9 ?& M$ x# u. r8 U, n7 x) V |
|