PLM之家PLMHome-国产软件践行者

[二次开发源码] NX二次开放源码分享: 获取装配下所有的实体

[复制链接]

2018-7-27 10:56:17 2004 0

admin 发表于 2018-7-27 10:56:17 |阅读模式

admin 楼主

2018-7-27 10:56:17

请使用QQ关联注册PLM之家,学习更多关于内容,更多精彩原创视频供你学习!

您需要 登录 才可以下载或查看,没有账号?注册

x

0 p8 K& n5 Q( `7 ENX二次开放源码分享: 获取装配下所有的实体; ]2 d3 t2 E' h% T( H  r
6 z* ^' l) I9 F$ S* \+ F

" q8 Z1 N6 N5 e2 s; ]* @
7 i1 q6 u# Q3 K, _6 Cpublic class report_all_bodies_in_assembly_level/ ?, K- |% Z; r$ I  K
{/ b: `2 e; x9 Y0 \* {9 {
  public static void Main(string[] args)
' Q+ z! _$ q0 Y- {  {
4 J7 a. i2 E3 q( j: _! n3 X8 @. b    Session theSession = Session.GetSession();
1 r; T5 K3 ]8 ?# [! |    UFSession theUFSession = UFSession.GetUFSession();
* S- a$ Z! h* P; L! Z& ^    ListingWindow theLW = theSession.ListingWindow;
8 \1 s- p" i0 y
  _+ C; e/ L/ Q5 W) x; o
3 d3 ]. K9 z) \; v
    Part theDispPart = theSession.Parts.Display;
( g! l5 k# U- s2 o/ A8 I) G    List<Body> theBodies = new List<Body>();$ `# u' t. B4 o& B9 n
    Tag aTag = Tag.Null;' V; {  p8 O" d+ T2 @9 ^
    int type = 0, subtype = 0;
" `7 s$ B+ S6 R, d- w7 Q1 R  Q7 V* C* ~0 K0 G( `
7 w# x, U  l, c- W- E: O' ]
    theLW.Open();
5 S$ K, O) s/ u% ~    do- B& ?# S/ Y. Y  W
    {0 x, \5 }8 B* Q
      theUFSession.Obj.CycleObjsInPart(theDispPart.Tag, UFConstants.UF_solid_type, ref aTag);
3 U, i  S& x, C2 k      if (aTag == Tag.Null) break;6 V" ?, j- L$ O# z8 t* Z9 E
      theUFSession.Obj.AskTypeAndSubtype(aTag, out type, out subtype);
6 X# h% t# C6 j
9 y# ^' }/ {' w0 H

& Q$ x% E4 X+ z+ `& ~6 [) q( F( |      if (subtype == UFConstants.UF_solid_body_subtype)
+ E4 H! U% p, `" ^, W      {
& l) w; ?) [" E) q" g. F) |        Body obj = (Body)theSession.GetObjectManager().GetTaggedObject(aTag);
, y; e6 e/ L0 D2 R% s: [1 i+ }        if (obj is Body) theBodies.Add(obj);
6 X. B: A9 ~" j: W4 t0 S/ w7 x      }' B4 ?% \8 _6 ^2 {
    } while (true);
: H9 ~5 |. e& [6 [, D$ _7 Q3 I5 g4 p* _
$ Y# q9 `7 Q! p* A1 d. J' K
: W2 t; @: M$ Q. u; X7 F! \. g2 `0 t$ \
    theLW.WriteLine("Bodies in the list: " + theBodies.Count.ToString());0 b* Z- u% k5 c
    foreach( Body theBody in theBodies )
) l! r5 H/ \9 Z1 S1 ]8 |    {
+ @% ?' k% a5 n( s6 r      if (theBody.IsOccurrence)+ q, R  \. w9 Z/ d$ U4 Z( C
        theLW.WriteLine(String.Format("Body: {0}, Layer: {1}, IsOccurrence: {2}, Component: {3}",
2 F& n% ~4 |( R" a4 |          theBody.ToString(), theBody.Layer, theBody.IsOccurrence, theBody.OwningComponent.DisplayName));5 X; z& k, H6 ?8 `: |; d$ }
      else
) }8 U& m& s$ K6 K8 G        theLW.WriteLine(String.Format("Body: {0}, Layer: {1}, IsOccurrence: {2}, Part: {3}",+ N: b% E- h. c! W/ O( K6 a
          theBody.ToString(), theBody.Layer, theBody.IsOccurrence, theBody.OwningPart.Leaf));
3 R6 L6 i' g9 C  b- r! I    }5 b% K( ~- r' H6 t. E. x( M3 w
  }/ L4 k6 V% K; p5 F5 \3 h, F" u7 B& k
}
" b7 L9 E4 D! I5 H5 R0 J2 Z; Z& @8 w3 I0 G. H
上海点团信息科技有限公司,承接UG NX,CATIA,CREO,Solidworks 等CAx软件,Teamcenter,3D Experience等PLM软件,工业4.0数字化软件的实施\二次开发\培训相关业务,详情QQ 939801026 Tel 18301858168 网址 doTeam.tech
回复

使用道具 举报

发表回复

您需要登录后才可以回帖 登录 | 注册

返回列表 本版积分规则

  • 发布新帖

  • 在线客服

  • 微信

  • 客户端

  • 返回顶部

  • x
    温馨提示

    本网站(plmhome.com)为PLM之家工业软件学习官网站

    展示的视频材料全部免费,需要高清和特殊技术支持请联系 QQ: 939801026

    PLM之家NX CAM二次开发专题模块培训报名开始啦

    我知道了