|
请使用QQ关联注册PLM之家,学习更多关于内容,更多精彩原创视频供你学习!
您需要 登录 才可以下载或查看,没有账号?注册
x
; d! c) N+ _# N1 Q; n6 a
NX二次开放源码分享: 获取装配下所有的实体
# w- d* J. R% D* ^# L' D( l& N7 \% t7 K; f
: s. D2 v1 D: }* m7 a: H9 `+ F
+ I& s* @- t9 l" @5 {* M8 ?
public class report_all_bodies_in_assembly_level
0 c( ~+ h0 G9 p' b7 c# { H( n{
o: F7 \; A$ L public static void Main(string[] args)3 g/ B7 w- l+ d7 m0 a
{
* ]; f/ S% Z: s Session theSession = Session.GetSession();
2 w# F$ H |. V8 @8 O Z UFSession theUFSession = UFSession.GetUFSession();! Q6 b% c0 q0 L3 @( E* U. v
ListingWindow theLW = theSession.ListingWindow;1 ~5 M' W i4 l' x
0 ]4 ^; ~3 Y. s1 x' G; v# O
, H' d& {7 O* P( U+ R Part theDispPart = theSession.Parts.Display;
+ N7 j! c. j$ n2 b3 r* f List<Body> theBodies = new List<Body>();
7 ], r8 P' `, @0 O( X Tag aTag = Tag.Null;2 X3 I3 V0 y9 e: G
int type = 0, subtype = 0;
% f, D! A g% l* A7 q8 q$ v" `% O, E8 o! B0 a' ~( I
, }9 ` @( U" W- t' U. F
theLW.Open();) {! E) l) R; i+ \& G) Y" w1 L, U
do( Z( _) F, J! \, t# q( P
{
5 m4 U# V' d T+ c/ R theUFSession.Obj.CycleObjsInPart(theDispPart.Tag, UFConstants.UF_solid_type, ref aTag); Q6 B; ?! T$ j5 X1 V
if (aTag == Tag.Null) break;
0 b6 k1 _# c" M8 z3 q) N$ v& v# X/ Y theUFSession.Obj.AskTypeAndSubtype(aTag, out type, out subtype);% ]! ~# `5 ^( P' b# ?$ R1 p
& F! n6 C7 v- e
, Z" [ z C; I- Z9 `% a; I6 t3 J3 \ if (subtype == UFConstants.UF_solid_body_subtype)
! |/ p( L" b: Q$ t, `/ `- G {9 [' W# I& m4 U" f
Body obj = (Body)theSession.GetObjectManager().GetTaggedObject(aTag);* C: I0 _' P# {+ P8 U1 P
if (obj is Body) theBodies.Add(obj);+ C. C1 E& h: w) ~2 F8 A
}* |6 l" c# \" x d+ t0 [1 [
} while (true);
( ? j- p! n& r, i. u& x9 r7 I8 N7 x- C8 n1 D3 F1 H7 L& a
0 P7 V0 o) C3 K
theLW.WriteLine("Bodies in the list: " + theBodies.Count.ToString());% `& k' m( Z$ ]) p7 T
foreach( Body theBody in theBodies )
% N- g8 G/ H) Y" E" }2 V7 a. F {
0 F. k( `4 x2 R if (theBody.IsOccurrence)
0 ~9 B7 c q0 p; z( _( Z theLW.WriteLine(String.Format("Body: {0}, Layer: {1}, IsOccurrence: {2}, Component: {3}",6 Y9 r* l2 y& b; ]' F) j
theBody.ToString(), theBody.Layer, theBody.IsOccurrence, theBody.OwningComponent.DisplayName));
5 a4 k* k+ w B+ E: A else
6 J+ v% X" _& k$ T theLW.WriteLine(String.Format("Body: {0}, Layer: {1}, IsOccurrence: {2}, Part: {3}",7 Z R" _% }5 ~, g2 d0 B* J
theBody.ToString(), theBody.Layer, theBody.IsOccurrence, theBody.OwningPart.Leaf));
' M t% z: H5 x" ^( ] }
; h# V! u% Q) C( X! x/ w }
$ G1 b) W2 U7 q& a: D}
5 e' U+ }: A# S) x( Q. m) L, G; f/ g$ F1 s; ~
|
|