|
|
请使用QQ关联注册PLM之家,学习更多关于内容,更多精彩原创视频供你学习!
您需要 登录 才可以下载或查看,没有账号?注册
x
3 @8 S1 ^( _5 m& ]' q& |
NX二次开放源码分享: 获取装配下所有的实体0 F7 p" o Q r" J6 V
. `8 V- m+ b8 y$ h% S
% H" x$ S7 \3 P0 }. R, @$ O$ t3 a6 {; h& l% C. k
public class report_all_bodies_in_assembly_level
9 I8 ^3 e D: T% ?! ~7 @+ F{. c$ N; N. k# U3 Y
public static void Main(string[] args)' Y: w9 {7 G& b5 j$ B9 b
{" S. ?/ [/ r9 p
Session theSession = Session.GetSession();1 Q+ m$ n* Q3 q6 v- b8 t9 |
UFSession theUFSession = UFSession.GetUFSession();
* \0 h6 e/ n4 U4 G4 d T ListingWindow theLW = theSession.ListingWindow;
$ _+ D( ^6 R. H+ |- D5 o$ Y2 p9 K: {: @& X- P
5 i+ S- x* c. C8 K, u1 t
Part theDispPart = theSession.Parts.Display;# z X1 W% w {5 X6 L x
List<Body> theBodies = new List<Body>();. J/ `. J# j& ?3 E
Tag aTag = Tag.Null;
, r0 y( f( v8 Z1 F5 Q int type = 0, subtype = 0;
2 x! ^4 q% t- j* E# B3 b7 C# K
2 d1 D3 P- {& C2 U3 j$ w) X9 H
% n. n3 f% ]* b2 _% H0 s theLW.Open();
F3 j8 L. u0 V! P6 h- v, Z+ _( K6 b do
- J5 F Z2 ]) d {; w1 F0 R m/ w R- s8 X
theUFSession.Obj.CycleObjsInPart(theDispPart.Tag, UFConstants.UF_solid_type, ref aTag);4 i2 T8 A& p4 Q- g e
if (aTag == Tag.Null) break;
) d7 ~5 f+ J% j0 m3 u1 x theUFSession.Obj.AskTypeAndSubtype(aTag, out type, out subtype);1 O1 f6 V( H# l+ k m: a) ?
" U$ M5 w, x& h- U+ | r1 w$ |
+ f/ T% e. I; ] D# [. G
if (subtype == UFConstants.UF_solid_body_subtype)
" q& B+ _* i# U! r1 n1 F+ N {0 S# `0 q" o( D" Z/ u: z
Body obj = (Body)theSession.GetObjectManager().GetTaggedObject(aTag); ~" a; ]: M1 k
if (obj is Body) theBodies.Add(obj);) ^# @+ ^9 o7 F3 x- q
}
5 }4 U- v# D" v: H* y } while (true);
0 N% V$ b( r9 T4 w* e
. V: O: l: |; Z7 D/ Q0 O
/ D7 Z/ E. z; |5 g! K8 d theLW.WriteLine("Bodies in the list: " + theBodies.Count.ToString());
5 I0 e- e/ i) `/ d foreach( Body theBody in theBodies )1 O3 P/ X) D) S3 I6 Z7 U8 d. @
{
. a2 S! N: U y; g4 H$ x if (theBody.IsOccurrence)
0 }& U$ S2 ?, O4 X8 P theLW.WriteLine(String.Format("Body: {0}, Layer: {1}, IsOccurrence: {2}, Component: {3}",
0 ]) Q- _, W) n' Z+ h theBody.ToString(), theBody.Layer, theBody.IsOccurrence, theBody.OwningComponent.DisplayName));
6 g3 v- ?7 r$ O else
( @: l+ c5 Z( x7 }; q, f theLW.WriteLine(String.Format("Body: {0}, Layer: {1}, IsOccurrence: {2}, Part: {3}",: _7 m* [: j) S7 r
theBody.ToString(), theBody.Layer, theBody.IsOccurrence, theBody.OwningPart.Leaf));
" G5 n' u3 E. m. r- x$ G }9 I# X5 n( r5 g) D% S# y
}
3 s8 j2 y( ?( S}
9 c9 x& M' r+ j0 b# Z
6 I# v6 t5 a7 S3 S" z; x w j |
|