|
请使用QQ关联注册PLM之家,学习更多关于内容,更多精彩原创视频供你学习!
您需要 登录 才可以下载或查看,没有账号?注册
x
; X8 _: G5 S# A: I& Y/ zNX二次开放源码分享: 获取装配下所有的实体) h. h! ~$ T: ~
0 u6 e" o. ?% l4 I0 K1 s
* p" Q9 O/ n' a _# [* f
+ ]& b+ N/ g6 S- k1 Spublic class report_all_bodies_in_assembly_level
$ {- I+ U+ S1 A0 w$ f" Q! l{2 I! a9 R2 c% N9 w% @
public static void Main(string[] args)% m. _" [9 ]# Q5 Z
{$ V- h" A2 S4 z$ ~" O& ]
Session theSession = Session.GetSession();. e2 M( ]/ G7 ?' {# ?* _
UFSession theUFSession = UFSession.GetUFSession();# R8 s/ P9 h+ R
ListingWindow theLW = theSession.ListingWindow;
" ]/ x' m5 e$ y
2 P+ `: s3 f7 ^0 w* M: j5 m! o2 N" @) K8 L: k. K
Part theDispPart = theSession.Parts.Display;0 j; l* K! ?2 P4 j- ^) T
List<Body> theBodies = new List<Body>();
& m" K4 D5 M1 ~3 f5 F5 a1 J8 Y Tag aTag = Tag.Null;
8 a, O, d% {2 C9 A8 ]6 h+ d int type = 0, subtype = 0;
4 K: M3 n- ~7 a$ O8 t+ q l- U" C* ^
! G0 W. G3 n; h, d' V
: c& X" `0 v1 L" P theLW.Open();$ F. g2 A8 |1 K1 [. A0 P
do
. \8 L* D' e4 ~# L& q) w+ s {+ s# c8 r; i8 J" I+ G2 K i/ d3 n; ?3 x% R
theUFSession.Obj.CycleObjsInPart(theDispPart.Tag, UFConstants.UF_solid_type, ref aTag);: [$ F" B2 b4 T) C6 G' C! C1 k
if (aTag == Tag.Null) break;% e0 E7 y2 R. q
theUFSession.Obj.AskTypeAndSubtype(aTag, out type, out subtype);* X; f: Z5 d& \ C6 [/ `2 e
2 E1 o6 B7 [9 ^# ^1 B- Q/ {" b ?) q
0 U- d. Y) a3 Y( N$ E: u: c
if (subtype == UFConstants.UF_solid_body_subtype)
1 I* }. k/ u8 ]$ W) Y$ \* [: e {
4 Z$ R! H% V; }7 H( \- n Body obj = (Body)theSession.GetObjectManager().GetTaggedObject(aTag);
( V" j9 j, B9 s3 N8 l& Y8 `5 V if (obj is Body) theBodies.Add(obj);
& N- ]2 Q8 s+ {! `2 V% @6 o }& L4 E) {) R4 Y/ ]
} while (true);- s4 [9 J' [1 D, I3 B* Y0 b! p
7 d O2 b+ }6 l7 O | v6 `& H
; \" J2 D/ M' I5 y1 c/ [* X
theLW.WriteLine("Bodies in the list: " + theBodies.Count.ToString());
\9 D* ~1 H* }# P7 Z1 z foreach( Body theBody in theBodies )1 z- [% z3 l, p. s/ L+ u1 L
{- q2 T4 j, ~7 ]( L [
if (theBody.IsOccurrence)% S( `9 b3 T* X5 G# i9 F1 ]
theLW.WriteLine(String.Format("Body: {0}, Layer: {1}, IsOccurrence: {2}, Component: {3}",6 D; J6 T( W5 F1 a1 C
theBody.ToString(), theBody.Layer, theBody.IsOccurrence, theBody.OwningComponent.DisplayName));6 _( q' ^5 Z3 B4 P6 R/ s8 m% X
else
2 Y* C4 |: ^8 P! A# t& K: m theLW.WriteLine(String.Format("Body: {0}, Layer: {1}, IsOccurrence: {2}, Part: {3}",. V7 }1 m8 t* w. v
theBody.ToString(), theBody.Layer, theBody.IsOccurrence, theBody.OwningPart.Leaf));
c" G6 _/ a( u }0 Z9 j( L2 G0 E4 h: R! x8 y
}
6 b& Y: ]- J( {- `, {; J% P# C}* m$ `5 h- V% o( c3 }
. |- d) q* p1 ?. d1 s0 B6 K |
|