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

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

[复制链接]

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

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

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

x

5 D- i0 l  o* ?8 \2 iNX二次开发源码: 使用NX OpenC++查询装配组件并判断加载状态
3 `9 v2 h6 E9 b1 W6 }/ z: \
4 P. e3 E( I6 T  k1 W

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

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

" T) i; d! x, y* q1 m
  1. <p>static void geTChildren(Assemblies::Component *rootcomponent,unsigned int indent)
    ( f( t1 A2 ~: c" E; b: \5 a3 ^0 N5 _
  2. {      
    ) c! [9 ]- k/ T8 @/ P/ Y8 Q
  3.   
    & j( [( O$ u) {6 w
  4.   unsigned int ii;# C: B$ Q5 O$ ~; K* M  j2 w$ E! Z
  5.   char space[MAX_LINE_SIZE+1] = { " " };! a; x* W* K8 G" I
  6.    for (ii = 0; ii < indent; ii++) strcat(space, " ");6 \# N5 j1 H: c. l& m
  7.   std::vector<Assemblies::Component *>components;0 s% k: Q' A' `3 @$ V+ n
  8.   Session *theSession = Session::GetSession();4 ?2 d: ?# ^4 s+ L) t
  9.   ListingWindow *lw = theSession->ListingWindow();# q0 O3 X/ z& U: z2 t2 r! n, Z
  10.      lw->Open();5 w" ?0 E& W; z& ]7 d- |8 R7 Y
  11.   components = rootcomponent->GetChildren();
    1 C8 \+ O4 k0 b) k
  12.       for (int i = 0 ; i <components.size();i++)% m# i" W- S, g& I
  13.       {
    8 z; m/ k7 L! G. C
  14.        Part *childpart = dynamic_cast<Part*>(components[i]->Prototype());5 ?6 e/ ~  g( r. z9 z" V% j
  15.      
    ! y. ]- I( o& X; @+ |3 z; q2 I$ Z
  16.       if(childpart==NULL)- l$ C7 C, Q0 h5 r' J6 ^
  17.        {$ G: x% `, @( R$ x. e0 ?
  18.         lw->WriteLine(space+components[i]->DisplayName()+"\t"+"Status: not loaded!");( c( t! v# }  E' n7 V! A
  19.         }
    4 b2 P, R( d6 u& q& l
  20.        else ; d( g* e/ i* I- P- f; C. I7 m6 f
  21.        {7 J7 I/ \5 M' ?) X# N
  22.         if (childpart->IsFullyLoaded()); a9 }4 z, z& P/ T) o4 I, ]- O
  23.          {
    0 d- h0 O. f. r/ t
  24.           lw->WriteLine(space+components[i]->DisplayName()+"\t"+"Status: IsFullyLoaded!");- W" d( U3 S: e5 U
  25.          }
    $ _" U6 H7 O) t3 g
  26.         else  
    4 }5 {* m: }1 v4 r, i4 N9 x' G
  27.          {
    + z1 W9 q& C/ I/ R" D$ h+ b
  28.           lw->WriteLine(space+components[i]->DisplayName()+"\t"+"Status: IsPartiallyLoaded!");
    ' C; ]( w  X4 s8 ^
  29.          }
    * J/ r2 c% f6 j2 d& a8 n
  30.         . C; y' N2 S2 ~' y  d" R# [
  31.       
    1 d% {6 @2 P7 C2 |& h+ |( M% r
  32.         getchildren(components[i],indent+5);& y+ L9 X4 v/ T# z. m  S; J* g2 N
  33.       }* s1 O4 N5 W% ?5 u- `# o
  34.       }
    $ @; M) R% d) m: P7 E2 M, p
  35. }</p><p>static void do_api()$ Y' a/ d) A8 q1 W5 e3 h4 p
  36. {
    6 a* Y$ O. w  G2 P1 X, ~0 Y
  37. //list the components
    ; {* u, V1 }# |8 u- `
  38.   Session *theSession = Session::GetSession();$ [) V8 R; _$ o) W" h& i
  39.   ListingWindow *lw = theSession->ListingWindow();
    * t. I, h9 I1 Z" h4 |
  40.   lw->Open();5 n  i$ f1 K8 M; p! M
  41.   Assemblies::Component * rootcomponent;
    7 a+ ~* K6 R' I
  42.   Part *workpart;
    4 E& Q+ R/ R* f  u9 W  d4 a
  43. rootcomponent = theSession->Parts()->Display()->ComponentAssembly()->RootComponent();2 \) Y7 r3 r; I! Z7 O  Z$ l
  44. workpart = theSession->Parts()->Work();
    4 Z( L+ _/ P( i9 E: U& C+ V8 s
  45. lw->WriteLine("The workpart is : "+workpart->FullPath()+ "\n" );( A, z) A( t) P: J9 A% h
  46. if(rootcomponent==NULL)+ T- C3 c$ E/ C/ b( C- Z
  47. {  
    % A! p- F) X9 h+ Q- M
  48.     lw->WriteLine("The part is not an assembly ! \n " );
    9 b; K2 W2 D1 \5 Y% T- W5 l
  49. }5 }4 E' {; b6 e% i
  50. else; b) |6 Q, t7 J* e; g/ X, S
  51. {& T9 k: u- d. H( g0 l
  52.   lw->WriteLine("The rootcomponent is : " +  rootcomponent->DisplayName()+"\n");
    $ z3 B; I% ]6 s. n
  53.   lw->WriteLine("The children components are : \n");# M3 ~8 b7 {& \7 S  O" }7 {) r
  54.      getchildren(rootcomponent,4);
    ' r: j7 Q2 Y# J% y5 T9 E
  55. }</p><p>}9 ?; i7 n8 b# w1 L6 `1 I
  56. </p><p> </p>
复制代码

& u8 f9 Q# K6 p3 Z2 P
该会员没有填写今日想说内容.
回复

使用道具 举报

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

    我知道了