|
请使用QQ关联注册PLM之家,学习更多关于内容,更多精彩原创视频供你学习!
您需要 登录 才可以下载或查看,没有账号?注册
x
, P* E& }5 U/ y- B; h$ E% R1 q2 M
NX二次开放源码分享: 获取装配下所有的实体4 K `# o9 W1 c6 g& w
; h8 M+ _" ^5 y* q
w5 u6 n& t# {) f1 M/ Y2 u1 W* b! e" y6 @. x9 [
public class report_all_bodies_in_assembly_level
1 k' R7 K% Q4 X' F* u$ q5 K1 m{
& x' N' ?! g7 t public static void Main(string[] args)
! w4 i3 G1 N4 L- B8 {8 h! F {
6 T% H+ I* W/ h/ } Session theSession = Session.GetSession();
' ^$ ]' N4 s- T& S4 u# X ? UFSession theUFSession = UFSession.GetUFSession();
# j+ t5 P: W# G! a ListingWindow theLW = theSession.ListingWindow;4 m3 Q) `# i! F3 i. g$ p
) O2 i" [) @* S9 w
' {& g2 G; ]2 ?9 h$ E Part theDispPart = theSession.Parts.Display;2 J4 _) p$ ^/ }( d/ M- h: R! W1 \3 g
List<Body> theBodies = new List<Body>();4 E3 S4 K$ q" A
Tag aTag = Tag.Null;
! q2 `: E1 ?* G8 |: N9 o8 f+ ` int type = 0, subtype = 0;) n! J( E" D) e V8 j6 o
8 o- [7 C/ J% Y9 d- K _" @ b/ r% g
theLW.Open();
! y# h4 L; e! {# ]: m8 \" C4 | do0 K7 G' o) n' B+ d3 n }8 z3 S
{
: ^! L% p8 w( L! Q* O theUFSession.Obj.CycleObjsInPart(theDispPart.Tag, UFConstants.UF_solid_type, ref aTag);
: n: `6 L, J' u. P& \ if (aTag == Tag.Null) break;+ `: b) u! s s; a" ^3 X
theUFSession.Obj.AskTypeAndSubtype(aTag, out type, out subtype);8 [; u1 e, z6 x& f, i" G$ f3 z# u% ?
- ]( X4 e8 e) v
* o1 R8 F- i2 S( u/ W$ q
if (subtype == UFConstants.UF_solid_body_subtype)$ \7 `- ~. L( x
{+ R5 D8 X6 r2 G! ~* Q
Body obj = (Body)theSession.GetObjectManager().GetTaggedObject(aTag);
O+ Y/ J: d. T6 _/ | if (obj is Body) theBodies.Add(obj);, |; q) F2 l( q4 Y U
}
) k+ B8 R0 p" M0 t8 c- { } while (true);6 a6 _: D7 ^+ G( S3 Y$ v2 s
+ w# ]$ J2 k4 V* o m: V
4 n- Y9 @' \5 n( s$ m; b theLW.WriteLine("Bodies in the list: " + theBodies.Count.ToString());! j5 n0 S0 j6 V0 M( b5 X q9 s
foreach( Body theBody in theBodies )" I* k7 e4 v ]+ }; ~2 K' [1 C/ s f
{
; j+ M, n; Z7 g1 e6 G if (theBody.IsOccurrence); X9 `' S, T! G" s" W$ R: T
theLW.WriteLine(String.Format("Body: {0}, Layer: {1}, IsOccurrence: {2}, Component: {3}",$ [* Z9 }# }8 q" b/ K9 R' [' V7 C( o
theBody.ToString(), theBody.Layer, theBody.IsOccurrence, theBody.OwningComponent.DisplayName));
/ o! N7 l# E5 h8 j# b$ _ else6 E8 z. F3 c2 F- ?
theLW.WriteLine(String.Format("Body: {0}, Layer: {1}, IsOccurrence: {2}, Part: {3}",
! V: p) B2 J: j* ?# B4 M4 p% O theBody.ToString(), theBody.Layer, theBody.IsOccurrence, theBody.OwningPart.Leaf));
4 @2 r6 W8 s, } }
- b: C5 m: ^' h+ U1 U( F# R S2 b }
0 Z# C9 Z2 O: `. R}- ]! W* u: U+ z! P3 K9 k
: H, r1 \( u( u4 r# ^- m
|
|