|
|
请使用QQ关联注册PLM之家,学习更多关于内容,更多精彩原创视频供你学习!
您需要 登录 才可以下载或查看,没有账号?注册
x
% u8 O, F' ]/ @/ w8 F4 k c; T
NX二次开放源码分享: 获取装配下所有的实体
. b( ~) G0 y, H$ U
5 G- h$ e2 r# [& E- A2 T' y- H6 g7 z: `9 u
' r* R& G4 D. ]7 S3 Fpublic class report_all_bodies_in_assembly_level
; G* X6 L# C' L: o{. d+ a8 {; l6 `& q" E
public static void Main(string[] args)
9 }, _) b. r: J7 G, t; b! t- ~ {
! R4 W2 P3 n7 H) F5 t) I2 ` Session theSession = Session.GetSession();
( _; ^2 ~" U7 q UFSession theUFSession = UFSession.GetUFSession();
* P" _* J6 A2 o9 J6 C) G ListingWindow theLW = theSession.ListingWindow; h3 p2 s& r1 R8 ^1 D1 N& K
+ M M: k% R% j: x
_ }3 M+ O7 T7 o& ^: s Part theDispPart = theSession.Parts.Display;
) N( T8 I# A6 X/ c" V0 Q: T List<Body> theBodies = new List<Body>();
. c9 |3 ^) Z ?& | G Tag aTag = Tag.Null;
- {. g2 {1 r$ `, X; } int type = 0, subtype = 0;
& k- l( ~7 ~$ W( ]4 Q8 [8 u
3 g! Q4 W2 R8 O4 r p* k" [7 Y# h3 m2 t3 C- H7 t+ U$ ?7 u
theLW.Open();, z# ?. Y; M5 h& }3 E4 y
do
% T/ y! r6 c1 K0 Z+ I9 t/ n' A {3 }7 t) z! S" M' ?- }3 b" v
theUFSession.Obj.CycleObjsInPart(theDispPart.Tag, UFConstants.UF_solid_type, ref aTag);
8 b; s3 y* b# b" p9 n if (aTag == Tag.Null) break;
( _) F8 D" _: S( D! T9 E theUFSession.Obj.AskTypeAndSubtype(aTag, out type, out subtype);
$ [+ m) `$ X4 i1 A6 h
; d0 T/ Y7 ?/ n& W8 c; D/ _4 P9 I- }; g
if (subtype == UFConstants.UF_solid_body_subtype)
/ h9 j/ R0 B3 G {
2 [" [- @6 K" b- ~* L Body obj = (Body)theSession.GetObjectManager().GetTaggedObject(aTag);- A& v$ `0 _, p) ~3 i8 \( u& @! F% J$ V
if (obj is Body) theBodies.Add(obj);5 j& q' ?- Z: e5 j- x
} C( d( i9 E. W5 H9 F9 G0 k6 W
} while (true);- Q# V! w$ G4 z; h/ L/ V
5 X' m# K( i- m/ `) i/ W& E4 J8 u1 |4 i- {
theLW.WriteLine("Bodies in the list: " + theBodies.Count.ToString());
+ Y+ K& Z8 X F6 a' ]& L( E3 l foreach( Body theBody in theBodies )
8 _' e2 B# D* S2 v/ } {
3 T( @; ?1 C. j9 M/ Q if (theBody.IsOccurrence)
9 W8 e4 B/ q( h* O, }0 k theLW.WriteLine(String.Format("Body: {0}, Layer: {1}, IsOccurrence: {2}, Component: {3}"," O! [" z0 C8 K6 G3 y: j( l6 e
theBody.ToString(), theBody.Layer, theBody.IsOccurrence, theBody.OwningComponent.DisplayName));4 D% ^! X% J- M! F( W. q
else
1 V$ T, I+ n; c/ v3 K, q: R theLW.WriteLine(String.Format("Body: {0}, Layer: {1}, IsOccurrence: {2}, Part: {3}",1 A6 T' h, \' m+ c2 t
theBody.ToString(), theBody.Layer, theBody.IsOccurrence, theBody.OwningPart.Leaf));, H* ]% K1 F5 @. g1 j# I
}
. a2 U0 i6 S/ b y' Q. e" V9 @ }4 w& _5 \3 k+ H5 X. E" I" w
}
7 F. i) D% y. W' Z8 ^" U% p+ a5 L* F7 J2 @7 |% g8 N J: z
|
|