PLM之家PLMHome-工业软件与AI结合践行者

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

[复制链接]

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

mildcat 发表于 2013-12-4 16:36:55 |阅读模式

mildcat 楼主

2013-12-4 16:36:55

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

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

x
9 j6 k& ]; i% d+ R) ^; z5 d5 E
NX二次开发源码: 使用NX OpenC++查询装配组件并判断加载状态) x' ~* j1 l  }9 r4 V- x2 l6 v8 G

6 n1 A! h$ d1 c) V

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

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

& \" N5 B$ f0 E9 r( w& Q
  1. <p>static void geTChildren(Assemblies::Component *rootcomponent,unsigned int indent)
      |. x3 i" F" ?8 C  v% l
  2. {       : P* c0 w* w& M' `, g2 I
  3.   0 L, J( i  A' F8 i" y, L/ t+ \
  4.   unsigned int ii;
    + S5 {% V8 R4 l6 x# q# w5 D
  5.   char space[MAX_LINE_SIZE+1] = { " " };0 i" w0 Q; e. O3 i5 F; @4 I
  6.    for (ii = 0; ii < indent; ii++) strcat(space, " ");9 f: z) p' U. H. w& k. ~
  7.   std::vector<Assemblies::Component *>components;
    , f0 c- V: K) e# ~
  8.   Session *theSession = Session::GetSession();
      V& M3 k- J/ N. S$ a9 L
  9.   ListingWindow *lw = theSession->ListingWindow();
    ( T. S) \& ?1 a. K
  10.      lw->Open();: |: Q, H8 h0 w+ z8 i  d0 C
  11.   components = rootcomponent->GetChildren();
      p+ c) z& {8 D
  12.       for (int i = 0 ; i <components.size();i++)
    ! L. p- D4 R4 |, }
  13.       {
    2 S* R8 J, c" y0 K  w% k9 g
  14.        Part *childpart = dynamic_cast<Part*>(components[i]->Prototype());- R# `/ G5 t8 e, Z6 M2 h+ n
  15.      
    - c& L4 k$ B* x/ e3 P( @6 S3 j
  16.       if(childpart==NULL)
    ; c' _# N0 o) r
  17.        {; i: d/ x' U) D6 j
  18.         lw->WriteLine(space+components[i]->DisplayName()+"\t"+"Status: not loaded!");
    2 v' t4 t% }* x% j3 q6 E+ s/ W9 e* z& @
  19.         }% L( P" S; n9 m
  20.        else
    ' [" C2 ?( }2 j' V+ r% s( T0 c
  21.        {2 `* f& ^. [  i/ s- A: s1 I
  22.         if (childpart->IsFullyLoaded())
      Q& G: @. Y; ^. @
  23.          {; r- b/ v7 X) B/ ]4 w# J+ ^+ K4 k- P
  24.           lw->WriteLine(space+components[i]->DisplayName()+"\t"+"Status: IsFullyLoaded!");
    ' T+ E$ `% f9 H& T
  25.          }9 l  C2 b5 l+ [* s4 [
  26.         else  : V  _; a2 e5 c: j# g$ o( D
  27.          {
    & x, R! e$ C0 n
  28.           lw->WriteLine(space+components[i]->DisplayName()+"\t"+"Status: IsPartiallyLoaded!");
    7 j3 X7 K/ u3 m6 i8 `* Y4 i7 |
  29.          }
    ( Y2 D8 e( @0 V# r  W  o& g( w! w! T
  30.         6 y$ |9 C4 Y. t, i) b2 u: C
  31.       
    6 {5 q! |" |$ j$ ~  d  b& q
  32.         getchildren(components[i],indent+5);3 t: Q% _" f/ D7 P0 R
  33.       }& t( V9 a8 ?1 n  U* c/ A
  34.       }# {9 O, \0 u/ T1 I% \4 X/ `  S
  35. }</p><p>static void do_api()! e# `& x; U& R# }1 i: r" z
  36. {
    0 A" C  f3 G/ n( a8 c
  37. //list the components) ?% b+ z% z& x' ^9 @
  38.   Session *theSession = Session::GetSession();
    - c9 W4 X) A1 n" P
  39.   ListingWindow *lw = theSession->ListingWindow();5 Q% G  l( {2 u9 j9 L- x3 _
  40.   lw->Open();
    * E- c: w* i/ I$ I, l- F0 M4 H! k
  41.   Assemblies::Component * rootcomponent;
    # E. z) f2 n1 {8 I" o) N8 ~1 |
  42.   Part *workpart;; ?. G9 a% e1 e/ X; e6 U
  43. rootcomponent = theSession->Parts()->Display()->ComponentAssembly()->RootComponent();
    5 t7 U8 S6 j0 m1 R+ P" |
  44. workpart = theSession->Parts()->Work();3 s2 H# G7 ?/ d8 b/ H% L$ w# A
  45. lw->WriteLine("The workpart is : "+workpart->FullPath()+ "\n" );
    / v. B7 m  e$ k7 R6 D
  46. if(rootcomponent==NULL)
    4 Q5 d' C/ i9 G6 f
  47. {  ) _: P8 C4 {/ |. V
  48.     lw->WriteLine("The part is not an assembly ! \n " );
    ; a: n  m7 l6 ]3 X  @
  49. }
    2 B. x! |) W, }) g, ?& Z
  50. else5 W: Z* _" G! |9 X# m$ ^
  51. {
    - e1 u' c0 z1 r. E& t4 v* L
  52.   lw->WriteLine("The rootcomponent is : " +  rootcomponent->DisplayName()+"\n");
      t0 X) L- X. }5 H
  53.   lw->WriteLine("The children components are : \n");1 A% z5 u: O/ K2 M( V0 x
  54.      getchildren(rootcomponent,4);; N, G, q) U3 }( y4 ]) j! p# Q
  55. }</p><p>}
    & o" v& ^- X. U2 R! y9 O0 g
  56. </p><p> </p>
复制代码
+ B- `% l) \* z% A1 \* u7 R
该会员没有填写今日想说内容.
回复

使用道具 举报

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

    我知道了