|
|
请使用QQ关联注册PLM之家,学习更多关于内容,更多精彩原创视频供你学习!
您需要 登录 才可以下载或查看,没有账号?注册
x
; ^/ w( n1 F- U9 O! {3 Y+ B! F
NX二次开放源码分享: 获取装配下所有的实体
) [% B$ t& P' }3 S$ {/ c9 D, f' e1 w
0 X9 Z* L; @9 K) x: i; {: W" b5 c6 t" L: _+ x' p" n- }
public class report_all_bodies_in_assembly_level" U' k3 q6 D: |: b
{
" j+ J1 w/ I9 y* O& ? public static void Main(string[] args)% f; b4 e: ^- a# w/ X, [
{. J" s0 s+ E) b! F
Session theSession = Session.GetSession();! z5 _# o$ p( ~" k
UFSession theUFSession = UFSession.GetUFSession();" V! \1 D+ e4 g" f: U2 N+ X( p
ListingWindow theLW = theSession.ListingWindow;& G) Q$ h( Q" [
, q3 g- ]6 y, E# r2 y Q- Z" }9 s+ [
Part theDispPart = theSession.Parts.Display;
7 Q& g' \6 S3 d# D List<Body> theBodies = new List<Body>();
% ^& R) H2 ]) l Tag aTag = Tag.Null;
! E' s4 F# [) x& B4 q int type = 0, subtype = 0;
% u: M# q S2 F" Y9 W! [+ `$ A; q( Q# E; o+ ]" q8 Z1 k8 z$ d+ U
4 V8 w5 y! [! N3 S theLW.Open();
2 P5 G! Q$ \8 n6 c' _! t, A% m do! k. b$ ]* X! o, d
{
) d/ L% E: s* j% [1 @ theUFSession.Obj.CycleObjsInPart(theDispPart.Tag, UFConstants.UF_solid_type, ref aTag);# q( t. A2 L* J p4 J
if (aTag == Tag.Null) break;
3 x0 ^- o6 C1 P" Y theUFSession.Obj.AskTypeAndSubtype(aTag, out type, out subtype);) y( H! y! u; _8 p- {3 `) X8 [
3 c9 w/ ?/ y; s+ E7 } Z( ~& c
8 w& i& \# ~8 _5 z% Y; ]3 d& U
if (subtype == UFConstants.UF_solid_body_subtype)- O2 ~+ I( H- o3 P
{$ r# `4 p: I# [; x f
Body obj = (Body)theSession.GetObjectManager().GetTaggedObject(aTag);+ J v! j% [2 Q! j9 g% k2 |
if (obj is Body) theBodies.Add(obj);9 y' k, b, M9 ~( w( I3 E+ n- r
}/ ~$ L% S1 l* R7 G* Q) d
} while (true);4 ?2 h. g) t4 z2 u
! ]4 f- K( w: [" I
# p- }9 v; H! Q! I6 u
theLW.WriteLine("Bodies in the list: " + theBodies.Count.ToString());' K$ i: I- i( j
foreach( Body theBody in theBodies )
5 g& F" K/ W; g7 | {- ^% c% J2 Z" b
if (theBody.IsOccurrence)
" T' H& f0 ~: I( m( R G theLW.WriteLine(String.Format("Body: {0}, Layer: {1}, IsOccurrence: {2}, Component: {3}",- C* |5 X' E! w* n$ v
theBody.ToString(), theBody.Layer, theBody.IsOccurrence, theBody.OwningComponent.DisplayName)); M* ^! F% s! d- ?2 |4 L
else
9 T$ P( m2 C: R) O9 b o# \) f0 J; w theLW.WriteLine(String.Format("Body: {0}, Layer: {1}, IsOccurrence: {2}, Part: {3}",; |% D- _# O4 u& O5 T. `
theBody.ToString(), theBody.Layer, theBody.IsOccurrence, theBody.OwningPart.Leaf));9 o/ b7 M) i S, Z$ r
}
; Z9 V. Y: P9 [ }
1 ^5 \8 U% _4 k- w$ X}
% t8 d5 z6 e1 T0 t/ o) S2 t( f7 W8 B* A
|
|