|
请使用QQ关联注册PLM之家,学习更多关于内容,更多精彩原创视频供你学习!
您需要 登录 才可以下载或查看,没有账号?注册
x
' U6 D( @+ {$ {, B* h
NX二次开放源码分享: 获取装配下所有的实体
" R: n# Y. U, y# C; y. Q) h
, | Q; D0 X$ b1 T1 c. P
1 B d$ ^1 e& J1 ~; P) w/ O1 d' t% V s7 _- k5 U( z9 O4 g' L& L
public class report_all_bodies_in_assembly_level% x: p2 }$ F! B# m' b
{- [# D* F9 k- T1 w O5 E0 L
public static void Main(string[] args)1 O0 \3 e& z0 [8 @0 X8 @
{
! `! x1 l. j6 s Session theSession = Session.GetSession();. d2 f1 k, x/ L3 y" @+ C# H
UFSession theUFSession = UFSession.GetUFSession();
, x* h& B; K& w ListingWindow theLW = theSession.ListingWindow;
: J8 F5 S# W5 p" U# \
! Z# q2 c* H2 r; J* j" d% h9 d4 V! C k7 y% o l" A" H4 e6 T
Part theDispPart = theSession.Parts.Display;
# N7 }. V* I% Q/ E* \: v- a$ O" j List<Body> theBodies = new List<Body>();0 E; a+ E! ?: p) W& g% s1 u6 ]: N
Tag aTag = Tag.Null;) E0 a: N8 a6 X8 Y0 P) H# @
int type = 0, subtype = 0;
* t; F4 \# T7 x T- D1 D
) I+ N2 {6 x2 F+ d J
4 y7 h4 Y& E% i7 R r1 T# [ theLW.Open();
5 X- I1 W6 W5 z' x5 z' |7 ~ do
# X3 P! }' H% J' F {) p9 r! n. K1 f* G
theUFSession.Obj.CycleObjsInPart(theDispPart.Tag, UFConstants.UF_solid_type, ref aTag);
4 q5 {& o8 q$ q9 Y4 P if (aTag == Tag.Null) break;5 P+ y6 B9 ~2 P) U3 ` S5 H7 @
theUFSession.Obj.AskTypeAndSubtype(aTag, out type, out subtype);( h+ ~; N! M8 |" @' z
5 E% ^ D+ T# I6 f3 c
& [2 G) t& u- k. z# e3 S if (subtype == UFConstants.UF_solid_body_subtype)
8 J+ L! F( z: s% | {
$ M& J/ K3 g4 J/ T; l4 c Body obj = (Body)theSession.GetObjectManager().GetTaggedObject(aTag);9 d1 [$ M7 n/ i8 h
if (obj is Body) theBodies.Add(obj);
2 J: e, ^ w5 s! { }
" ]5 d, \+ l" R* m1 @' n } while (true);5 E% M7 s( E/ A8 D, ?+ X+ r8 ?
0 i0 d7 U9 n* j! z. j7 n& b
5 x) j/ e) z& g5 |# f theLW.WriteLine("Bodies in the list: " + theBodies.Count.ToString());
: X: _* f- @* P' t foreach( Body theBody in theBodies )* S1 L j5 n% b3 g; ]8 A3 B
{9 } K$ V1 T6 z
if (theBody.IsOccurrence)
- s( Y- A4 ^. E. _$ @ theLW.WriteLine(String.Format("Body: {0}, Layer: {1}, IsOccurrence: {2}, Component: {3}",
( G$ ~& H! c" @) h+ z: A theBody.ToString(), theBody.Layer, theBody.IsOccurrence, theBody.OwningComponent.DisplayName));
1 j- j% e! Z' Y$ m8 | else
[& L2 f' x: y theLW.WriteLine(String.Format("Body: {0}, Layer: {1}, IsOccurrence: {2}, Part: {3}",
# o# @% q4 `& Q& z theBody.ToString(), theBody.Layer, theBody.IsOccurrence, theBody.OwningPart.Leaf));$ i7 k* D$ x! e- n% c4 W
}( B) F3 G8 g) {
}
1 J }2 L' _/ \* J( K8 \}
! `6 J1 N4 a) C$ e) y+ z
. ]* w/ w9 p' J& H |
|