|
请使用QQ关联注册PLM之家,学习更多关于内容,更多精彩原创视频供你学习!
您需要 登录 才可以下载或查看,没有账号?注册
x
8 B6 j, |5 x: Q, u5 b
NX二次开放源码分享: 获取装配下所有的实体! n& |. D* s( X3 M1 B& t) ?4 ^5 p
. Q0 C5 W, i0 u' q# U4 @, u
9 W& ^+ M1 X l" z8 | L ~% P( d: X3 u9 u
public class report_all_bodies_in_assembly_level3 ~7 ^& i! [9 U2 }* U
{
- p% m) F3 t& M4 y/ e public static void Main(string[] args)
) `. X5 @5 `2 o2 D: y* C# C {
9 z8 r% g* @( M- e1 U% F Session theSession = Session.GetSession();$ q+ Q( _ R0 m: ~/ u0 K
UFSession theUFSession = UFSession.GetUFSession();* g( G! C P* F- q0 u& d6 i
ListingWindow theLW = theSession.ListingWindow;
3 d; T/ l4 k& p. v# L, l
* A# B% N5 ~$ P+ n& P+ k7 }2 k7 \$ f* t+ x' \
Part theDispPart = theSession.Parts.Display;& ^& c( k) `, k
List<Body> theBodies = new List<Body>();8 }4 r, A/ I; l1 g1 o+ n/ f
Tag aTag = Tag.Null;% g f( C" ^/ E
int type = 0, subtype = 0;
- ?+ R; ~% }' n* O y% i. U: y
$ }1 l4 s; F/ H
2 L! c% G! W1 | theLW.Open();
. c+ ?9 }+ m* o* [/ n: |( j. H do( F5 e$ g& l5 E% T: S1 G/ T
{
% n8 L7 R. |$ i/ U) T theUFSession.Obj.CycleObjsInPart(theDispPart.Tag, UFConstants.UF_solid_type, ref aTag);
. W; F% V$ E& } if (aTag == Tag.Null) break;" o5 }$ a! n. G- d/ @5 s( s) J; \
theUFSession.Obj.AskTypeAndSubtype(aTag, out type, out subtype);
, i* q q4 l# i( Z: K( l7 E1 X7 |
" S6 u. V$ r5 f# o# Y5 l. Z+ _
if (subtype == UFConstants.UF_solid_body_subtype)
$ U9 a; J9 x2 X, }. I- ] {: B" L/ X4 k! |% G* \, Z. ]1 M
Body obj = (Body)theSession.GetObjectManager().GetTaggedObject(aTag);4 e$ H; m! W8 X* i
if (obj is Body) theBodies.Add(obj);; ]* s; U0 }/ \+ I
}
1 }; l, _6 `/ l } while (true);1 k$ o" l, Z3 ^4 }0 @" C5 t, B
) y4 P! A: Y) O9 `% I/ ]1 L. g
% V5 A- Z% q& I7 z4 c* D theLW.WriteLine("Bodies in the list: " + theBodies.Count.ToString());
7 W/ a$ { J- |! l+ L- V foreach( Body theBody in theBodies )- \5 J. E1 b3 m/ v% k
{4 \+ l: r7 W+ e8 [
if (theBody.IsOccurrence)
7 d* g' j) h( F& `4 n, Y theLW.WriteLine(String.Format("Body: {0}, Layer: {1}, IsOccurrence: {2}, Component: {3}",
# G# W2 U2 v( Z/ p R theBody.ToString(), theBody.Layer, theBody.IsOccurrence, theBody.OwningComponent.DisplayName));
% E( u+ j: b& O+ m1 h else9 Y8 j- ]; @. \! H1 H4 F& q
theLW.WriteLine(String.Format("Body: {0}, Layer: {1}, IsOccurrence: {2}, Part: {3}",* F5 w) |( k7 D- v4 ^) T* y
theBody.ToString(), theBody.Layer, theBody.IsOccurrence, theBody.OwningPart.Leaf));8 L, U4 F5 r: B: ^. o0 }, M
}8 t$ d8 `7 t( u: ^1 A# }4 G6 _- I
}$ p- ?5 \/ K0 I: d1 b, ]
}. y. s2 c# ~9 G
5 |2 ?; E' z0 V
|
|