|
|
请使用QQ关联注册PLM之家,学习更多关于内容,更多精彩原创视频供你学习!
您需要 登录 才可以下载或查看,没有账号?注册
x
; P# L, n1 }5 J- Z( n
NX二次开放源码分享: 获取装配下所有的实体
. @* z4 T: {6 g# K" Q( f1 g3 [; n# A5 v# P* c# D3 V8 `
. F, Q0 t" j2 l; `9 {9 {
9 }" g- B8 m5 S( J- Rpublic class report_all_bodies_in_assembly_level5 b, u; s4 D6 b4 C" h
{
* v3 t9 M% ~0 k! r: o; U public static void Main(string[] args)4 O5 |# o% q) G& B
{1 N7 l6 e- v+ m
Session theSession = Session.GetSession();* [4 [: f0 m) P- y9 m
UFSession theUFSession = UFSession.GetUFSession();5 d* D9 W9 F0 \, v: z' B
ListingWindow theLW = theSession.ListingWindow;
3 K8 R! ?0 w; `9 c: r: g2 M+ V
5 i7 w6 [8 N3 @- _1 y
Part theDispPart = theSession.Parts.Display;. S! t. X5 B6 i3 I0 H5 Q& U
List<Body> theBodies = new List<Body>();
5 ]7 {7 U0 U w4 Q Tag aTag = Tag.Null;; I& k, D) o7 I
int type = 0, subtype = 0;* W: X4 ~9 C& m$ _) x2 C" a: J) S
) X5 N {+ j% o% F4 e+ P
2 i6 U9 u, n/ L' Z6 A7 {* s/ M theLW.Open();
) @% X: l$ w3 n do+ |3 E( T6 c) @( k
{
2 E+ G8 b, n" _% i1 K theUFSession.Obj.CycleObjsInPart(theDispPart.Tag, UFConstants.UF_solid_type, ref aTag);
' r$ _' b% t7 x3 _3 C3 Q' X if (aTag == Tag.Null) break;
& [- Q( E! c. Q0 V i theUFSession.Obj.AskTypeAndSubtype(aTag, out type, out subtype);& \3 j6 k$ F i5 ?8 b* @) ~' O+ t
# m* Y; j. ]9 S, b
5 t& S$ o, h4 Q# z5 w# B if (subtype == UFConstants.UF_solid_body_subtype)
( d' n' ?, C0 _' T {
# B0 g3 s( c9 A. F. J Body obj = (Body)theSession.GetObjectManager().GetTaggedObject(aTag);, Z9 O' o0 w/ ~: Z! p% O" |, m
if (obj is Body) theBodies.Add(obj);9 @2 Q: p1 X( _" Q" a2 M# V/ e
}
' |( E' o; C2 m/ j' O! v; x" r; ^" O2 W& x } while (true);
' w6 w7 c: I! c7 q
0 w, r# X0 B3 `4 y0 R. U- q: Q( L: K9 }6 A
theLW.WriteLine("Bodies in the list: " + theBodies.Count.ToString());
9 Z( ? T" F% N0 T; p$ W* m foreach( Body theBody in theBodies )/ F) n% }4 k+ d6 M+ }
{
1 ]0 w1 A$ W2 b/ }1 I) c! {5 d if (theBody.IsOccurrence)
- B& b* D/ F3 A5 _. S% F5 U' N theLW.WriteLine(String.Format("Body: {0}, Layer: {1}, IsOccurrence: {2}, Component: {3}",; n: l* F' y" g& F5 \
theBody.ToString(), theBody.Layer, theBody.IsOccurrence, theBody.OwningComponent.DisplayName));
3 K: t/ \* d: E+ R4 |, N; ~- c3 L' Z8 S else
) B6 k' M9 X0 o9 H5 E theLW.WriteLine(String.Format("Body: {0}, Layer: {1}, IsOccurrence: {2}, Part: {3}",
5 P! R. Z# c' w, Q" e, ] theBody.ToString(), theBody.Layer, theBody.IsOccurrence, theBody.OwningPart.Leaf));; _7 t1 Z6 O* l3 \) E2 y7 a
}3 d$ i/ @( _# {, I& P
}) E# c; S6 G! Q. `% ~
}$ S$ k5 g) K& w( C9 k; _+ Y4 o: k
, I2 p, W4 ]% H8 x! n) a
|
|