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

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

[复制链接]

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

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

admin 楼主

2018-7-27 10:56:17

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

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

x
, P* E& }5 U/ y- B; h$ E% R1 q2 M
NX二次开放源码分享: 获取装配下所有的实体4 K  `# o9 W1 c6 g& w

; h8 M+ _" ^5 y* q
  w5 u6 n& t# {) f1 M/ Y2 u1 W* b! e" y6 @. x9 [
public class report_all_bodies_in_assembly_level
1 k' R7 K% Q4 X' F* u$ q5 K1 m{
& x' N' ?! g7 t  public static void Main(string[] args)
! w4 i3 G1 N4 L- B8 {8 h! F  {
6 T% H+ I* W/ h/ }    Session theSession = Session.GetSession();
' ^$ ]' N4 s- T& S4 u# X  ?    UFSession theUFSession = UFSession.GetUFSession();
# j+ t5 P: W# G! a    ListingWindow theLW = theSession.ListingWindow;4 m3 Q) `# i! F3 i. g$ p
) O2 i" [) @* S9 w

' {& g2 G; ]2 ?9 h$ E    Part theDispPart = theSession.Parts.Display;2 J4 _) p$ ^/ }( d/ M- h: R! W1 \3 g
    List<Body> theBodies = new List<Body>();4 E3 S4 K$ q" A
    Tag aTag = Tag.Null;
! q2 `: E1 ?* G8 |: N9 o8 f+ `    int type = 0, subtype = 0;) n! J( E" D) e  V8 j6 o

8 o- [7 C/ J% Y
9 d- K  _" @  b/ r% g
    theLW.Open();
! y# h4 L; e! {# ]: m8 \" C4 |    do0 K7 G' o) n' B+ d3 n  }8 z3 S
    {
: ^! L% p8 w( L! Q* O      theUFSession.Obj.CycleObjsInPart(theDispPart.Tag, UFConstants.UF_solid_type, ref aTag);
: n: `6 L, J' u. P& \      if (aTag == Tag.Null) break;+ `: b) u! s  s; a" ^3 X
      theUFSession.Obj.AskTypeAndSubtype(aTag, out type, out subtype);8 [; u1 e, z6 x& f, i" G$ f3 z# u% ?
- ]( X4 e8 e) v
* o1 R8 F- i2 S( u/ W$ q
      if (subtype == UFConstants.UF_solid_body_subtype)$ \7 `- ~. L( x
      {+ R5 D8 X6 r2 G! ~* Q
        Body obj = (Body)theSession.GetObjectManager().GetTaggedObject(aTag);
  O+ Y/ J: d. T6 _/ |        if (obj is Body) theBodies.Add(obj);, |; q) F2 l( q4 Y  U
      }
) k+ B8 R0 p" M0 t8 c- {    } while (true);6 a6 _: D7 ^+ G( S3 Y$ v2 s

+ w# ]$ J2 k4 V* o  m: V

4 n- Y9 @' \5 n( s$ m; b    theLW.WriteLine("Bodies in the list: " + theBodies.Count.ToString());! j5 n0 S0 j6 V0 M( b5 X  q9 s
    foreach( Body theBody in theBodies )" I* k7 e4 v  ]+ }; ~2 K' [1 C/ s  f
    {
; j+ M, n; Z7 g1 e6 G      if (theBody.IsOccurrence); X9 `' S, T! G" s" W$ R: T
        theLW.WriteLine(String.Format("Body: {0}, Layer: {1}, IsOccurrence: {2}, Component: {3}",$ [* Z9 }# }8 q" b/ K9 R' [' V7 C( o
          theBody.ToString(), theBody.Layer, theBody.IsOccurrence, theBody.OwningComponent.DisplayName));
/ o! N7 l# E5 h8 j# b$ _      else6 E8 z. F3 c2 F- ?
        theLW.WriteLine(String.Format("Body: {0}, Layer: {1}, IsOccurrence: {2}, Part: {3}",
! V: p) B2 J: j* ?# B4 M4 p% O          theBody.ToString(), theBody.Layer, theBody.IsOccurrence, theBody.OwningPart.Leaf));
4 @2 r6 W8 s, }    }
- b: C5 m: ^' h+ U1 U( F# R  S2 b  }
0 Z# C9 Z2 O: `. R}- ]! W* u: U+ z! P3 K9 k
: H, r1 \( u( u4 r# ^- m
上海点团信息科技有限公司,承接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二次开发专题模块培训报名开始啦

    我知道了