PLM之家PLMHome-工业软件践行者

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

[复制链接]

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

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

admin 楼主

2018-7-27 10:56:17

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

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

x

' u% d6 X" w. A3 {4 o8 w: K1 GNX二次开放源码分享: 获取装配下所有的实体
  \2 {5 A2 [4 c' `0 v; c/ ^8 u8 c8 R+ B! P7 W! {

, C, e% B) ~& |' A5 N3 B& K
( g6 P  U! w/ m8 e* n6 Tpublic class report_all_bodies_in_assembly_level5 J& w$ a: q1 m8 t( Q% K
{( M# \$ W* P. T2 w. |
  public static void Main(string[] args)3 B& ~: c8 ^* a3 I2 w9 `
  {+ t) J5 @! j2 s, g" P7 u) L  Q
    Session theSession = Session.GetSession();
/ [5 B5 @% m1 I6 i: _! c; c    UFSession theUFSession = UFSession.GetUFSession();$ S* u( {; T& v& u
    ListingWindow theLW = theSession.ListingWindow;4 S: U* H3 F8 E! A
7 Z0 d6 X  n3 d) z4 Q5 z

& S- E# W1 i* g1 G4 m9 Q    Part theDispPart = theSession.Parts.Display;6 W$ R. \# x$ T6 ^
    List<Body> theBodies = new List<Body>();
! A- Y+ v5 c6 ~/ E/ }0 K$ v: a    Tag aTag = Tag.Null;0 Q$ c) j9 {, ]! e
    int type = 0, subtype = 0;
+ d! e2 a6 J3 j; L& j. F6 }, h: m
( Q+ p0 o! H5 t9 H+ P

; |2 p0 W2 L: m+ j1 v0 @6 `6 y    theLW.Open();
9 B4 K% L3 l2 v  k1 \& T    do& r0 v5 _9 S) v7 G
    {7 n. F: X( t$ K# }/ `' ~
      theUFSession.Obj.CycleObjsInPart(theDispPart.Tag, UFConstants.UF_solid_type, ref aTag);0 M7 Y$ t; q( S1 |6 b  ~/ G3 v
      if (aTag == Tag.Null) break;$ S; x- G/ \$ ]' e0 y
      theUFSession.Obj.AskTypeAndSubtype(aTag, out type, out subtype);
% `8 _+ }; i6 y5 \4 Q8 \2 a7 A; Q2 _7 [4 o1 h' `. W

( W" i  w. h0 e0 p      if (subtype == UFConstants.UF_solid_body_subtype)
& m4 X4 K) p3 J" v+ O: d' E+ n      {
6 c; S1 R. u8 l) U        Body obj = (Body)theSession.GetObjectManager().GetTaggedObject(aTag);
$ p9 g% z, u, T( B: ?        if (obj is Body) theBodies.Add(obj);& x- W9 `7 ]3 ~7 }* x5 M
      }
9 O3 {' E8 a/ t    } while (true);+ P% {2 ~6 j9 |/ H/ c6 U

% ?$ J2 X0 w4 c5 b) K8 V( p

5 l- X7 r* S1 a0 w: o& J    theLW.WriteLine("Bodies in the list: " + theBodies.Count.ToString());9 Q% X: n$ ~9 Y7 b" y1 ~" j
    foreach( Body theBody in theBodies )
: p! C/ Z6 ~7 w4 A    {
  t$ Z* d# @# T/ y1 w' E      if (theBody.IsOccurrence): N2 r+ b- F( D9 z% T: \6 p
        theLW.WriteLine(String.Format("Body: {0}, Layer: {1}, IsOccurrence: {2}, Component: {3}",, `3 |4 X* k0 a1 N' Y3 D8 B9 J* E
          theBody.ToString(), theBody.Layer, theBody.IsOccurrence, theBody.OwningComponent.DisplayName));
3 ?, @. q! H- K1 G% }8 R% ^3 E      else/ H- b, u- h) O, a5 \( A  g
        theLW.WriteLine(String.Format("Body: {0}, Layer: {1}, IsOccurrence: {2}, Part: {3}",- B2 _* M+ t/ K# E* K& M
          theBody.ToString(), theBody.Layer, theBody.IsOccurrence, theBody.OwningPart.Leaf));
: B) c, v7 z* p    }
4 [' r4 h' ]5 i1 f% Q' H  }3 K- [- l0 m: j5 r) z
}& M3 V" ?$ v- ~4 ^
+ H; ]& f8 U5 x8 ^. e
上海点团信息科技有限公司,承接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二次开发专题模块培训报名开始啦

    我知道了