|
|
请使用QQ关联注册PLM之家,学习更多关于内容,更多精彩原创视频供你学习!
您需要 登录 才可以下载或查看,没有账号?注册
×
: j" f! b4 ~! t
NX二次开放源码分享: 获取装配下所有的实体
+ S0 z/ N: \& g5 g; ` B: G7 h; D* X4 _" K$ p( _
& a0 L0 u5 @; ^ G2 c
6 ~+ F0 B5 T' R+ P' v
public class report_all_bodies_in_assembly_level
# l5 d9 T' u1 p! {{
, Y& H/ L% I1 v public static void Main(string[] args)3 P. u! }& e* O
{
6 U" L d1 b5 `0 P3 o9 D Session theSession = Session.GetSession();
% A, A, C4 \! _! z# i1 y UFSession theUFSession = UFSession.GetUFSession();: q0 K; R0 }3 X8 [8 U
ListingWindow theLW = theSession.ListingWindow;
8 \5 s% _; [- H& e0 x" C5 a. j* b1 g! C0 w
7 H" r6 k. l8 @. p3 ] Part theDispPart = theSession.Parts.Display;
* k- T1 B& n v2 m List<Body> theBodies = new List<Body>();
) x# h6 H% Y9 X# H8 b% P8 ~ Tag aTag = Tag.Null;) p% b B2 G, s6 M; e6 A
int type = 0, subtype = 0;
* S& l$ A& v" e) H/ F
" g) P, R- T) v! s* ~( D
1 S0 |! i0 ~ i& L/ ?, u theLW.Open();
! E# {9 j6 J1 H3 i do
! g* p B/ X) I1 J$ j# z0 [ {6 x. W5 [. ] G! K. I
theUFSession.Obj.CycleObjsInPart(theDispPart.Tag, UFConstants.UF_solid_type, ref aTag);: S/ w! M6 c( [/ t' [
if (aTag == Tag.Null) break;
8 T% P6 l. Q0 ] theUFSession.Obj.AskTypeAndSubtype(aTag, out type, out subtype);2 ^9 o! @4 ?3 R; Y5 n( E7 P, y) l
& S) X5 P: H4 K
7 P7 [% L$ }% L+ [0 F if (subtype == UFConstants.UF_solid_body_subtype)
( h: ?! F( V1 r% }% Y1 J; G {5 H/ j! Y* Z- N$ i4 W x* q+ @# J
Body obj = (Body)theSession.GetObjectManager().GetTaggedObject(aTag);3 e/ O. C1 [* T
if (obj is Body) theBodies.Add(obj); x' E% L+ t5 k' e( _% s
}" I2 M6 ?8 k$ |! N" @. g
} while (true);
# @1 ^/ N# P1 F% l6 m G+ i4 s4 Q5 p/ X7 [
1 ?4 e1 x3 P' ~$ v `1 w% V$ q% g theLW.WriteLine("Bodies in the list: " + theBodies.Count.ToString());5 }" @0 v1 O$ U( c! E9 D- u
foreach( Body theBody in theBodies )
0 z0 a* J {5 I7 j {
4 [- l5 \2 X2 o* X if (theBody.IsOccurrence)2 x7 j `" P! w7 m8 `& n& f" K
theLW.WriteLine(String.Format("Body: {0}, Layer: {1}, IsOccurrence: {2}, Component: {3}",
/ w2 c7 u6 h, Z- L3 [ theBody.ToString(), theBody.Layer, theBody.IsOccurrence, theBody.OwningComponent.DisplayName));
# l! }, @4 `( N# i( a, T m' r else
; ?% e @; a, E theLW.WriteLine(String.Format("Body: {0}, Layer: {1}, IsOccurrence: {2}, Part: {3}",6 P A. g0 N* ^8 J4 g% O. F, l7 ~1 K% D
theBody.ToString(), theBody.Layer, theBody.IsOccurrence, theBody.OwningPart.Leaf));
0 s( y. J: [# S3 S. U1 E2 z }
0 ?. z8 L: A8 v: K+ E3 H, L }, p; ]. [% W2 K! }3 j/ L
}
+ C- X, \) e q/ V+ |9 p; }5 P5 E! ^6 W
+ z3 o' @5 _0 G |
|