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

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

[复制链接]

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

mildcat 发表于 2013-12-4 16:36:55 |阅读模式

mildcat 楼主

2013-12-4 16:36:55

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

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

x

  M# |, r/ ^+ f; W3 CNX二次开发源码: 使用NX OpenC++查询装配组件并判断加载状态
1 r6 ^8 y" C2 Q2 x+ M4 V* H: @
1 _6 E+ M3 x. U  t! R

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

NX二次开发源码: 使用NX OpenC++查询装配组件并判断加载状态
# C" Z2 D, ]& v& ?" m' J
  1. <p>static void geTChildren(Assemblies::Component *rootcomponent,unsigned int indent)
    9 x4 F; z2 [8 ?6 b8 X
  2. {      
    2 u- [* S% L- k4 a! n7 |0 ^
  3.   + `" ^5 q% Y9 L1 u# t$ g
  4.   unsigned int ii;. g3 e1 n% M9 J1 v  _
  5.   char space[MAX_LINE_SIZE+1] = { " " };  e% y! b5 s! }% N2 y6 [  _9 I& Q
  6.    for (ii = 0; ii < indent; ii++) strcat(space, " ");  \; r# {0 A8 W# @1 ?  J5 e. L
  7.   std::vector<Assemblies::Component *>components;
    8 G/ T1 e2 v, H$ N) e
  8.   Session *theSession = Session::GetSession();$ a- F# S4 e8 ~$ S7 A5 f& l3 @
  9.   ListingWindow *lw = theSession->ListingWindow();
    ) M: A& z& o6 R! F% ?
  10.      lw->Open();
    & M1 m8 Q) ]# j9 s9 P
  11.   components = rootcomponent->GetChildren();
    4 x0 ?: q2 U9 ~- v
  12.       for (int i = 0 ; i <components.size();i++)! J$ @4 [; y# P. V/ s. P$ i) N
  13.       {% ~6 U- J. ]1 u) A: u7 i" n
  14.        Part *childpart = dynamic_cast<Part*>(components[i]->Prototype());/ J, u* R4 f5 j
  15.      3 Y( W0 |. ~# C: j1 D1 q- U1 M$ ?
  16.       if(childpart==NULL)
    4 z, i: O+ }- e- e( _. I& O
  17.        {
    4 T7 y" k( O  [
  18.         lw->WriteLine(space+components[i]->DisplayName()+"\t"+"Status: not loaded!");
    1 @3 I: a  ^( g( V* M
  19.         }9 E! U# ~8 y$ @( j/ ~
  20.        else
    3 y: T% I6 A( L9 A% k, y
  21.        {
    / `/ A% q9 [6 L; @$ I
  22.         if (childpart->IsFullyLoaded())
    ( T& e9 @; B; `5 z5 Y+ Y
  23.          {, m$ u0 b; t7 x+ p) d, ~
  24.           lw->WriteLine(space+components[i]->DisplayName()+"\t"+"Status: IsFullyLoaded!");
    " K3 u/ N7 T! r
  25.          }) V  w6 a, J. [5 T
  26.         else  
    / ^: |+ e5 @! M* `, s: C$ L
  27.          {
    / T1 r/ |( U) a$ F) k* Q
  28.           lw->WriteLine(space+components[i]->DisplayName()+"\t"+"Status: IsPartiallyLoaded!");; b* V8 a4 S; p
  29.          }
    0 B& ~6 }+ u: e) g) a
  30.         # c; {, ]5 w4 d' b: Z& u7 j
  31.       
    2 s2 \) c  g$ {
  32.         getchildren(components[i],indent+5);
    1 W9 x" @) n' j! t
  33.       }2 }, }$ z& [/ A& ]) V
  34.       }, b: E; Y1 `& z, B
  35. }</p><p>static void do_api()
    $ O$ H1 _  e+ Y
  36. {9 h' d& U. O8 B8 _2 R& W, u6 Z
  37. //list the components
    6 c4 p) K- a  }. y2 _: ]% N7 Z- L
  38.   Session *theSession = Session::GetSession();2 X7 N1 M2 s3 f
  39.   ListingWindow *lw = theSession->ListingWindow();
    - m0 U6 \6 |2 r- c5 [2 B7 R9 \# ~
  40.   lw->Open();5 _( P0 F3 h+ P6 I
  41.   Assemblies::Component * rootcomponent;6 C8 \$ v# V7 i4 Z/ m4 e
  42.   Part *workpart;
    ( a) ~+ F/ F5 q* J4 v
  43. rootcomponent = theSession->Parts()->Display()->ComponentAssembly()->RootComponent();
    ! _$ i. l# o2 p: v9 t
  44. workpart = theSession->Parts()->Work();
    3 S. d( t0 d* |* R* _
  45. lw->WriteLine("The workpart is : "+workpart->FullPath()+ "\n" );' O6 x. O. m3 T
  46. if(rootcomponent==NULL)
    / k  f" [5 L* V" U
  47. {  6 x; V8 h3 G# ]0 E( n& Q3 i, u( x
  48.     lw->WriteLine("The part is not an assembly ! \n " );
    ! v0 D% o5 ]' S$ f7 c1 @7 P
  49. }6 p! o& J1 m: b1 f) @
  50. else
    $ P* X" P8 j4 B* H. G6 O
  51. {; H7 V, C5 r3 S0 r0 b/ g
  52.   lw->WriteLine("The rootcomponent is : " +  rootcomponent->DisplayName()+"\n");3 p! z8 W+ M+ j0 n
  53.   lw->WriteLine("The children components are : \n");; T# q9 E  i- J  b
  54.      getchildren(rootcomponent,4);; t) D- a) ~- ^$ B  `, |
  55. }</p><p>}( t: |8 g1 ^2 v, ~6 n$ }
  56. </p><p> </p>
复制代码
' i1 `. U2 W) f5 g
该会员没有填写今日想说内容.
回复

使用道具 举报

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

    我知道了