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

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

[复制链接]

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

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

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

x

" k( j) R  R. \, q- p% MNX二次开发源码: 使用NX OpenC++查询装配组件并判断加载状态0 j8 p' }/ B5 M

/ o9 h1 C/ B3 Y" n1 j+ l2 I4 g

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

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

5 d& F& h5 f& e" P% f( B
  1. <p>static void geTChildren(Assemblies::Component *rootcomponent,unsigned int indent): r5 u6 i- _% ?3 Z# \
  2. {       ! a# w7 C  d. P+ W3 B4 d3 _
  3.   
    6 X+ q1 O8 o) p; S  C5 Q& u
  4.   unsigned int ii;) H0 S; p: ^: q/ ?" q
  5.   char space[MAX_LINE_SIZE+1] = { " " };
    ) p9 j, _. A8 D4 [5 v
  6.    for (ii = 0; ii < indent; ii++) strcat(space, " ");
    + X+ s4 z+ t. k$ W" A4 S
  7.   std::vector<Assemblies::Component *>components;
    ' f! ~! \) W) Z5 U0 b, F( \) ^
  8.   Session *theSession = Session::GetSession();
    5 r! Q' v: Z2 o5 p+ \" i# ^
  9.   ListingWindow *lw = theSession->ListingWindow();
    % Y2 I1 a( M8 _& o. C, e& h
  10.      lw->Open();
    3 X6 E" G8 D1 t: I
  11.   components = rootcomponent->GetChildren();  S0 |* g2 c- |
  12.       for (int i = 0 ; i <components.size();i++)
    - P! I' f" y) @/ D
  13.       {
    8 F' @4 _( ~' L! i" U+ O
  14.        Part *childpart = dynamic_cast<Part*>(components[i]->Prototype());
    4 x/ X# Y& t, e" G
  15.      
    $ ^3 W! u/ b/ L) t# {* ^* ]
  16.       if(childpart==NULL)
    * m6 T: d, n2 y
  17.        {& Y& x% O6 B/ G# D
  18.         lw->WriteLine(space+components[i]->DisplayName()+"\t"+"Status: not loaded!");# n) [* c' ~5 h6 X
  19.         }
    # K+ _6 N3 \; C8 l4 r& T" E
  20.        else
    & b1 u+ l# w# p2 Q/ G- O0 }7 L
  21.        {% G: |; I& G6 T0 `
  22.         if (childpart->IsFullyLoaded())* r4 O9 Q/ n, U
  23.          {
    % l" D/ y* Z3 L( o
  24.           lw->WriteLine(space+components[i]->DisplayName()+"\t"+"Status: IsFullyLoaded!");. s4 t. L! j, x# E* V5 \' D4 G
  25.          }: k) y7 P# Q: N2 z9 `
  26.         else  
    5 p6 T" X4 V1 K2 V8 Z
  27.          {/ ~: [6 p6 i/ `4 X) V% B8 v, c
  28.           lw->WriteLine(space+components[i]->DisplayName()+"\t"+"Status: IsPartiallyLoaded!");$ M8 x4 }* t* H# j  Q/ K
  29.          }/ ]" L) V1 J' B3 c5 Q
  30.         5 q4 Z; F) s" x* Z1 ?5 g
  31.       
    ; P  N* f9 j9 [% q  r. S
  32.         getchildren(components[i],indent+5);4 q9 w2 [8 f& r: I' z) A
  33.       }
    " y# ?3 i; T3 d5 u) \9 y& H
  34.       }
    ' m4 |: F8 @4 ~. V
  35. }</p><p>static void do_api()6 U" }) o' `7 c0 D! J
  36. {5 Q; M$ Z7 S% E- ~
  37. //list the components( C/ E; z/ s- h( {. U, P3 N
  38.   Session *theSession = Session::GetSession();, n' d6 u5 [" h: w% M$ X
  39.   ListingWindow *lw = theSession->ListingWindow();# h0 N" d# R0 H2 L
  40.   lw->Open();
    ' b- w% Y# ^& N" Z% t4 a
  41.   Assemblies::Component * rootcomponent;
    - l$ f- D$ ~; L$ S/ U
  42.   Part *workpart;
    * X3 ]9 K* d0 ?) M& ~
  43. rootcomponent = theSession->Parts()->Display()->ComponentAssembly()->RootComponent();0 K" y& L2 h/ n+ `6 P: c
  44. workpart = theSession->Parts()->Work();
    ) u! O$ a6 w$ w5 [' m+ V: Y* d4 X$ E
  45. lw->WriteLine("The workpart is : "+workpart->FullPath()+ "\n" );' A2 \0 A- w% r' J- Z
  46. if(rootcomponent==NULL)* O% p$ l( n# l, [
  47. {  3 K+ Z! ~2 w) c* p. l. u& ~
  48.     lw->WriteLine("The part is not an assembly ! \n " );; R: S( Z8 r6 z# N# q; g7 V
  49. }
    4 a/ ~7 g. q5 F0 ?! P3 u" Y
  50. else
    $ A" G8 I  ~+ P8 z. x' L0 y
  51. {
    , Q' t- s2 ^$ a
  52.   lw->WriteLine("The rootcomponent is : " +  rootcomponent->DisplayName()+"\n");
    , M, @! ?, {: d; l8 \% j; z: x
  53.   lw->WriteLine("The children components are : \n");& s$ W) Y- N$ f8 c0 _8 y
  54.      getchildren(rootcomponent,4);
    ' @' D. T) C. d  X2 U
  55. }</p><p>}
    2 M# {2 L9 |' V
  56. </p><p> </p>
复制代码

$ f8 I# F  A' I! u
该会员没有填写今日想说内容.
回复

使用道具 举报

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

    我知道了