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

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

[复制链接]

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

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

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

x

8 v% A5 O6 k) ]* f: C' ?% WNX二次开发源码: 使用NX OpenC++查询装配组件并判断加载状态+ e. K! G0 u( N8 b
: [8 O8 d- R) O* ~: V

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

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

# s0 v- H5 e& C9 D0 A! _' z
  1. <p>static void geTChildren(Assemblies::Component *rootcomponent,unsigned int indent)
    ! n  v% H$ T% M; H/ A
  2. {         u  }; V- t) k( I
  3.   8 W) P2 o/ U: d" P
  4.   unsigned int ii;0 r0 @! D1 C' f
  5.   char space[MAX_LINE_SIZE+1] = { " " };9 t9 I; Y% v0 f
  6.    for (ii = 0; ii < indent; ii++) strcat(space, " ");0 K6 S$ K' v7 E5 ~8 x( L2 i. T6 R2 j! c
  7.   std::vector<Assemblies::Component *>components;( a2 I2 P! U( }+ f; z2 Q
  8.   Session *theSession = Session::GetSession();4 M) j, E/ |6 w2 Z- y8 L$ w' y
  9.   ListingWindow *lw = theSession->ListingWindow();
    # `6 t7 {: ^$ L+ f9 [& ]
  10.      lw->Open();. J" y. V1 k$ v# ~
  11.   components = rootcomponent->GetChildren();
    ! }9 l( K0 @- T+ z
  12.       for (int i = 0 ; i <components.size();i++)8 E; X7 g+ T: H; r) ]
  13.       {
    , T  j2 G2 [5 a. ^) O
  14.        Part *childpart = dynamic_cast<Part*>(components[i]->Prototype());
    9 {( Q% \" N) f
  15.      
    6 g. l5 E! p2 H4 i  y
  16.       if(childpart==NULL)
    5 }/ K; y' g, @( ?
  17.        {. r- T! }7 l8 S3 P- z# u( v, r
  18.         lw->WriteLine(space+components[i]->DisplayName()+"\t"+"Status: not loaded!");! D) f# N+ a* a5 F: V" L5 L8 r- D
  19.         }
    + Y! Q! }/ U0 |' M2 v8 X8 l; S8 T
  20.        else
    , k; `9 k1 N# U& t9 O/ a. U
  21.        {
    9 v7 u. U4 H% N. ^1 f* m3 ^
  22.         if (childpart->IsFullyLoaded())
    " V. j) \- o+ w
  23.          {
    0 h$ X. v  Y8 h5 [% i: u, V* x
  24.           lw->WriteLine(space+components[i]->DisplayName()+"\t"+"Status: IsFullyLoaded!");+ q+ u# a5 e; |) `$ z; w
  25.          }
    4 Y" ^* V( Q1 n) t
  26.         else  
    . @& M/ A* s/ j" u% R( F; W: D! P
  27.          {- {6 w4 B* i9 W
  28.           lw->WriteLine(space+components[i]->DisplayName()+"\t"+"Status: IsPartiallyLoaded!");
    ! c+ a( u# u  i/ ^' c" S6 z* t' [
  29.          }
    / g8 \$ i5 c/ [0 C
  30.         - g6 I9 v4 q3 z5 w5 X
  31.       
    * x! a! a! B+ w
  32.         getchildren(components[i],indent+5);
    ' w4 H9 \( k3 j; v; F3 j0 X" f
  33.       }
    7 k! m6 {7 S  L0 M' J% |
  34.       }
    0 g% [4 ~* U% u6 `
  35. }</p><p>static void do_api()
    6 Q2 D* h% u+ A
  36. {5 ^! F0 z1 i' {
  37. //list the components/ Y) d% i8 ?0 C) W% W8 f
  38.   Session *theSession = Session::GetSession();8 L7 H" [8 U( a1 |% _3 s+ m
  39.   ListingWindow *lw = theSession->ListingWindow();
    ' m6 m' k  L3 N7 d5 ]/ e6 Q
  40.   lw->Open();' W$ Z+ n- S* `* G* j; x5 h
  41.   Assemblies::Component * rootcomponent;
    3 \6 Y2 \2 e% x: C2 x. C
  42.   Part *workpart;5 Q5 x1 Z3 z; o' ^3 |0 ^3 ^
  43. rootcomponent = theSession->Parts()->Display()->ComponentAssembly()->RootComponent();* m' W5 ^8 P$ g6 r1 A# U9 b
  44. workpart = theSession->Parts()->Work();' y$ T; }7 V/ O) G7 f
  45. lw->WriteLine("The workpart is : "+workpart->FullPath()+ "\n" );/ ^# R$ I1 H0 r: E
  46. if(rootcomponent==NULL)
    . o# G- e' [  q
  47. {  8 b% U  @/ K' N: o3 q; q8 B
  48.     lw->WriteLine("The part is not an assembly ! \n " );$ A/ ^3 k8 _. H- @% v! s1 b
  49. }) d+ }! P; ^! H. g9 \: E! @
  50. else7 E& E9 \. b* n0 w
  51. {
    - f4 }. F" a2 a5 I9 x& V9 l
  52.   lw->WriteLine("The rootcomponent is : " +  rootcomponent->DisplayName()+"\n");9 l1 u, A) c; X' V4 W" `. s/ ~
  53.   lw->WriteLine("The children components are : \n");
    ! k$ Y- ^* f3 a9 |% z3 h& X
  54.      getchildren(rootcomponent,4);
    + H' v+ u+ l7 q( O, h' ], Q0 @
  55. }</p><p>}7 L- R# d3 G- x' T2 N3 n) P
  56. </p><p> </p>
复制代码
+ l# ^  e( Q0 j. v7 f4 q
该会员没有填写今日想说内容.
回复

使用道具 举报

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

    我知道了