|
请使用QQ关联注册PLM之家,学习更多关于内容,更多精彩原创视频供你学习!
您需要 登录 才可以下载或查看,没有账号?注册
x
* n& K/ g" F$ i$ X1 |* Y
NX二次开放源码分享: 获取装配下所有的实体$ s( L5 d; P9 w9 K7 L1 |
" {5 _( ~7 K. n7 b. @* v3 C3 R+ S4 ?6 Z/ Q7 S8 z7 `
; X8 J% s' P8 @ opublic class report_all_bodies_in_assembly_level
& {2 d' W3 s5 D4 }2 @( \/ L6 _{. R- O( h2 Q; J4 A- \6 ~
public static void Main(string[] args)
3 Z" k, |" r4 Z$ [1 Y( l( ~ { i% A) p2 f8 t/ |2 u; G
Session theSession = Session.GetSession();/ R% i+ t" g# }' y
UFSession theUFSession = UFSession.GetUFSession();
4 v' f* x+ y6 T( q! ~% [* L ListingWindow theLW = theSession.ListingWindow;2 F X: j( A' N: S P
) Z- Q D$ _/ p4 p+ W6 v3 Z$ X9 D1 S7 X: w) P) [
Part theDispPart = theSession.Parts.Display;: B" f- ~- t% i- [3 Q) m8 j
List<Body> theBodies = new List<Body>();
) w J8 @7 W; @/ n& ~# J$ X0 {9 u Tag aTag = Tag.Null;
|3 Y, y( u* `. V: Z) U v/ c; i7 a int type = 0, subtype = 0;6 a2 I9 H6 j) v) t* A
( k+ I6 w8 ]* M3 p/ m- t0 z
# ~* X! I4 k$ u* r
theLW.Open();6 a3 o- Y$ H' y; Y% S8 o
do
$ r+ H) @! a* {' Z5 Z. R" M5 o {
7 W/ Y: s# N% X& N+ f" C theUFSession.Obj.CycleObjsInPart(theDispPart.Tag, UFConstants.UF_solid_type, ref aTag);
0 V7 E9 E' O# \, ]7 U( s' d if (aTag == Tag.Null) break;& F8 a! L* g0 P3 I
theUFSession.Obj.AskTypeAndSubtype(aTag, out type, out subtype);! N' j' D9 J& p
+ q8 ?4 N% S( p' s
/ X, R! U) w8 k. O9 d if (subtype == UFConstants.UF_solid_body_subtype)* r# [) _2 m9 e, L2 c6 n
{7 ~7 }$ M; a5 A, I% W
Body obj = (Body)theSession.GetObjectManager().GetTaggedObject(aTag);" O+ }( ^6 m! o0 l. J
if (obj is Body) theBodies.Add(obj);
1 J0 w2 W, }8 M6 y }8 @9 [4 m# z" k4 W* U- Q
} while (true);
: e2 T# {; _ V ]$ o
- `( g* M! I( r7 c8 N$ g$ I
" |% N" O ^9 y" F$ j Q. y theLW.WriteLine("Bodies in the list: " + theBodies.Count.ToString());( X2 N) P+ |. X: h9 Z5 [/ Z
foreach( Body theBody in theBodies )
- W- @- D- u- q# p {& g/ d# t% \7 |9 G3 v; I& x
if (theBody.IsOccurrence)3 M" L+ `0 p* q# G( s9 D& p! D5 d% V
theLW.WriteLine(String.Format("Body: {0}, Layer: {1}, IsOccurrence: {2}, Component: {3}",1 U" U+ V) J6 J* M6 a: e+ j
theBody.ToString(), theBody.Layer, theBody.IsOccurrence, theBody.OwningComponent.DisplayName));
0 ^& a; m; V& E3 | else5 Y( a& q- [4 S: s3 x% }+ |% `' O- O3 @
theLW.WriteLine(String.Format("Body: {0}, Layer: {1}, IsOccurrence: {2}, Part: {3}",
9 s W7 t- ?+ }0 p8 I* S M- k- }! X theBody.ToString(), theBody.Layer, theBody.IsOccurrence, theBody.OwningPart.Leaf));" x/ r2 e% @* Q0 H" K- K/ j
}
* A- `/ o( W. }7 T }8 L1 n+ y8 e1 F y9 I
}
0 t' P, g+ ?; Y7 s {& ~
) `% O5 A+ E3 T8 }( c+ j |
|