|
请使用QQ关联注册PLM之家,学习更多关于内容,更多精彩原创视频供你学习!
您需要 登录 才可以下载或查看,没有账号?注册
x
6 I- F' y4 s. K1 f
NX二次开放源码分享: 获取装配下所有的实体
8 S3 t L+ k! u6 J/ K1 B9 q' X9 r% k2 [8 r0 Z9 h5 }
. A: G+ r7 ~( }# h! R0 K
9 G* `; T7 v- V0 h( ^" spublic class report_all_bodies_in_assembly_level0 H) I3 g& L% j; [
{$ g3 m0 P1 ~( O( w: L5 `* _* a
public static void Main(string[] args)# o! h3 y1 F; s! z) B
{
% T7 x+ V9 V0 G$ n1 G- h( H Session theSession = Session.GetSession();
) A0 r2 f4 E9 j7 \2 r( z UFSession theUFSession = UFSession.GetUFSession();
L# V4 C' j x$ |; } ListingWindow theLW = theSession.ListingWindow;( b+ r2 Y Q9 K8 n$ M E& X
Y+ S( O2 f; }' m' d* m6 x
4 b4 R& H2 x' v
Part theDispPart = theSession.Parts.Display;
- U6 X+ u" z5 j. L, i List<Body> theBodies = new List<Body>();' y: A/ M9 l3 I
Tag aTag = Tag.Null;2 } Q6 Q( b# o1 ^9 O4 N
int type = 0, subtype = 0;
9 a+ y4 \& r) ~8 b7 u" T. }7 J$ V; }7 p G6 r) w% A+ n# A' z/ l
0 K `# Q% W4 \2 U
theLW.Open();
8 T- H6 _/ s3 |& x: d" u do+ C2 d! z8 d, e; _
{
8 N% s6 L$ O0 ?( ` B; R theUFSession.Obj.CycleObjsInPart(theDispPart.Tag, UFConstants.UF_solid_type, ref aTag);; q: t+ |6 y$ ?# I- R% z
if (aTag == Tag.Null) break;9 f1 r( I# V+ z# h1 A9 M( q
theUFSession.Obj.AskTypeAndSubtype(aTag, out type, out subtype);( y! Y. j* h1 Q& H2 H+ |
$ q" ]# |+ o$ }% m% \, I: D* O# u2 y6 v4 N8 M
if (subtype == UFConstants.UF_solid_body_subtype)
3 u. C6 y' [! K {' B: H1 A, h* U* F0 I9 u% h
Body obj = (Body)theSession.GetObjectManager().GetTaggedObject(aTag);
/ X# a0 n- V" N3 J! ] if (obj is Body) theBodies.Add(obj);
$ M, o7 \" W" E, K, P3 l$ W' d3 r! D }) {; d$ K" i1 g# `
} while (true);
1 X( f3 n' _, }# p& o* F" q, o& W4 F9 W
; t' B8 C! }% e- B! I8 @0 p9 Q7 W, O
theLW.WriteLine("Bodies in the list: " + theBodies.Count.ToString());
8 t2 R! C6 @2 l" x" n. L foreach( Body theBody in theBodies )0 l& P) T6 L) j4 Y& J% L9 [5 |
{
2 B" N1 W6 f) S# `2 c if (theBody.IsOccurrence)5 B$ Y, T' A8 e4 P
theLW.WriteLine(String.Format("Body: {0}, Layer: {1}, IsOccurrence: {2}, Component: {3}",# q( \' Q: x& i1 n2 O
theBody.ToString(), theBody.Layer, theBody.IsOccurrence, theBody.OwningComponent.DisplayName));
/ M0 {) Z# t, ` else
7 k, y R, S9 D( ^ theLW.WriteLine(String.Format("Body: {0}, Layer: {1}, IsOccurrence: {2}, Part: {3}",
2 z1 p: |, [3 P! f5 f# M theBody.ToString(), theBody.Layer, theBody.IsOccurrence, theBody.OwningPart.Leaf));; L$ x5 i0 x' X0 y
}' ^' Q# U" F$ H5 U
}- J# M. V4 M7 K
}: c3 i7 x* j' m; w
, H1 p# e" J e* i$ S2 f
|
|