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

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

[复制链接]

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

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

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

x

: k: V2 p9 N( B* ~5 J/ |NX二次开发源码: 使用NX OpenC++查询装配组件并判断加载状态
- N* ^  ^3 m) P+ @" V" `' |# ]' O6 ^- k$ n2 W' O. s0 p' d

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

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

' Q8 `4 X2 D$ ]9 {7 N
  1. <p>static void geTChildren(Assemblies::Component *rootcomponent,unsigned int indent)
    # e+ r) V" J8 r8 \! D8 F% U7 V0 A
  2. {       4 A4 q" ?3 v8 n; a/ A4 ^
  3.   % ^1 ^% l: w( v$ A! R! ^4 d
  4.   unsigned int ii;- H- C6 L8 S( R; u
  5.   char space[MAX_LINE_SIZE+1] = { " " };+ X1 S+ v  W1 Y  u
  6.    for (ii = 0; ii < indent; ii++) strcat(space, " ");
    1 F9 T, F' t9 Z/ I1 H; W: h
  7.   std::vector<Assemblies::Component *>components;( }6 d& t% ]( Q# A
  8.   Session *theSession = Session::GetSession();; c# q7 k3 R- h! _' g
  9.   ListingWindow *lw = theSession->ListingWindow();" k# k$ ^' G  \
  10.      lw->Open();
    & ]* G2 u7 a3 U5 \: [
  11.   components = rootcomponent->GetChildren();) p% q% h9 {* z! l: g
  12.       for (int i = 0 ; i <components.size();i++)) E8 y1 W. t$ Z
  13.       {
    - e" u, J9 X& {" u
  14.        Part *childpart = dynamic_cast<Part*>(components[i]->Prototype());8 w7 V$ [" V- `
  15.      ) i9 @! G7 V. o* n1 n6 Z
  16.       if(childpart==NULL)7 h7 [) U3 U; P1 W" O+ a4 c4 L
  17.        {* d' E: e7 L0 R* ^3 d
  18.         lw->WriteLine(space+components[i]->DisplayName()+"\t"+"Status: not loaded!");
    . a9 @. b0 V1 n) P" B* W
  19.         }
    * A; E6 ~; e. c4 b2 O( L! h8 V
  20.        else
    6 X0 p! y4 N1 o
  21.        {
    + F5 ^. \2 R3 M' f
  22.         if (childpart->IsFullyLoaded())  d5 `9 B) k" x1 I: W9 z! c
  23.          {# v; c5 d3 w8 S: B% ~
  24.           lw->WriteLine(space+components[i]->DisplayName()+"\t"+"Status: IsFullyLoaded!");( i  j( c$ |+ L- S. g7 N6 K
  25.          }( D4 W/ j1 ^( C/ ^
  26.         else  : Q; M) v  j" t) R/ r, i
  27.          {! L1 ?* ?' V$ R7 H/ ~4 \$ B, y7 P
  28.           lw->WriteLine(space+components[i]->DisplayName()+"\t"+"Status: IsPartiallyLoaded!");
    6 c/ J( Y8 C, d! V" ?; P
  29.          }
    1 k( j8 O5 h" h4 J3 [! u) D, C) h" |' E
  30.         6 \1 M  @+ a( a* Q' C
  31.       & \) [, x; |+ `
  32.         getchildren(components[i],indent+5);; R! H+ z. Y& G7 a
  33.       }
    ; j8 s+ O% Z0 S- `: J2 N+ ~
  34.       }
    ' F, T9 v# z: j. p1 B
  35. }</p><p>static void do_api()& o3 g; j& b' \; w8 N* c2 s
  36. {8 y( h# I: l* X
  37. //list the components1 [1 `7 P/ T; \! j% [$ Z* r
  38.   Session *theSession = Session::GetSession();: Y! P: u% r" W5 g) j
  39.   ListingWindow *lw = theSession->ListingWindow();
    ' c! m) m% b" A6 q
  40.   lw->Open();
    % [8 l# S% m- t- a
  41.   Assemblies::Component * rootcomponent;
    - s0 M8 J4 t3 D* M& f
  42.   Part *workpart;+ O" V% k. w" |% ~
  43. rootcomponent = theSession->Parts()->Display()->ComponentAssembly()->RootComponent();: V9 ^4 C2 G( M+ y: t, A
  44. workpart = theSession->Parts()->Work();
    0 P+ D& L4 N- U0 F
  45. lw->WriteLine("The workpart is : "+workpart->FullPath()+ "\n" );
    5 n9 }+ t( e% s* u
  46. if(rootcomponent==NULL)
    1 ^* H: i, c' r2 e! C3 D) f7 f
  47. {  : [+ L+ `  a9 w5 U3 j2 s
  48.     lw->WriteLine("The part is not an assembly ! \n " );' w, q0 d# S1 q0 e
  49. }& A; h0 }0 q. s* Y
  50. else
    ) h5 t! c# ^5 t1 r* L
  51. {
    ; `# K+ E" C. w& E5 }& J
  52.   lw->WriteLine("The rootcomponent is : " +  rootcomponent->DisplayName()+"\n");
    - c/ w* G: M' e1 P
  53.   lw->WriteLine("The children components are : \n");
    . b$ ]; D5 V; ^0 ~* D. s) r8 K5 F
  54.      getchildren(rootcomponent,4);' C3 Y7 [, V3 Q/ b/ ]& V$ G, x
  55. }</p><p>}3 q( I5 z0 A1 |% W( ]
  56. </p><p> </p>
复制代码

6 T+ n8 v6 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二次开发专题模块培训报名开始啦

    我知道了