|
请使用QQ关联注册PLM之家,学习更多关于内容,更多精彩原创视频供你学习!
您需要 登录 才可以下载或查看,没有账号?注册
x
8 o% A; O& f! ]& b4 yNX二次开放源码分享: 获取装配下所有的实体7 j( b9 Z+ J% Z. B4 Z* n; {
# O: U* a/ l+ \. K3 \1 c$ F
% d& b1 O' f0 C, X$ v p
+ x+ l- O, F$ cpublic class report_all_bodies_in_assembly_level7 h* l1 W: t) [
{: a8 y3 n8 j1 z! g; ^5 _& c
public static void Main(string[] args)
. P9 }0 f, g0 f } {
) w" c! \' T: ~2 ]7 K3 }' ` Session theSession = Session.GetSession();
0 H* x/ j3 _4 l1 P) D% D) n( ^1 s UFSession theUFSession = UFSession.GetUFSession(); o/ O# ~% B1 h) a9 J$ \
ListingWindow theLW = theSession.ListingWindow;
3 Z6 D) L0 f) y4 V5 n/ o- V( ~0 }& _. v. ^- k3 g* D
# f" c' `; V. k0 d/ X
Part theDispPart = theSession.Parts.Display;
8 A. ?6 W2 p3 m. y List<Body> theBodies = new List<Body>(); Y1 @7 F/ X% I+ l3 }( r
Tag aTag = Tag.Null;( ~0 O+ i2 ^; I( S( r1 b1 \
int type = 0, subtype = 0;7 m2 t$ t1 S* o' o- G+ z5 U
+ o) C! c' ?/ y
% ]4 x: [. F H% s theLW.Open();1 O" m! V5 K* e
do& k9 M6 o# n! b' ?$ s
{
" y4 J, M+ g% k, W N, a$ h1 K6 ? theUFSession.Obj.CycleObjsInPart(theDispPart.Tag, UFConstants.UF_solid_type, ref aTag);
! k. A" x7 [7 x% r, Y$ [0 f if (aTag == Tag.Null) break;
# e% B) j) r$ J+ b2 ? theUFSession.Obj.AskTypeAndSubtype(aTag, out type, out subtype);/ |# Z# q; i1 P6 S- Z: i5 w% ]
4 e" U$ P5 j8 N) @/ \! C* V
: N6 Y5 b, R0 t0 t; R" @: V* \ if (subtype == UFConstants.UF_solid_body_subtype)
5 y/ Q7 m/ Y9 ?+ {. _ {/ V! K# _( X. K% W" W. Q8 h
Body obj = (Body)theSession.GetObjectManager().GetTaggedObject(aTag);3 e' G. M1 P+ r; J. v
if (obj is Body) theBodies.Add(obj);
9 B2 ^% g( N/ M) ?! R9 ? }
! S( ^- l* e$ V& j } while (true);- [4 e9 v4 \1 F+ n
* s: d; Z. R* F8 q: C. Y, F
6 v) c5 D# U5 E
theLW.WriteLine("Bodies in the list: " + theBodies.Count.ToString());0 c8 `- O3 L: Q, {2 g
foreach( Body theBody in theBodies )
/ x* t' p% {& g {
' v' d8 U/ a4 ~6 r! }0 _9 u3 r if (theBody.IsOccurrence)
( q9 H/ m( K5 }- K theLW.WriteLine(String.Format("Body: {0}, Layer: {1}, IsOccurrence: {2}, Component: {3}",
- O+ T% w& r7 R theBody.ToString(), theBody.Layer, theBody.IsOccurrence, theBody.OwningComponent.DisplayName));) q7 ^5 |2 k& B* X
else7 E K* q8 ^* K0 Q/ l2 y1 U8 G
theLW.WriteLine(String.Format("Body: {0}, Layer: {1}, IsOccurrence: {2}, Part: {3}", Z! u: W; r/ N0 D; Q
theBody.ToString(), theBody.Layer, theBody.IsOccurrence, theBody.OwningPart.Leaf));' u9 j: L ]' g' `$ e/ Q/ `
}1 x6 x/ A4 }! K
}
* h- H: d; z# {+ {}
+ s1 ~7 W; `! i9 ?( k- c$ y# d7 }) `3 G/ Q$ A& n! |6 V' V
|
|