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

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

[复制链接]

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

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

mildcat 楼主

2013-12-4 16:36:55

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

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

x
8 @( _6 f9 f1 F
NX二次开发源码: 使用NX OpenC++查询装配组件并判断加载状态, |  ^* \% L9 h( L$ \

) H7 V. g5 e' f# o: L' F

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

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

9 k8 p9 w' E  k% S( N9 ~
  1. <p>static void geTChildren(Assemblies::Component *rootcomponent,unsigned int indent)1 M' X! q0 q1 v4 f- U) c; \
  2. {       ' B$ C+ s+ S( U/ S' \& P+ ~
  3.   4 ?0 C' @* n1 e' |/ T8 _- t
  4.   unsigned int ii;3 d  \- c. h8 c: Q( }  @
  5.   char space[MAX_LINE_SIZE+1] = { " " };2 a2 }* Y3 M. P! [- K# f& A- D% j
  6.    for (ii = 0; ii < indent; ii++) strcat(space, " ");) N8 m8 ]+ N' i3 q- c* `4 F
  7.   std::vector<Assemblies::Component *>components;! r) v5 v" v) `5 H% `/ x5 x
  8.   Session *theSession = Session::GetSession();
    1 t6 K3 G' A5 g% v% y1 k7 Y8 \
  9.   ListingWindow *lw = theSession->ListingWindow();
    % m- M0 J, Y$ ], k! p" Q
  10.      lw->Open();
    0 d* o/ l9 m( W; G3 W! E
  11.   components = rootcomponent->GetChildren();
    ! M# N$ x$ ^, ^' z9 x+ F4 K
  12.       for (int i = 0 ; i <components.size();i++)+ s0 e- X' r* M7 ]! A+ x4 e
  13.       {
      F6 t4 h: A* K; O8 m
  14.        Part *childpart = dynamic_cast<Part*>(components[i]->Prototype());! ^# M( G# t) l6 W) @
  15.      
    . E7 R7 J' V& g3 R  n: A: q
  16.       if(childpart==NULL)/ j$ B) r. b/ T( k$ \' {) ~, b* g
  17.        {4 E5 x) _+ u0 Y$ t
  18.         lw->WriteLine(space+components[i]->DisplayName()+"\t"+"Status: not loaded!");
    0 L6 V, t1 e- D6 Y: O  v
  19.         }$ A* g- {- i' O( z; ^' m
  20.        else
    $ q" t" t& M7 c$ m. d! Z( G# J: ?/ h7 v
  21.        {
    . ~+ C4 W/ B3 t# p
  22.         if (childpart->IsFullyLoaded())+ W- V  v6 c  Q. z
  23.          {8 B* G- j0 E9 D
  24.           lw->WriteLine(space+components[i]->DisplayName()+"\t"+"Status: IsFullyLoaded!");3 G. N6 d6 |1 }+ H2 u
  25.          }
    , U) Q: p+ Y* C' l- l
  26.         else  
    6 e6 a+ _. n5 ?$ i2 N0 `3 k+ i
  27.          {
    ( U0 Z' H4 o$ D! ~6 {  G4 i
  28.           lw->WriteLine(space+components[i]->DisplayName()+"\t"+"Status: IsPartiallyLoaded!");
    ! q5 w1 s$ @3 z* z& G2 l
  29.          }+ J' o. I! A" ?9 Y
  30.         9 a1 C# S+ F! T  R) Q/ H6 [. R
  31.       ' T( ]5 ^% X, i- `3 @. Q5 t
  32.         getchildren(components[i],indent+5);! j$ n3 b% y! U7 `9 s! E; f5 ?( ?
  33.       }4 x6 L( X/ g9 e, u' }
  34.       }
    8 k: R+ C; H. i  C1 T3 G- l
  35. }</p><p>static void do_api()
    # R2 J) ]3 c8 E% z
  36. {) r! Q: b3 s) ^+ N  v# {
  37. //list the components# W/ |; L5 T0 W% Q' [/ C
  38.   Session *theSession = Session::GetSession();5 ~; d% r0 G! G, B6 N' a# n( ~/ T
  39.   ListingWindow *lw = theSession->ListingWindow();( H) E3 U! |- ]4 X3 Q) m
  40.   lw->Open();
    + h0 Q: B$ y+ _, U
  41.   Assemblies::Component * rootcomponent;  N$ E4 ]% A3 Y  f! A/ k
  42.   Part *workpart;4 w, G  M" d+ y
  43. rootcomponent = theSession->Parts()->Display()->ComponentAssembly()->RootComponent();- `# l  p3 f/ Y, J9 J5 T
  44. workpart = theSession->Parts()->Work();
    8 j$ E* _/ w% ~. q# R
  45. lw->WriteLine("The workpart is : "+workpart->FullPath()+ "\n" );2 L# Y: \! D2 P4 A
  46. if(rootcomponent==NULL)$ r/ a) z1 k( J0 B, o' O. _0 O7 j
  47. {  
    ! [+ l* L% _$ m' I
  48.     lw->WriteLine("The part is not an assembly ! \n " );
    # |' i  b$ `- d/ R9 T( x4 K
  49. }" W2 ^& L4 a! \6 u
  50. else3 t( P  r) A  K1 y
  51. {. l6 B1 c7 H) w
  52.   lw->WriteLine("The rootcomponent is : " +  rootcomponent->DisplayName()+"\n");3 c' c/ y0 M' H" h
  53.   lw->WriteLine("The children components are : \n");$ N' b8 M' N3 O
  54.      getchildren(rootcomponent,4);
    + K" g2 U  A& \, v  J
  55. }</p><p>}
    2 d6 @8 z7 q+ G9 a) r
  56. </p><p> </p>
复制代码

1 I+ ?; C+ w- n3 d- ~; S, S
该会员没有填写今日想说内容.
回复

使用道具 举报

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

    我知道了