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

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

[复制链接]

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

320

主题

226

回帖

9784

积分

管理员

PLM之家NX|TC专家

积分
9784
发表于 2013-12-4 16:36:55 | 显示全部楼层 |阅读模式

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

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

x
  _) s. E, s; d" }" f3 ~
NX二次开发源码: 使用NX OpenC++查询装配组件并判断加载状态
' u  v& Q! O" ], D4 Z0 B3 d; r7 q2 J0 D3 W" i3 [3 K( F

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

NX二次开发源码: 使用NX OpenC++查询装配组件并判断加载状态
- G% G! ~" w" O
  1. <p>static void geTChildren(Assemblies::Component *rootcomponent,unsigned int indent)6 D& U* R$ s4 q* p, I6 w
  2. {       . g  Z1 _0 R( v, [. y4 c
  3.   
    " k6 T: @: G' L* v$ x' h/ ]+ S
  4.   unsigned int ii;( C0 D& p1 a" F
  5.   char space[MAX_LINE_SIZE+1] = { " " };
    2 E" Q* x9 A5 S1 b( G5 O- g
  6.    for (ii = 0; ii < indent; ii++) strcat(space, " ");! Q7 N$ I, {& Y9 O, n% U- o) h
  7.   std::vector<Assemblies::Component *>components;$ ?' I# I# ~5 e9 H$ t# f
  8.   Session *theSession = Session::GetSession();
    3 w" J1 Z5 }( b" e4 I' P
  9.   ListingWindow *lw = theSession->ListingWindow();
    ! \+ P4 y# T: w: N
  10.      lw->Open();/ j. V$ n* C# P2 t& f; f7 H5 l- V
  11.   components = rootcomponent->GetChildren();
    ) U4 Z! f- V' S4 e4 Y# E
  12.       for (int i = 0 ; i <components.size();i++)
    - U3 L3 E* j3 [% T' g3 ~
  13.       {! |/ c0 o% ~# J' I3 W" e+ d% }2 b
  14.        Part *childpart = dynamic_cast<Part*>(components[i]->Prototype());
    % n0 T" ~3 i$ `  i
  15.      0 F5 J/ x$ M5 M+ X
  16.       if(childpart==NULL)  B% t2 Q1 Z: \
  17.        {' q+ K& R5 V+ e
  18.         lw->WriteLine(space+components[i]->DisplayName()+"\t"+"Status: not loaded!");
    ) m2 z4 b6 Y) _7 y. G, D" }+ R
  19.         }1 Q+ P( E& O3 }" |
  20.        else 1 _2 ~9 M, `; ~  A8 l
  21.        {
    * A+ W. E- c5 f7 S  \
  22.         if (childpart->IsFullyLoaded())
    , N2 _( Y7 c/ f+ ?% D
  23.          {2 J! h' @/ Y7 j$ Z& \/ f
  24.           lw->WriteLine(space+components[i]->DisplayName()+"\t"+"Status: IsFullyLoaded!");
    . ~# f4 i( `8 \* B5 O
  25.          }
    9 \3 K- M& J/ C4 `" E8 ?
  26.         else    W* M9 l$ N/ i# n. `
  27.          {
    % c& H5 v% ~( \/ b
  28.           lw->WriteLine(space+components[i]->DisplayName()+"\t"+"Status: IsPartiallyLoaded!");& }& V& \$ B: L9 C: |6 G. f5 L
  29.          }
    5 f0 I& v7 A# o4 x; _2 g5 \# Z3 u/ {
  30.           i! Z: v. O7 z6 i5 q% Q5 E
  31.       * T8 D( x9 H, c/ Q/ Z# m/ }. t
  32.         getchildren(components[i],indent+5);
    5 v" Y$ Z1 o7 K) ]
  33.       }$ s- C& r% ~' @+ G; e0 q; a
  34.       }- D* }4 |/ O% T- j1 p
  35. }</p><p>static void do_api()
    / a! h0 y# Z/ G" |5 S/ c
  36. {! v/ Y+ @8 B: H8 a. K, X
  37. //list the components
    ( D. @5 ^! A$ _/ K# t$ [
  38.   Session *theSession = Session::GetSession();
    ' p5 k( o. A3 [
  39.   ListingWindow *lw = theSession->ListingWindow();
    . _: p3 _/ o  K' A, F7 g
  40.   lw->Open();
      v: B1 W( h. }: g
  41.   Assemblies::Component * rootcomponent;
    4 o( U$ b, j7 ?; j
  42.   Part *workpart;
    7 H+ q; ?( M: o, p
  43. rootcomponent = theSession->Parts()->Display()->ComponentAssembly()->RootComponent();; i0 T# u  Q3 G8 h+ \& o% [. M
  44. workpart = theSession->Parts()->Work();+ h2 ?+ |( M1 u! C) m
  45. lw->WriteLine("The workpart is : "+workpart->FullPath()+ "\n" );1 Q; q4 q# h9 r! m5 v$ V1 S
  46. if(rootcomponent==NULL)5 B4 z* S2 ^& U+ a7 ]
  47. {  
    7 L, C4 {! n/ u0 ]! e# {- S
  48.     lw->WriteLine("The part is not an assembly ! \n " );: Y2 R! m' K6 E- a' c6 N
  49. }
    1 {; s* g- v6 T2 e4 B7 V
  50. else1 k9 x9 b; N4 U$ h' W; B' I6 x+ p+ p
  51. {4 F2 |: i2 c" T8 b( a$ H( }( \
  52.   lw->WriteLine("The rootcomponent is : " +  rootcomponent->DisplayName()+"\n");. u6 X) h7 a: W& S1 s4 h
  53.   lw->WriteLine("The children components are : \n");
    . R& I, `9 W) r+ r3 d
  54.      getchildren(rootcomponent,4);7 p% m, c, g* p( o# D/ H6 `
  55. }</p><p>}5 S' v( |- `  ]: g* M! d5 {. |3 X
  56. </p><p> </p>
复制代码

. c8 Y. a* |3 \- D( t; W3 v# ?7 r  E
该会员没有填写今日想说内容.
回复

使用道具 举报

全部回复1

7

主题

31

回帖

170

积分

注册会员

积分
170
发表于 2013-12-8 00:59:17 | 显示全部楼层
嗯,这个不错
上海点团信息科技有限公司,承接UG NX,CATIA,CREO,Solidworks 等CAx软件,Teamcenter,3D Experience等PLM软件,工业4.0数字化软件的实施\二次开发\培训相关业务,详情QQ 939801026 Tel 18301858168 网址 www.doteam.tech
回复 支持 反对

使用道具 举报

发表回复

您需要登录后才可以回帖 登录 | 注册

返回列表 本版积分规则

  • 发布新帖

  • 在线客服

  • 微信

  • 客户端

  • 返回顶部

  • x
    温馨提示

    本网站(plmhome.com)为PLM之家工业软件学习官网站

    展示的视频材料全部免费,需要高清和特殊技术支持请联系 QQ: 939801026

    PLM之家NX CAM二次开发专题模块培训报名开始啦

    我知道了