|
请使用QQ关联注册PLM之家,学习更多关于内容,更多精彩原创视频供你学习!
您需要 登录 才可以下载或查看,没有账号?注册
x
C1 k6 M3 K1 z3 N& [: yNX二次开放源码分享: 获取装配下所有的实体
* ~& o, V1 L; X& |5 y }& @; [; o+ ^) }! W8 w8 f- p
8 g7 `6 \& `1 v, D, `2 ~& U3 G* r: H: u* n
public class report_all_bodies_in_assembly_level
4 r2 ~; E7 p2 l. T{
; S, {# q! q% ^5 U- c0 U public static void Main(string[] args)
, j+ J3 Y5 N! ]5 c6 Y6 {8 ] {
7 E0 S) ^% R) |% z8 D- J* ~, e Session theSession = Session.GetSession();
% K) r$ f! N" B) `/ |( ~& J' c UFSession theUFSession = UFSession.GetUFSession();" m ~6 v8 }5 V: s2 y
ListingWindow theLW = theSession.ListingWindow;
( a' D3 u, J7 Z0 `8 @# X* R) B7 p$ ^: l7 f. R
/ \- } ?8 N5 v6 v) v! g* y
Part theDispPart = theSession.Parts.Display;
, I# B( K! H; Y/ X* e List<Body> theBodies = new List<Body>();
" |3 B! E d$ l3 t; W6 ? Tag aTag = Tag.Null;; @; {9 Q" J: ~) P# ]
int type = 0, subtype = 0;
7 C- m8 b# a$ v& f4 V9 z- d+ J. o
% `. C( v0 l, ?5 C7 L7 O4 d0 ^8 i7 E& ?" s
theLW.Open();
, x4 d6 U: V/ o4 x( t" Z do
& `" n- C, s% M) L! x# h {5 `# z3 ^" S; E2 T7 X
theUFSession.Obj.CycleObjsInPart(theDispPart.Tag, UFConstants.UF_solid_type, ref aTag);
, ~7 @1 q! ]& v! f! w if (aTag == Tag.Null) break;
7 X! n) u' T+ G/ C theUFSession.Obj.AskTypeAndSubtype(aTag, out type, out subtype);
. n2 k# e" h* G' [- F. R! M2 j1 @
- d( t- i( C, R7 G5 N" a
/ v7 @6 K, b4 [7 n4 s' z* @ if (subtype == UFConstants.UF_solid_body_subtype)
8 I% @. _$ F' ` {: R6 \; k7 w# K8 y
Body obj = (Body)theSession.GetObjectManager().GetTaggedObject(aTag);
, m1 {" S/ @6 ?9 M5 u& _ if (obj is Body) theBodies.Add(obj);
( g/ h8 C$ @1 ^0 x7 D* O; B }
! e- s( |1 m/ X4 y ` } while (true);0 e: C- s3 w* W9 t
3 s0 y" _" N6 P7 `& Q( v' L$ M
% t7 l1 l" @% h h( }5 u% c theLW.WriteLine("Bodies in the list: " + theBodies.Count.ToString());
+ ]% m7 R$ |5 @7 I0 Y7 s! z foreach( Body theBody in theBodies )
4 I: h s! g+ ^8 b, n {3 I, ~; G: B) b9 @1 x3 E2 T3 c+ Y
if (theBody.IsOccurrence)
( Q+ j# ] D. j- C# A i1 s. l# V theLW.WriteLine(String.Format("Body: {0}, Layer: {1}, IsOccurrence: {2}, Component: {3}",
5 u1 M& Z8 ~5 B: E( {7 W! O5 a. L/ p theBody.ToString(), theBody.Layer, theBody.IsOccurrence, theBody.OwningComponent.DisplayName));
2 f0 u% \" V" W1 V7 O- ~ else
+ a: J5 j; Q: {! K k theLW.WriteLine(String.Format("Body: {0}, Layer: {1}, IsOccurrence: {2}, Part: {3}",) }3 z% a+ A$ f9 P! E2 u1 m# |
theBody.ToString(), theBody.Layer, theBody.IsOccurrence, theBody.OwningPart.Leaf));
- }" S: S3 d$ Y, H }, i6 Z! f+ x$ ?( y+ d! p
}4 j* \8 X& h) h
}3 Q) k, `% Y4 @4 F
8 V8 M$ U- l* W5 C1 k i |
|