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

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

[复制链接]

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

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

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

x

& r% H1 C! _! I7 s) D) lNX二次开发源码: 使用NX OpenC++查询装配组件并判断加载状态
# p" d3 p4 u% h' ]' o" P3 `% Y+ M  G; e) g  }2 c( ^

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

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

/ s3 ]. h. K, f" Y2 g) f0 k- w4 b0 ~. Y
  1. <p>static void geTChildren(Assemblies::Component *rootcomponent,unsigned int indent)1 k) e6 s) X1 _0 Z8 w
  2. {      
    ' R$ ^1 [8 _7 N
  3.   1 {8 g) |+ |9 G7 Z' b" O/ \! x  l
  4.   unsigned int ii;, K. }* j, V3 M
  5.   char space[MAX_LINE_SIZE+1] = { " " };
    : y; L, \" v7 f- i* H5 n
  6.    for (ii = 0; ii < indent; ii++) strcat(space, " ");* V$ p6 s, Y( L
  7.   std::vector<Assemblies::Component *>components;
    - Z/ M5 r: _! g9 l+ l) O6 B
  8.   Session *theSession = Session::GetSession();: {  s3 h) Y6 ~9 d* W
  9.   ListingWindow *lw = theSession->ListingWindow();
    1 [, |) m& t9 d6 z. x3 y
  10.      lw->Open();3 c' m# k6 T" o/ {
  11.   components = rootcomponent->GetChildren();- e3 c5 z$ C9 @
  12.       for (int i = 0 ; i <components.size();i++)
    9 W* R, l8 D, m& M4 Q0 S( E  n
  13.       {
    / h5 j" |6 R7 T0 e3 U9 {6 o5 P. _) R* {5 F
  14.        Part *childpart = dynamic_cast<Part*>(components[i]->Prototype());8 |' m7 w% s; |& ?# F
  15.      
    ( y, X3 N3 n, C$ \1 @5 b% K, o
  16.       if(childpart==NULL)
    + X1 l* i: m( P8 `" J0 f1 l/ D5 ^
  17.        {
    ' C" x7 E, l+ }& \) M2 D3 ~
  18.         lw->WriteLine(space+components[i]->DisplayName()+"\t"+"Status: not loaded!");& `$ H( g- I# ~' H# \5 g3 Q
  19.         }% u4 q; y" ^. s$ U
  20.        else . a. ]" m% S& N' e2 g& a
  21.        {
    & h: r- T, [- _, y
  22.         if (childpart->IsFullyLoaded())' n( V: L" h( R+ b5 i
  23.          {
    7 {( H- w0 L+ l" K" V$ e
  24.           lw->WriteLine(space+components[i]->DisplayName()+"\t"+"Status: IsFullyLoaded!");
    - \% G+ l0 r5 K: s! K: C5 x
  25.          }" W& k4 `/ R9 W+ I2 ]) a
  26.         else  . h3 A8 i1 c+ P& F* V* o
  27.          {
    " S1 q6 H( F* p6 M& n( S
  28.           lw->WriteLine(space+components[i]->DisplayName()+"\t"+"Status: IsPartiallyLoaded!");. M& f0 a* \- M* c- W2 Y0 V
  29.          }" `6 v# F. R8 o- n& ]0 @- @
  30.         ' J, Q: O2 @  l3 p- C
  31.       ; k! M# J" a4 E
  32.         getchildren(components[i],indent+5);! Z% G4 f& i6 S6 I& ^
  33.       }& U8 m0 R* O3 {7 }: P
  34.       }
    / v8 R* I8 M3 V* p8 J% T
  35. }</p><p>static void do_api()
    . f% k6 o, H4 n' I
  36. {9 H, s0 ^% i( W3 Z" ]
  37. //list the components
    . w) m; [4 N: |
  38.   Session *theSession = Session::GetSession();
    6 I) H' g5 i' N  t* W4 g- ]
  39.   ListingWindow *lw = theSession->ListingWindow();4 R# N3 k1 h' J+ U& i! u" r- U
  40.   lw->Open();/ I9 p' C) j6 [5 H7 a
  41.   Assemblies::Component * rootcomponent;6 Q6 J4 h0 M( J3 y* U
  42.   Part *workpart;- {5 j2 M% `+ s$ U' j9 Z
  43. rootcomponent = theSession->Parts()->Display()->ComponentAssembly()->RootComponent();
      Q! V# g$ ^6 K9 h0 ^
  44. workpart = theSession->Parts()->Work();
    ) U- y: ]& F3 c$ d4 b4 g
  45. lw->WriteLine("The workpart is : "+workpart->FullPath()+ "\n" );9 |! W) z" u2 l' f  w" B5 B5 |
  46. if(rootcomponent==NULL)
    $ R' [' ^0 n* P
  47. {  + k9 I" R2 z; _
  48.     lw->WriteLine("The part is not an assembly ! \n " );
    * L& R+ x& V, q# \& Z  }
  49. }5 C1 N) A' O0 g1 k
  50. else% f! a5 }% A8 O" v
  51. {
    - I0 y8 o  N  k0 |7 E; f
  52.   lw->WriteLine("The rootcomponent is : " +  rootcomponent->DisplayName()+"\n");
    1 B7 P1 K" Q5 s0 ^5 T" W8 s& l
  53.   lw->WriteLine("The children components are : \n");2 w) H7 h0 k% G4 ~# s5 i
  54.      getchildren(rootcomponent,4);
    " c% R! n( x/ }$ N
  55. }</p><p>}
    2 c7 [  B' _9 V" {: v
  56. </p><p> </p>
复制代码
) Q  j- I$ I" u4 W4 l
该会员没有填写今日想说内容.
回复

使用道具 举报

全部回复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二次开发专题模块培训报名开始啦

    我知道了