|
请使用QQ关联注册PLM之家,学习更多关于内容,更多精彩原创视频供你学习!
您需要 登录 才可以下载或查看,没有账号?注册
x
, B+ Q$ N9 V1 ?3 P: `2 X
NX二次开放源码分享: 获取装配下所有的实体$ m6 q- `- S5 X! h& e6 M
% E J9 v3 D" H% Q% h1 a3 I( e* E" C" o& X
/ m- S. e# ~" x# g: Y: K* Jpublic class report_all_bodies_in_assembly_level* ?# I L/ Q4 h% H3 c8 x X8 \
{& r6 g% R( V/ |9 F
public static void Main(string[] args)
8 R+ ?' U$ r2 A* h/ M- ~5 ] {
" U, u; W* @ o9 ]# }3 i( Q Session theSession = Session.GetSession();- R4 v2 q: l+ k2 |, U! |2 H6 T
UFSession theUFSession = UFSession.GetUFSession();. L0 _' R4 m! I" M8 a# _( b
ListingWindow theLW = theSession.ListingWindow;
6 P1 x. s, y8 f6 o& w) n/ J& x! ~
* a! d& k/ \9 v( V& i* b; L% N. W: h. _
% z( D: E0 p! k* y Part theDispPart = theSession.Parts.Display;
% }3 U) v# P! U0 @- V List<Body> theBodies = new List<Body>();
% v: @. [0 B0 C; [ Tag aTag = Tag.Null;
5 U! C- ]5 W7 Y/ k5 E8 f2 } int type = 0, subtype = 0;2 ~8 M0 z' N( i4 Y' E
/ Z* K; U4 r. s7 k8 Q( J$ z" r8 A. m0 W. {8 z7 _/ V
theLW.Open();' q4 Z' e! @" Y
do
! M1 ], u: z. d8 P6 | {/ y P; ~: r, [7 p& a5 p7 S
theUFSession.Obj.CycleObjsInPart(theDispPart.Tag, UFConstants.UF_solid_type, ref aTag);
$ z: U$ U1 R) Q! l8 w' B2 B if (aTag == Tag.Null) break;: A/ C+ w O0 h. Z4 d
theUFSession.Obj.AskTypeAndSubtype(aTag, out type, out subtype);
* N# b5 s% X5 B
" [0 X J4 a# U3 ~5 {3 |; m. }6 a2 U" W o
if (subtype == UFConstants.UF_solid_body_subtype)4 P# m. n6 Q. a" f$ c+ X' l
{
0 e& Z2 D3 n3 F# A5 n" ] Body obj = (Body)theSession.GetObjectManager().GetTaggedObject(aTag);3 x7 N, y) c9 m8 Z9 n- ?- E
if (obj is Body) theBodies.Add(obj);
3 f/ E3 M, O4 w9 m& \1 l: R2 E P }7 P3 P8 J) i5 w( c
} while (true);
( Q0 P% `9 d5 ^) k. X! Q2 J# g: S3 f# S* [
9 Q9 M- Q: A+ z1 _ d) m; w6 } theLW.WriteLine("Bodies in the list: " + theBodies.Count.ToString());" b; J2 I- a* P6 [: o: Y6 a
foreach( Body theBody in theBodies ); n: Y+ U9 O# u
{' f6 H; ^' W1 h9 v
if (theBody.IsOccurrence)! E$ Z, F$ ?( @1 O( r5 \5 m
theLW.WriteLine(String.Format("Body: {0}, Layer: {1}, IsOccurrence: {2}, Component: {3}",
; c0 x. |- K. S theBody.ToString(), theBody.Layer, theBody.IsOccurrence, theBody.OwningComponent.DisplayName));
- P3 ?7 X" K4 Y0 `) }- F1 u G else/ |0 a: L% l+ ~' l
theLW.WriteLine(String.Format("Body: {0}, Layer: {1}, IsOccurrence: {2}, Part: {3}",5 x& e- F8 A. f% ~& g z; Z
theBody.ToString(), theBody.Layer, theBody.IsOccurrence, theBody.OwningPart.Leaf));6 ~. d4 N. n6 }" N: X1 _0 C
}* P/ {( r. v" y
}% a& A& l' C+ V4 H5 t% h
}
O' J W: ~$ U+ `2 W# E& M7 ]3 k- {( r8 L3 w2 P
|
|