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

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

[复制链接]

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

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

admin 楼主

2018-7-27 10:56:17

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

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

x
; d! c) N+ _# N1 Q; n6 a
NX二次开放源码分享: 获取装配下所有的实体
# w- d* J. R% D* ^# L' D( l& N7 \% t7 K; f
: s. D2 v1 D: }* m7 a: H9 `+ F
+ I& s* @- t9 l" @5 {* M8 ?
public class report_all_bodies_in_assembly_level
0 c( ~+ h0 G9 p' b7 c# {  H( n{
  o: F7 \; A$ L  public static void Main(string[] args)3 g/ B7 w- l+ d7 m0 a
  {
* ]; f/ S% Z: s    Session theSession = Session.GetSession();
2 w# F$ H  |. V8 @8 O  Z    UFSession theUFSession = UFSession.GetUFSession();! Q6 b% c0 q0 L3 @( E* U. v
    ListingWindow theLW = theSession.ListingWindow;1 ~5 M' W  i4 l' x
0 ]4 ^; ~3 Y. s1 x' G; v# O

, H' d& {7 O* P( U+ R    Part theDispPart = theSession.Parts.Display;
+ N7 j! c. j$ n2 b3 r* f    List<Body> theBodies = new List<Body>();
7 ], r8 P' `, @0 O( X    Tag aTag = Tag.Null;2 X3 I3 V0 y9 e: G
    int type = 0, subtype = 0;
% f, D! A  g% l* A7 q8 q$ v" `% O, E8 o! B0 a' ~( I
, }9 `  @( U" W- t' U. F
    theLW.Open();) {! E) l) R; i+ \& G) Y" w1 L, U
    do( Z( _) F, J! \, t# q( P
    {
5 m4 U# V' d  T+ c/ R      theUFSession.Obj.CycleObjsInPart(theDispPart.Tag, UFConstants.UF_solid_type, ref aTag);  Q6 B; ?! T$ j5 X1 V
      if (aTag == Tag.Null) break;
0 b6 k1 _# c" M8 z3 q) N$ v& v# X/ Y      theUFSession.Obj.AskTypeAndSubtype(aTag, out type, out subtype);% ]! ~# `5 ^( P' b# ?$ R1 p
& F! n6 C7 v- e

, Z" [  z  C; I- Z9 `% a; I6 t3 J3 \      if (subtype == UFConstants.UF_solid_body_subtype)
! |/ p( L" b: Q$ t, `/ `- G      {9 [' W# I& m4 U" f
        Body obj = (Body)theSession.GetObjectManager().GetTaggedObject(aTag);* C: I0 _' P# {+ P8 U1 P
        if (obj is Body) theBodies.Add(obj);+ C. C1 E& h: w) ~2 F8 A
      }* |6 l" c# \" x  d+ t0 [1 [
    } while (true);
( ?  j- p! n& r, i. u& x9 r7 I8 N7 x- C8 n1 D3 F1 H7 L& a
0 P7 V0 o) C3 K
    theLW.WriteLine("Bodies in the list: " + theBodies.Count.ToString());% `& k' m( Z$ ]) p7 T
    foreach( Body theBody in theBodies )
% N- g8 G/ H) Y" E" }2 V7 a. F    {
0 F. k( `4 x2 R      if (theBody.IsOccurrence)
0 ~9 B7 c  q0 p; z( _( Z        theLW.WriteLine(String.Format("Body: {0}, Layer: {1}, IsOccurrence: {2}, Component: {3}",6 Y9 r* l2 y& b; ]' F) j
          theBody.ToString(), theBody.Layer, theBody.IsOccurrence, theBody.OwningComponent.DisplayName));
5 a4 k* k+ w  B+ E: A      else
6 J+ v% X" _& k$ T        theLW.WriteLine(String.Format("Body: {0}, Layer: {1}, IsOccurrence: {2}, Part: {3}",7 Z  R" _% }5 ~, g2 d0 B* J
          theBody.ToString(), theBody.Layer, theBody.IsOccurrence, theBody.OwningPart.Leaf));
' M  t% z: H5 x" ^( ]    }
; h# V! u% Q) C( X! x/ w  }
$ G1 b) W2 U7 q& a: D}
5 e' U+ }: A# S) x( Q. m) L, G; f/ g$ F1 s; ~
上海点团信息科技有限公司,承接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二次开发专题模块培训报名开始啦

    我知道了