|
请使用QQ关联注册PLM之家,学习更多关于内容,更多精彩原创视频供你学习!
您需要 登录 才可以下载或查看,没有账号?注册
x
5 h6 E, _& F6 ~3 `( ~NX二次开放源码分享: 获取装配下所有的实体
& `4 N8 c* m* ~6 s0 f# J6 M, S8 D* y5 r6 J* @' {
6 Z I: y8 \* D/ K- T
+ r5 A- j9 n' R A' C! npublic class report_all_bodies_in_assembly_level! f4 h8 h% @# l; v/ Y. i! a( e3 |/ D
{
3 e0 G" n5 X# c; I public static void Main(string[] args)
0 T4 s% e1 }! ^* h* K7 | {# ^: c+ h5 d o/ k6 n; ^: z+ `
Session theSession = Session.GetSession();, Q' y+ C# g6 o& j
UFSession theUFSession = UFSession.GetUFSession();
, ?, f; `4 S9 ^8 p ListingWindow theLW = theSession.ListingWindow;
; y; J9 b; M1 h4 w) r( t5 p4 G* O/ }* N. Y
) |: h m# F. F+ l
Part theDispPart = theSession.Parts.Display;9 s" d$ V, m9 n6 ~% A3 V
List<Body> theBodies = new List<Body>();5 ] [9 l6 z! t+ O8 ~, M# P
Tag aTag = Tag.Null;$ H8 F q& r I* _; E* K0 @ }
int type = 0, subtype = 0;
6 S& l0 k. r' [
7 J6 B" r8 t) \4 b( f. v& m6 ]- ?6 h* ]8 r! _
theLW.Open();- }0 H/ e! y C! d) g
do3 e& Q* ~4 V0 T, d% e6 j
{
4 i3 v- I1 h/ W theUFSession.Obj.CycleObjsInPart(theDispPart.Tag, UFConstants.UF_solid_type, ref aTag);8 j9 q/ u% ], f1 I% s
if (aTag == Tag.Null) break;
! e$ _* h% r/ I& Y3 F4 }' E2 ~( a theUFSession.Obj.AskTypeAndSubtype(aTag, out type, out subtype);% \4 {0 U+ U/ G1 Q
' M) D1 O& Q2 c3 G
5 B1 H" N5 \( T( L' A2 s/ t: n4 L
if (subtype == UFConstants.UF_solid_body_subtype)) ^0 N0 p' j& ^! L! W# ~& }8 d% i5 L
{
- G1 B4 k! U- b+ K' c0 w Body obj = (Body)theSession.GetObjectManager().GetTaggedObject(aTag);
) \. X5 G. M9 b, b2 k if (obj is Body) theBodies.Add(obj);
* J; G0 T7 e' S; Z3 F } C. k; P: y3 H0 W& V
} while (true);4 @* i6 S5 O/ r/ V) ]- a" r
' l. m8 ^4 g. U* y, p2 @
" H( N3 |2 G1 q! h2 Z# g& E theLW.WriteLine("Bodies in the list: " + theBodies.Count.ToString());* ^% T* q+ M" F
foreach( Body theBody in theBodies )
$ X" g0 X* W& p( Q {7 t) n3 `2 {( {6 z; N: u
if (theBody.IsOccurrence)) s1 A8 u3 k5 n2 a, E
theLW.WriteLine(String.Format("Body: {0}, Layer: {1}, IsOccurrence: {2}, Component: {3}",1 C! n( _0 L) }
theBody.ToString(), theBody.Layer, theBody.IsOccurrence, theBody.OwningComponent.DisplayName));! X5 `2 b$ F6 t, g5 M
else( H+ X& ~7 F2 P0 G0 w
theLW.WriteLine(String.Format("Body: {0}, Layer: {1}, IsOccurrence: {2}, Part: {3}",
8 j e) T" m& q; g4 i ~/ C theBody.ToString(), theBody.Layer, theBody.IsOccurrence, theBody.OwningPart.Leaf));
1 I& Q! N' D- Y( ^* K }' g# d$ h' ]; S5 P
}# [+ W$ n4 H* {, x2 o0 q7 @8 g
}! Q& {4 v8 M8 l7 |- J$ L+ y8 ?8 T
7 D3 Z- O4 t. o: _6 Z& E
|
|