|
请使用QQ关联注册PLM之家,学习更多关于内容,更多精彩原创视频供你学习!
您需要 登录 才可以下载或查看,没有账号?注册
x
: n' m9 ~2 ?) A$ j( d1 [NX二次开放源码分享: 获取装配下所有的实体1 m8 w9 v. ]1 X6 a# Q( q
" b3 G& Z! [0 q* }3 y5 n0 v8 G3 _! `- l! L6 v; |0 o
* i) n. ~1 p# h4 cpublic class report_all_bodies_in_assembly_level! ~3 V# E* P+ E' m6 q! l
{
, g% R2 A, y6 \% s+ e6 F" C public static void Main(string[] args)# _. F' }7 Q" W
{4 v$ I: f8 j% N: B# C2 k
Session theSession = Session.GetSession();" I) }- J. z4 y8 R" _0 V' D t
UFSession theUFSession = UFSession.GetUFSession();
3 _, j& U* [ _; ]$ W8 u ListingWindow theLW = theSession.ListingWindow;( r! n4 d. ^2 x
0 ?! f) O- r! V+ c0 P h$ a9 t& @% c# t* V6 ?
Part theDispPart = theSession.Parts.Display;
4 z k: E! I4 { List<Body> theBodies = new List<Body>();2 ~8 K0 P' f6 v+ v- W
Tag aTag = Tag.Null;
1 a) b0 I4 z* f+ p4 @0 A8 I7 I int type = 0, subtype = 0;
0 z) Y) ^: g5 A* T8 X' J0 i9 b1 |$ @: \. V: p% q- n
2 K8 d3 x, B$ p {) f" C theLW.Open();
! G9 ~3 O: [) u% n( g( b do m* L0 C2 w+ Q! {0 j
{. l5 y+ @/ @/ b# l, D1 y
theUFSession.Obj.CycleObjsInPart(theDispPart.Tag, UFConstants.UF_solid_type, ref aTag);
8 P3 `# U$ u# B& F+ O3 b if (aTag == Tag.Null) break;
: i+ F9 @5 _6 B( I, l& k- ? theUFSession.Obj.AskTypeAndSubtype(aTag, out type, out subtype);
" l! ]; y# d& p6 o" z
/ M) E% C6 |4 X2 |; M6 L( \& ?3 ^
if (subtype == UFConstants.UF_solid_body_subtype)& o1 i% o& p) N! H% U0 N
{* W: U4 d% F/ y4 D/ D- ~: _3 w L, M) U
Body obj = (Body)theSession.GetObjectManager().GetTaggedObject(aTag);
o% e7 q# @. z( ~! ~) B7 \ g if (obj is Body) theBodies.Add(obj);
4 m& g* u0 e b( a6 d r }
2 F9 ?& y5 p" M/ X: e X3 n( F2 n+ J } while (true);" S2 p5 z9 `/ n/ H" {$ L+ {
2 B( t6 a- P8 ^
+ m6 }9 I( O8 [+ X* Z6 Q0 z+ m4 Z theLW.WriteLine("Bodies in the list: " + theBodies.Count.ToString());
2 V5 M. ]. C/ v- \ c foreach( Body theBody in theBodies )
5 c" h% Q7 _+ E6 p8 R& c {7 A# [% q' f# Y* [' \+ U6 ~
if (theBody.IsOccurrence)
- }. @3 i' n5 z1 k+ }+ W theLW.WriteLine(String.Format("Body: {0}, Layer: {1}, IsOccurrence: {2}, Component: {3}",
: T1 \4 k# L" ^; T% |; q" L theBody.ToString(), theBody.Layer, theBody.IsOccurrence, theBody.OwningComponent.DisplayName));
) [. v9 _7 ?# g8 M9 h* V; u2 g$ ]" } W else
- g* b4 j$ w$ R$ R M theLW.WriteLine(String.Format("Body: {0}, Layer: {1}, IsOccurrence: {2}, Part: {3}",( |- f* w: d) Q5 `# C4 h4 f" @
theBody.ToString(), theBody.Layer, theBody.IsOccurrence, theBody.OwningPart.Leaf));
1 a1 Z+ Y4 f5 f }9 b# K& I- c7 [! R+ O- I/ D
}
. V: J+ M! R* ?7 R1 n: C}* _6 E3 M$ D ]/ @. S" H
5 U% h9 S( Q+ c* k5 U |
|