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

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

[复制链接]

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

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

admin 楼主

2018-7-27 10:56:17

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

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

x

) `; l; v# g/ b; R- A$ P- LNX二次开放源码分享: 获取装配下所有的实体3 L+ }8 r" j% r% O2 L9 v

) H; m$ d: O$ X: U! L- C% N6 @4 B/ s5 h3 Y+ o

3 G* t* Y; R3 h8 Y; jpublic class report_all_bodies_in_assembly_level
$ a0 E; o, }% w8 Z5 |{
% K- U$ O$ v+ X# R! j  public static void Main(string[] args)+ T' e) g& I/ O! R
  {
7 k" Y0 q" M8 y    Session theSession = Session.GetSession();3 `  M4 L9 r7 o: S: f! u' k7 `9 Y
    UFSession theUFSession = UFSession.GetUFSession();
% R. N. a% ]4 b3 J    ListingWindow theLW = theSession.ListingWindow;
* i$ M+ I8 u- F' ~% G7 `5 u- ]* f* H6 M! `0 C

% U- {9 n# f: t    Part theDispPart = theSession.Parts.Display;7 x2 m: |: ~$ Q/ j( e  i
    List<Body> theBodies = new List<Body>();7 f2 j" t/ ~0 r7 [6 d0 A
    Tag aTag = Tag.Null;- T9 m2 d0 G2 ?
    int type = 0, subtype = 0;7 Y6 o5 R  G+ o- ?/ S; J( M
2 U2 A# y8 g7 h6 B4 o2 k- r6 ?$ R

' ^- p" V0 X4 G, X, M$ j' n    theLW.Open();
4 X- P3 X+ y( ?0 x    do  U* Y- c7 G. @9 v/ I3 D1 q
    {
0 }- d1 p$ F3 Q+ k      theUFSession.Obj.CycleObjsInPart(theDispPart.Tag, UFConstants.UF_solid_type, ref aTag);6 d% Z8 I  b0 v4 r
      if (aTag == Tag.Null) break;# t2 p: E; z  \5 n+ r7 k7 U
      theUFSession.Obj.AskTypeAndSubtype(aTag, out type, out subtype);
# h6 L+ y9 \. j' A
+ `3 w* |. ]1 i$ g8 J$ c& W

* j8 \$ ~6 j( K9 B) M. M9 Z      if (subtype == UFConstants.UF_solid_body_subtype)/ f+ r# z& }& Y- @
      {, V0 v# _) d6 x# n1 m; t, M8 k
        Body obj = (Body)theSession.GetObjectManager().GetTaggedObject(aTag);
8 m4 g0 Z: C' E* u+ e        if (obj is Body) theBodies.Add(obj);
9 J- X3 r9 v9 ~( s! y      }
* ~. U, `; @; h: o- h( c% b    } while (true);
7 [( K! p2 ?; r/ D: H( C
7 b% |. v# v6 g. @
! ?" o9 j' E8 u8 l: N  V( o
    theLW.WriteLine("Bodies in the list: " + theBodies.Count.ToString());4 R, @, f4 B7 i. J5 ]( @& q
    foreach( Body theBody in theBodies )
! Z4 `$ P% h! d1 s5 O    {4 o8 F, R$ k0 S' S
      if (theBody.IsOccurrence)( H8 D( Y! i/ f1 d& v. ?. h, Y2 j% s
        theLW.WriteLine(String.Format("Body: {0}, Layer: {1}, IsOccurrence: {2}, Component: {3}",
+ L6 @6 i6 t, y          theBody.ToString(), theBody.Layer, theBody.IsOccurrence, theBody.OwningComponent.DisplayName));
! h% m! C8 J0 i. M- _+ ?$ @- m  h      else" r- ~( o' k7 q
        theLW.WriteLine(String.Format("Body: {0}, Layer: {1}, IsOccurrence: {2}, Part: {3}",
- B2 ?6 ~8 t7 x. J          theBody.ToString(), theBody.Layer, theBody.IsOccurrence, theBody.OwningPart.Leaf));; s0 L& J$ p" w4 u0 k* e% ~8 f
    }! L- A2 c0 {5 @- [( x" ]2 u  Z3 B
  }
9 t9 a$ |' X0 Q1 R: B* l; E}
  V' b3 W& s& e
& ]  d8 f% ]8 s3 l8 ~7 I
上海点团信息科技有限公司,承接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二次开发专题模块培训报名开始啦

    我知道了