|
请使用QQ关联注册PLM之家,学习更多关于内容,更多精彩原创视频供你学习!
您需要 登录 才可以下载或查看,没有账号?注册
x
D4 F1 m' Z+ D/ z* m* Z: @+ U0 V
NX二次开放源码分享: 获取装配下所有的实体7 q" T8 P6 |, }' E5 S/ U
# F4 }: x* W3 w0 o6 m& f: O% k3 Y6 V
& v( B8 b9 H! R# t( {7 Lpublic class report_all_bodies_in_assembly_level% q% s3 M6 _% b: G" b5 L' I; g% u
{
k/ |4 _) D2 u+ @) C public static void Main(string[] args)
3 o6 }1 T* @% ~$ Y/ x0 X {
: _2 G5 C% r# f7 g Session theSession = Session.GetSession();! ^3 o$ @9 `$ z8 \
UFSession theUFSession = UFSession.GetUFSession();
1 Z1 f. I9 u! N5 m8 s. H3 v1 f ListingWindow theLW = theSession.ListingWindow;
* W8 {% F+ @; o2 N, T4 V9 \, E( w/ m5 T
& Y- @' k6 A7 p+ ^' Y Part theDispPart = theSession.Parts.Display;
7 {& J1 [* v! ?0 H; z; Z4 L l List<Body> theBodies = new List<Body>();
( {0 ]! i) F+ l. w3 b Tag aTag = Tag.Null;
8 a4 b- m1 T% o' i+ K& }, Y/ t4 Y int type = 0, subtype = 0;
# z1 e% ~: r" R. \3 v9 Z6 q- D" a& J; a& `$ S
$ ?* @' v7 E; U2 Y% j3 k theLW.Open();& w0 C: Y( i4 P2 P8 h! `( Z
do' y3 h7 K' ^7 h8 c6 e
{/ b/ _1 ^( n/ d+ J6 A
theUFSession.Obj.CycleObjsInPart(theDispPart.Tag, UFConstants.UF_solid_type, ref aTag);
+ y* ?6 r0 B# C3 Z; }! L if (aTag == Tag.Null) break;
& m, c! z- f; R# g- ?- X2 S theUFSession.Obj.AskTypeAndSubtype(aTag, out type, out subtype);* P6 n p: Q) S, S" n
, o5 ~, y* T6 u- z8 f# J
$ z: x4 i, `9 P1 w+ W if (subtype == UFConstants.UF_solid_body_subtype)
) K1 }( o4 H. C# j, ~% L' A {
* i: k' k8 m% B3 j Body obj = (Body)theSession.GetObjectManager().GetTaggedObject(aTag);9 @& ^+ H# `) y: i i( g; }
if (obj is Body) theBodies.Add(obj);
% [( R: E( o$ L! V# i }1 N4 J0 C/ E1 {' p& { x- \# n
} while (true);
8 T9 O I5 \0 @' q- S' B& h% H0 ~" k! ?4 z4 _/ M. `, U
, a8 @3 D$ C: V; b4 ?) K7 j
theLW.WriteLine("Bodies in the list: " + theBodies.Count.ToString());
4 M( a: m) n$ \. |5 b foreach( Body theBody in theBodies )
; _; t) H' b: x! n {
/ |2 e! [: W4 W- p if (theBody.IsOccurrence) P1 S" {- N4 G4 S
theLW.WriteLine(String.Format("Body: {0}, Layer: {1}, IsOccurrence: {2}, Component: {3}",
7 o" T+ Z6 N3 p' s9 o/ M3 B) }: j- Q theBody.ToString(), theBody.Layer, theBody.IsOccurrence, theBody.OwningComponent.DisplayName));
, u* D* I8 u" \- }( y, n else9 Y" \7 S! o C4 d9 q! e( u6 H9 [
theLW.WriteLine(String.Format("Body: {0}, Layer: {1}, IsOccurrence: {2}, Part: {3}",+ [9 s% }7 m* b$ \
theBody.ToString(), theBody.Layer, theBody.IsOccurrence, theBody.OwningPart.Leaf));
# Y: Q9 k7 i8 l( u' R }" m3 Q" E4 _0 l9 R9 s% k5 @
}
$ q7 x0 W2 u+ k7 H- d}
0 f* ]9 G6 l" ]0 Y1 V
2 Q/ z W0 r) _, k( J j |
|