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

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

[复制链接]

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

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

admin 楼主

2018-7-27 10:56:17

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

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

x
$ R* V7 Z( N/ o3 J1 |# N
NX二次开放源码分享: 获取装配下所有的实体0 ~' f2 _7 }9 l: i- i* A
5 T  G! g2 i& Y# X' h% Y" _! u

. e& ^' Z6 d& Z" j) u+ `
0 B, P! ^! v/ n- r1 n) T/ @7 b  ]6 ]public class report_all_bodies_in_assembly_level  N: x2 ^8 `+ M: u6 F
{+ j' L$ {8 b# W. X! S1 l+ m4 m
  public static void Main(string[] args)0 G- Q, J' z0 B3 ]
  {
% E& x- F! N2 h; T    Session theSession = Session.GetSession();- Z# |; Q. B6 n7 {; T
    UFSession theUFSession = UFSession.GetUFSession();, ^7 Q# \# d: m  f/ p
    ListingWindow theLW = theSession.ListingWindow;
! I8 f) B. `! d4 {  e! `' L2 \  z/ }0 p0 j8 z4 }+ q" b

8 ?9 J* w2 h* W# R! ^5 j, Z& G    Part theDispPart = theSession.Parts.Display;
0 A+ G" ~, t* _! S6 q    List<Body> theBodies = new List<Body>();
5 V' E' r2 A: F6 Y; l) Z4 a    Tag aTag = Tag.Null;2 b% H- Y4 f0 O0 n8 l7 f( M
    int type = 0, subtype = 0;$ y) Q0 K# ?5 V+ O' C9 x

  F% u. f; P; A8 t! i; V
! ?% B4 s. I2 D% Y: Q  k, f) n6 e
    theLW.Open();5 C  u  f" G7 E" ?
    do; R% V. i# t# @' _' `$ t, Q
    {
8 `7 z% S8 ~6 X; b      theUFSession.Obj.CycleObjsInPart(theDispPart.Tag, UFConstants.UF_solid_type, ref aTag);- [* `" S; p7 o: V
      if (aTag == Tag.Null) break;
6 Z1 |- C: L8 B0 D      theUFSession.Obj.AskTypeAndSubtype(aTag, out type, out subtype);
7 D" N- m/ _# l$ _7 J$ e2 a- A. E7 ~, n! a  ^

' a& Y) }6 @; D3 U- M+ y* w      if (subtype == UFConstants.UF_solid_body_subtype)+ x2 ]) x) u/ b- p& M* e9 p- m
      {, m( z0 d5 a* q- m! T
        Body obj = (Body)theSession.GetObjectManager().GetTaggedObject(aTag);2 ~9 j' B: f' K2 {
        if (obj is Body) theBodies.Add(obj);# @) M, J/ z" c6 P) _
      }
/ }$ ~% \& J- x+ q$ M    } while (true);
/ N9 k$ r1 w$ b9 g: ]4 U$ |+ ?2 W5 I4 `7 @8 s6 ^/ [2 d

% T6 k( T/ f/ r: s: F    theLW.WriteLine("Bodies in the list: " + theBodies.Count.ToString());; K2 J/ W' {& e/ a$ [
    foreach( Body theBody in theBodies )- F$ Y( v! @4 |, o: f( R9 i
    {
6 w" ]. z4 n+ \2 g      if (theBody.IsOccurrence)
) b7 I, Z! X  J( c8 b3 V! D        theLW.WriteLine(String.Format("Body: {0}, Layer: {1}, IsOccurrence: {2}, Component: {3}",1 \2 n, P" d: K4 T( j
          theBody.ToString(), theBody.Layer, theBody.IsOccurrence, theBody.OwningComponent.DisplayName));
6 {- z/ _2 Q0 j6 j  g" I/ m  ~      else! A$ @6 _# u& Y1 K8 \8 q6 [
        theLW.WriteLine(String.Format("Body: {0}, Layer: {1}, IsOccurrence: {2}, Part: {3}",
0 r8 Q) m% A1 D, I' F          theBody.ToString(), theBody.Layer, theBody.IsOccurrence, theBody.OwningPart.Leaf));. J9 d6 C5 X/ U" t# J9 @
    }
& g# y& R/ L* ~/ R( b: ?8 V  }9 h; r0 s- @- N8 {) o- _
}- i; o; }- B. B

% J$ j6 D- P# F) S
上海点团信息科技有限公司,承接UG NX,CATIA,CREO,Solidworks 等CAx软件,Teamcenter,3D Experience等PLM软件,工业4.0数字化软件的实施\二次开发\培训相关业务,详情QQ 939801026 Tel 18301858168 网址 www.diantuankj.com/ doTeam.tech
回复

使用道具 举报

发表回复

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

返回列表 本版积分规则

  • 发布新帖

  • 在线客服

  • 微信

  • 客户端

  • 返回顶部

  • x
    温馨提示

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

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

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

    我知道了