PLM之家PLMHome-工业软件践行者

[二次开发源码] NX二次开发源码: 使用NX OpenC++查询装配组件并判断加载状态

[复制链接]

2013-12-8 00:59:17 3682 1

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

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

x

; N7 K3 G' u( m! L/ KNX二次开发源码: 使用NX OpenC++查询装配组件并判断加载状态
% R1 U7 z6 k( D/ B
. y+ c) S1 |0 [( l+ E% `

NX二次开发源码: 使用NX OpenC++查询装配组件并判断加载状态

NX二次开发源码: 使用NX OpenC++查询装配组件并判断加载状态
. E6 G& d4 z2 ]" c/ a/ n0 {
  1. <p>static void geTChildren(Assemblies::Component *rootcomponent,unsigned int indent)
    0 k3 l( w! N, S( c4 M, J$ r
  2. {       # `7 h1 j5 l; ~+ C
  3.   + w2 }' x8 R2 o. y' A
  4.   unsigned int ii;3 M/ `; Y% w* t8 ?% c
  5.   char space[MAX_LINE_SIZE+1] = { " " };
    : C2 U6 I9 l/ H' k" f
  6.    for (ii = 0; ii < indent; ii++) strcat(space, " ");% o6 y$ ~. [) n5 R0 E3 B1 w
  7.   std::vector<Assemblies::Component *>components;
    ; K* k& V1 H2 @$ H
  8.   Session *theSession = Session::GetSession();8 u  d3 S( @* s* i2 `* p
  9.   ListingWindow *lw = theSession->ListingWindow();
    4 @- {! U. ~$ }$ l: m2 e- o# N* Q2 Z+ r# A
  10.      lw->Open();
    3 w5 M$ J! D1 ~4 j, I/ |
  11.   components = rootcomponent->GetChildren();0 {$ j- \8 d. x
  12.       for (int i = 0 ; i <components.size();i++)2 s  @# B3 w- @' a3 p' Y  n" @
  13.       {
    / X: o/ W  G) ?4 v' o+ U( Q  v
  14.        Part *childpart = dynamic_cast<Part*>(components[i]->Prototype());) ?* V# G. w, ?5 [- W
  15.      
    . j$ L( a! z: {) n% k
  16.       if(childpart==NULL)
    : m9 F. M. O" ?4 d
  17.        {
    / d0 E  j2 ]& d$ ~9 j' b$ _
  18.         lw->WriteLine(space+components[i]->DisplayName()+"\t"+"Status: not loaded!");- b3 C2 |  l6 l9 u' I: O
  19.         }3 |1 T$ [# j" H( f; S$ Z) `
  20.        else
    - H6 i% G, W5 p" N8 {
  21.        {
    # w3 R3 \7 }& b$ S
  22.         if (childpart->IsFullyLoaded())+ t- f8 I. D5 @
  23.          {
    # n6 c- J1 I7 f$ V7 p8 q& s
  24.           lw->WriteLine(space+components[i]->DisplayName()+"\t"+"Status: IsFullyLoaded!");
    # b" X9 u" k! V1 N$ H' X& t1 E
  25.          }; E$ b0 e" ^% ]2 R. C7 y2 [0 B' w0 j
  26.         else    B# z8 U5 Z6 Y) f7 u7 F  R# f
  27.          {
    + O8 y: I/ T! N
  28.           lw->WriteLine(space+components[i]->DisplayName()+"\t"+"Status: IsPartiallyLoaded!");) P& R8 x% L* S
  29.          }  [4 D4 v3 m& x
  30.         
    : U6 D% J! O  h; u
  31.       + {4 o  B1 l( u2 M) Z: F+ U6 Q
  32.         getchildren(components[i],indent+5);
    4 X! x0 `- O( N3 ~" e0 ~2 O
  33.       }- R' _+ s2 I, P8 o  _8 p
  34.       }7 k( ^( g+ h. ]
  35. }</p><p>static void do_api()
    7 A# u* Y1 C- O* {1 d# _
  36. {- z0 Y, g# m9 q8 b- \- |2 o
  37. //list the components
    ! s4 L7 n2 ]2 w6 t; J' ]+ U- H
  38.   Session *theSession = Session::GetSession();
    ! l2 J. y+ W$ U4 l; B
  39.   ListingWindow *lw = theSession->ListingWindow();: Y) W# k4 l! S% L# i
  40.   lw->Open();9 s2 r* U. `# T8 i
  41.   Assemblies::Component * rootcomponent;" f$ x% {& P$ J4 z, f- H4 E2 `
  42.   Part *workpart;
    $ M2 i9 E0 L* z, i" C' p
  43. rootcomponent = theSession->Parts()->Display()->ComponentAssembly()->RootComponent();
      j# L( M% X, K
  44. workpart = theSession->Parts()->Work();
    * g: q  Y$ |9 l( i8 B: S
  45. lw->WriteLine("The workpart is : "+workpart->FullPath()+ "\n" );' V+ [) ?% Q3 J: I
  46. if(rootcomponent==NULL)5 v! F) I; k2 u$ z' X
  47. {  
    0 j1 U' D  o! T7 P
  48.     lw->WriteLine("The part is not an assembly ! \n " );
    & G3 ~( p- V/ Q7 w
  49. }& l# Q! z- ~* u8 _! h) v
  50. else
    ' C& d& P) I$ Q- Q% U3 O  w+ [
  51. {+ }3 t) ^& j/ s
  52.   lw->WriteLine("The rootcomponent is : " +  rootcomponent->DisplayName()+"\n");
    6 b8 f& s7 m" O. K. |
  53.   lw->WriteLine("The children components are : \n");
    & T: R0 a/ L8 @9 I7 D, d; o1 k
  54.      getchildren(rootcomponent,4);$ W/ k! r7 v# ~: p. \
  55. }</p><p>}' R+ @9 O: a/ G' H$ Z+ c9 M2 \
  56. </p><p> </p>
复制代码

* t8 D8 r$ u5 a5 E8 n
该会员没有填写今日想说内容.
回复

使用道具 举报

全部回复1

牧马人 发表于 2013-12-8 00:59:17

牧马人 沙发

2013-12-8 00:59:17

嗯,这个不错
上海点团信息科技有限公司,承接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二次开发专题模块培训报名开始啦

    我知道了