|
|
请使用QQ关联注册PLM之家,学习更多关于内容,更多精彩原创视频供你学习!
您需要 登录 才可以下载或查看,没有账号?注册
x
' u% d6 X" w. A3 {4 o8 w: K1 GNX二次开放源码分享: 获取装配下所有的实体
\2 {5 A2 [4 c' `0 v; c/ ^8 u8 c8 R+ B! P7 W! {
, C, e% B) ~& |' A5 N3 B& K
( g6 P U! w/ m8 e* n6 Tpublic class report_all_bodies_in_assembly_level5 J& w$ a: q1 m8 t( Q% K
{( M# \$ W* P. T2 w. |
public static void Main(string[] args)3 B& ~: c8 ^* a3 I2 w9 `
{+ t) J5 @! j2 s, g" P7 u) L Q
Session theSession = Session.GetSession();
/ [5 B5 @% m1 I6 i: _! c; c UFSession theUFSession = UFSession.GetUFSession();$ S* u( {; T& v& u
ListingWindow theLW = theSession.ListingWindow;4 S: U* H3 F8 E! A
7 Z0 d6 X n3 d) z4 Q5 z
& S- E# W1 i* g1 G4 m9 Q Part theDispPart = theSession.Parts.Display;6 W$ R. \# x$ T6 ^
List<Body> theBodies = new List<Body>();
! A- Y+ v5 c6 ~/ E/ }0 K$ v: a Tag aTag = Tag.Null;0 Q$ c) j9 {, ]! e
int type = 0, subtype = 0;
+ d! e2 a6 J3 j; L& j. F6 }, h: m
( Q+ p0 o! H5 t9 H+ P
; |2 p0 W2 L: m+ j1 v0 @6 `6 y theLW.Open();
9 B4 K% L3 l2 v k1 \& T do& r0 v5 _9 S) v7 G
{7 n. F: X( t$ K# }/ `' ~
theUFSession.Obj.CycleObjsInPart(theDispPart.Tag, UFConstants.UF_solid_type, ref aTag);0 M7 Y$ t; q( S1 |6 b ~/ G3 v
if (aTag == Tag.Null) break;$ S; x- G/ \$ ]' e0 y
theUFSession.Obj.AskTypeAndSubtype(aTag, out type, out subtype);
% `8 _+ }; i6 y5 \4 Q8 \2 a7 A; Q2 _7 [4 o1 h' `. W
( W" i w. h0 e0 p if (subtype == UFConstants.UF_solid_body_subtype)
& m4 X4 K) p3 J" v+ O: d' E+ n {
6 c; S1 R. u8 l) U Body obj = (Body)theSession.GetObjectManager().GetTaggedObject(aTag);
$ p9 g% z, u, T( B: ? if (obj is Body) theBodies.Add(obj);& x- W9 `7 ]3 ~7 }* x5 M
}
9 O3 {' E8 a/ t } while (true);+ P% {2 ~6 j9 |/ H/ c6 U
% ?$ J2 X0 w4 c5 b) K8 V( p
5 l- X7 r* S1 a0 w: o& J theLW.WriteLine("Bodies in the list: " + theBodies.Count.ToString());9 Q% X: n$ ~9 Y7 b" y1 ~" j
foreach( Body theBody in theBodies )
: p! C/ Z6 ~7 w4 A {
t$ Z* d# @# T/ y1 w' E if (theBody.IsOccurrence): N2 r+ b- F( D9 z% T: \6 p
theLW.WriteLine(String.Format("Body: {0}, Layer: {1}, IsOccurrence: {2}, Component: {3}",, `3 |4 X* k0 a1 N' Y3 D8 B9 J* E
theBody.ToString(), theBody.Layer, theBody.IsOccurrence, theBody.OwningComponent.DisplayName));
3 ?, @. q! H- K1 G% }8 R% ^3 E else/ H- b, u- h) O, a5 \( A g
theLW.WriteLine(String.Format("Body: {0}, Layer: {1}, IsOccurrence: {2}, Part: {3}",- B2 _* M+ t/ K# E* K& M
theBody.ToString(), theBody.Layer, theBody.IsOccurrence, theBody.OwningPart.Leaf));
: B) c, v7 z* p }
4 [' r4 h' ]5 i1 f% Q' H }3 K- [- l0 m: j5 r) z
}& M3 V" ?$ v- ~4 ^
+ H; ]& f8 U5 x8 ^. e
|
|