PLM之家PLMHome-工业软件与AI结合践行者

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

[复制链接]

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

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

admin 楼主

2018-7-27 10:56:17

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

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

x

0 q: E) [& D- p4 ?+ u1 m+ D+ @. kNX二次开放源码分享: 获取装配下所有的实体
' @" h+ \: S: |- N0 y$ }
. V9 \4 n) t8 m; W7 V
" i5 H/ F$ {4 c
* |5 A/ S2 @9 M* l* F+ Kpublic class report_all_bodies_in_assembly_level
1 ^9 A, k1 A& b. a$ v0 V" i{
+ q( d9 T+ @* J7 |  public static void Main(string[] args)4 f' |. U9 i% [1 m' D
  {0 R8 C1 s9 d* {. [# i
    Session theSession = Session.GetSession();& T2 p' n" C, E$ J5 Z" @/ A
    UFSession theUFSession = UFSession.GetUFSession();
2 F4 [7 v; O4 p$ u7 y9 f7 W4 A3 k    ListingWindow theLW = theSession.ListingWindow;
2 {( z. e& Z4 F5 P4 F# Z# A% s0 K# ]9 J) [/ A% m! z6 o6 v$ Z2 W7 r( y

* v1 K' J* Z4 S0 X- t    Part theDispPart = theSession.Parts.Display;" L- M; p3 X7 |$ \3 q7 O" p
    List<Body> theBodies = new List<Body>();6 q- H$ M. w3 P; q9 }
    Tag aTag = Tag.Null;- ~, ]- @( d, ?6 o) ^" n- g
    int type = 0, subtype = 0;
+ \3 @; N" A9 ^9 P" M) V
1 ?; N  b2 c3 W2 X6 l/ o

! j6 Z+ ]+ Y9 |1 {& o    theLW.Open();0 m1 y! `) F. v* ^8 Z
    do( w! v' g8 o. I& z2 f
    {3 {1 H7 F2 X( I, C
      theUFSession.Obj.CycleObjsInPart(theDispPart.Tag, UFConstants.UF_solid_type, ref aTag);  L' D* t/ j+ \
      if (aTag == Tag.Null) break;9 \% P6 d7 L8 D/ n$ z
      theUFSession.Obj.AskTypeAndSubtype(aTag, out type, out subtype);
. g+ K; @9 w$ b+ B4 T% w- L
1 c! F& P0 n$ W  j- S5 b( R

2 a9 L( S) h$ U0 \      if (subtype == UFConstants.UF_solid_body_subtype)
7 W( S6 t. }4 z; m0 c      {, U. n6 v( z6 ~+ A
        Body obj = (Body)theSession.GetObjectManager().GetTaggedObject(aTag);' }+ h8 z. E& r% D9 Q. \7 z8 b
        if (obj is Body) theBodies.Add(obj);9 Q9 |! C1 V' }! ^8 ^
      }6 T: S& g( W  K. K
    } while (true);3 W. j# |; L3 R" E! l5 b! i: K

" }5 [& U) d7 _8 m, s
+ {, U+ l" |  N1 V* B; ?
    theLW.WriteLine("Bodies in the list: " + theBodies.Count.ToString());. f) l4 N: A1 T( d- p/ Q
    foreach( Body theBody in theBodies )4 ^2 C5 U0 R  Q4 e& D/ Q
    {
9 M6 [1 c) ~* J' M& o7 G      if (theBody.IsOccurrence)1 w7 K  k4 ^4 N
        theLW.WriteLine(String.Format("Body: {0}, Layer: {1}, IsOccurrence: {2}, Component: {3}",, n. K: C' ^* S# `4 c: [, J/ e
          theBody.ToString(), theBody.Layer, theBody.IsOccurrence, theBody.OwningComponent.DisplayName));
+ @$ l3 }- \, j      else
) v$ t1 K% I8 Q$ S/ f- J        theLW.WriteLine(String.Format("Body: {0}, Layer: {1}, IsOccurrence: {2}, Part: {3}",
! j6 [; r5 Q1 \- G2 T& S          theBody.ToString(), theBody.Layer, theBody.IsOccurrence, theBody.OwningPart.Leaf));
: g" @/ t/ U8 S  V3 ]    }
# |; c# Y0 `- D  H2 W6 V* @# t" `  }- i! Y7 M; S: M$ z6 o
}; @2 _$ y( q) K: u. y
0 B( N, ~" P+ O
上海点团信息科技有限公司,承接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二次开发专题模块培训报名开始啦

    我知道了