|
|
请使用QQ关联注册PLM之家,学习更多关于内容,更多精彩原创视频供你学习!
您需要 登录 才可以下载或查看,没有账号?注册
x
/ |+ c; e6 h* B) yNX二次开放源码分享: 获取装配下所有的实体
( J3 v& n5 u. d" N8 A; Q8 p! X q4 Y' j: F: M
# Q9 z( m9 s# G6 Q8 o+ [
/ u$ g- B3 x+ u Mpublic class report_all_bodies_in_assembly_level
1 @( H" K! p* q6 f. D{
; V9 O% y; `" |/ \, i public static void Main(string[] args)& V+ F: x3 k5 W0 Y/ j2 l; W
{" @, ?! V, O, s
Session theSession = Session.GetSession();5 B/ E; o$ `5 [6 ?* `
UFSession theUFSession = UFSession.GetUFSession();+ j1 E3 f. w5 o) z; v- y
ListingWindow theLW = theSession.ListingWindow;2 H: V% |. D5 p1 |% R9 |. q& C- p/ r
v* B8 `/ y: J# [* s8 E# B, @: D& q- M+ e6 F5 o2 E
Part theDispPart = theSession.Parts.Display;
1 W; t8 c, j: g" ?( Q ^/ S List<Body> theBodies = new List<Body>();
/ W0 E2 J* h' ^# g7 s# I Tag aTag = Tag.Null;( Q( i _7 M0 v. p' u
int type = 0, subtype = 0;9 y+ t0 g1 A* t6 g
- F' L/ g$ l& y9 Q
' Z. ?( M7 i3 _" g
theLW.Open();4 c7 ^/ s" Q2 W7 p i
do2 O6 F' N. K& U# d
{
4 Y' \0 F3 O! v! ?7 b8 Z; d9 M theUFSession.Obj.CycleObjsInPart(theDispPart.Tag, UFConstants.UF_solid_type, ref aTag);
- k8 A y; z) U m/ ?; Q+ v if (aTag == Tag.Null) break;
$ n0 n3 }/ D- F; a! Q theUFSession.Obj.AskTypeAndSubtype(aTag, out type, out subtype);
% U8 \" N( R* e/ |- d' A9 _6 I) k0 V" K% [. s; {
/ p1 a. A1 B/ I if (subtype == UFConstants.UF_solid_body_subtype)0 w- p Y0 ^: K% N0 w( g1 W5 Z
{6 @! q4 m1 o" M( \) A
Body obj = (Body)theSession.GetObjectManager().GetTaggedObject(aTag);
: m0 x, m; W. L+ B& U* H3 N if (obj is Body) theBodies.Add(obj);8 F8 z- a# [. U/ u
}
. e, T) ?) i6 ^2 \# J } while (true);* l4 g1 E$ J8 c
" N8 Q% T+ \5 L( p! t. C
* l( m) N* {; T# ]+ U7 H0 I- @: A theLW.WriteLine("Bodies in the list: " + theBodies.Count.ToString());
6 k; j+ g" t# h( ~! h foreach( Body theBody in theBodies )+ ]" V) [* O& `& X
{
) s l5 X5 l7 Z: A8 T+ h( {0 \ if (theBody.IsOccurrence)& H8 z- J' C& u6 X1 ?
theLW.WriteLine(String.Format("Body: {0}, Layer: {1}, IsOccurrence: {2}, Component: {3}", A, U2 I/ u( X# N* d; X
theBody.ToString(), theBody.Layer, theBody.IsOccurrence, theBody.OwningComponent.DisplayName));
9 B' ?, O6 r8 S8 ?# @3 I2 [ else3 H. o0 v. t* m6 r. G; B$ W- X
theLW.WriteLine(String.Format("Body: {0}, Layer: {1}, IsOccurrence: {2}, Part: {3}",
6 U4 O, {- B: k/ W theBody.ToString(), theBody.Layer, theBody.IsOccurrence, theBody.OwningPart.Leaf));# i6 \" ^. D1 z: B8 Z6 }3 S* a7 U
}
8 L" ?4 {, y! q! Z }
3 j* A4 B0 V' m t* S7 {}
. X4 |% S: ?' ?" k( r
4 w2 b* \$ D$ K" o |
|