|
请使用QQ关联注册PLM之家,学习更多关于内容,更多精彩原创视频供你学习!
您需要 登录 才可以下载或查看,没有账号?注册
x
w2 d4 e9 v& V: O
NX二次开放源码分享: 获取装配下所有的实体9 N# n# j3 ~5 l0 V1 h
/ l" o& D! N# ~, x8 e2 F1 A0 u) X
6 _: d# n: L6 s' l2 p
+ E7 Q5 c, ]" s! Kpublic class report_all_bodies_in_assembly_level
L3 i3 l+ t2 \6 v* p+ b2 S& ~{3 G. |! M4 R! q! }% |' p8 t
public static void Main(string[] args)( }# c& g8 A+ u4 M; l
{
: z' X/ y" b- M, L' U4 I Session theSession = Session.GetSession();
) S; S" }. W% X- F+ ^ UFSession theUFSession = UFSession.GetUFSession();
. f' U5 [1 u- R6 ~: t8 k! a$ ? ListingWindow theLW = theSession.ListingWindow;5 _' c( z. Y& h
. y; u9 {2 M E
6 ]1 j% ~8 S# Z8 Y6 d Part theDispPart = theSession.Parts.Display;& L/ K) i$ v$ v8 m: H5 A
List<Body> theBodies = new List<Body>();! F1 F: a. k/ Q! f) t& j
Tag aTag = Tag.Null;
& o0 E& s. Z- o; S( ?' [ int type = 0, subtype = 0;0 S1 g, z* T' `; o$ M2 b
& D) g7 A( I, d# ~9 M- _
: g' H. h0 l5 J' q* V) k' V theLW.Open();
) ^6 L3 P9 `- V do
+ D5 B- j) T' ?" `- u {( W4 p% d. K( q. |: ^5 K2 N
theUFSession.Obj.CycleObjsInPart(theDispPart.Tag, UFConstants.UF_solid_type, ref aTag);: s* R8 T: U9 X3 v5 z
if (aTag == Tag.Null) break;
0 ]1 i D/ T* x6 Z+ F theUFSession.Obj.AskTypeAndSubtype(aTag, out type, out subtype);" X. I0 r d3 L2 ]
: R+ c: l$ f5 a, a
' f, {) B1 g4 L$ w5 t if (subtype == UFConstants.UF_solid_body_subtype)# p# U. d! Q8 B& V( \
{
$ h& Q# H# E- {; ~* ~ Body obj = (Body)theSession.GetObjectManager().GetTaggedObject(aTag);
% @) I0 }; M2 @3 D; A0 } if (obj is Body) theBodies.Add(obj);: Z! s- ?5 Z& \& a% Y
}
7 p; w/ _0 n. ] N( @% _, [) S S/ |- K } while (true);
, R, y, p7 s# V. {6 O8 F+ X& F
4 u) T! y/ c. P4 Q8 d( @
' n. L* u7 h. X3 ?& T9 i theLW.WriteLine("Bodies in the list: " + theBodies.Count.ToString());
1 g; h/ J7 q) x* ~+ @- l foreach( Body theBody in theBodies )
$ d# B4 ?) v K' K {
$ u* [0 f) ]: z1 ^4 p2 h& L if (theBody.IsOccurrence); P0 A0 r: P+ [
theLW.WriteLine(String.Format("Body: {0}, Layer: {1}, IsOccurrence: {2}, Component: {3}"," |' A7 y9 Z4 `
theBody.ToString(), theBody.Layer, theBody.IsOccurrence, theBody.OwningComponent.DisplayName));
( P+ t$ J% k* a& w; ]" t) |, Q8 r, l else( h* p# _6 x, z
theLW.WriteLine(String.Format("Body: {0}, Layer: {1}, IsOccurrence: {2}, Part: {3}",0 @* _3 R& k" S
theBody.ToString(), theBody.Layer, theBody.IsOccurrence, theBody.OwningPart.Leaf));
9 t0 n! B. y7 Q3 X. [5 u! G }
{1 c+ _; _( P- \: Q9 `* v8 F5 z }* ?3 Q k/ w w9 x+ j1 Y
}% O! M9 b. |* c* o+ [' S8 p- Q% c
2 ~9 y' {1 m6 F4 e ~
|
|