PLM之家PLMHome-国产软件践行者

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

[复制链接]

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

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

mildcat 楼主

2013-12-4 16:36:55

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

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

x

" g3 l& H7 m2 o3 X: _NX二次开发源码: 使用NX OpenC++查询装配组件并判断加载状态
# m1 [" L  d3 V' q/ s+ c5 e" H9 Q
8 z0 J$ u. d6 {

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

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

8 g# p6 I8 p0 M3 ^/ |
  1. <p>static void geTChildren(Assemblies::Component *rootcomponent,unsigned int indent)! C# f8 [( O' Q2 e* _' R& u' y2 @
  2. {      
    ' ^4 o) g. ]! {- P; ^
  3.   ; D' {2 d* s5 |' _& Y6 I- E9 _
  4.   unsigned int ii;
    7 @0 d- d5 D* |% C$ M- U
  5.   char space[MAX_LINE_SIZE+1] = { " " };% }2 g( z" y2 t! O2 E- k# l
  6.    for (ii = 0; ii < indent; ii++) strcat(space, " ");5 Q8 i% o& z: P% |0 K- ?: n
  7.   std::vector<Assemblies::Component *>components;
    / [9 I% O% u* t. C
  8.   Session *theSession = Session::GetSession();# T9 w$ x; z# y" X0 g0 o+ M' O- s
  9.   ListingWindow *lw = theSession->ListingWindow();
    % M; z8 I6 u# S& h$ L( R
  10.      lw->Open();
    ' ]2 b4 v; {5 ?& v, t" b& _- E1 y1 Z1 E$ l
  11.   components = rootcomponent->GetChildren();+ p, f6 ]% m: _3 n- J9 G: j! O
  12.       for (int i = 0 ; i <components.size();i++)5 I/ P$ x+ d: U9 z. z+ m; Z: \
  13.       {. g6 @! ?# ]5 \# n. Q
  14.        Part *childpart = dynamic_cast<Part*>(components[i]->Prototype());
    6 @& A! ^: ]1 r% e! ^
  15.      8 ?  R/ v. f& u2 M
  16.       if(childpart==NULL)
    ' I* S: S# ]9 ^) L1 Z
  17.        {& U2 }- x0 L5 {* e; R9 i0 Y0 K/ W& M
  18.         lw->WriteLine(space+components[i]->DisplayName()+"\t"+"Status: not loaded!");5 V' R# Z' _& Q* S
  19.         }
    . ?  g& ~; S8 B1 ^5 `3 ?
  20.        else 7 _- T; E( P6 P
  21.        {
    5 S% e+ p$ ~6 n9 c
  22.         if (childpart->IsFullyLoaded())* O  O6 O/ ~; h+ Y- X( G
  23.          {& L% `) Q! T. w* u, o
  24.           lw->WriteLine(space+components[i]->DisplayName()+"\t"+"Status: IsFullyLoaded!");1 H0 d9 t& b; k, A9 z; {1 J0 h2 x
  25.          }- J" T( A( ]' c4 q/ v# R
  26.         else  . N" z2 @. h0 Z/ J, w+ X6 Y3 @  s0 m
  27.          {
    ) h  _; v- M5 e! F% z! R( _
  28.           lw->WriteLine(space+components[i]->DisplayName()+"\t"+"Status: IsPartiallyLoaded!");
    6 z* W* l1 Z4 s- o8 z. X
  29.          }
    4 e, m' |/ h% Q7 I8 \1 ~
  30.         $ n, W3 b% o  U; D# u3 J) A
  31.       
      w: Z! c, B: ^# h" J
  32.         getchildren(components[i],indent+5);1 k: Q! {+ V. v4 E* d: R, u
  33.       }0 B8 ^0 _  V* ^, Y+ T% T, R
  34.       }. g9 a+ @# i5 y4 S" ?- a
  35. }</p><p>static void do_api()3 G& J4 g, ]7 U% v2 v! @
  36. {
    ) g0 `! D- ~- ?+ ~6 q2 F
  37. //list the components
    8 D" N+ `, d* e7 z2 D; P
  38.   Session *theSession = Session::GetSession();  H" y& \7 p) \
  39.   ListingWindow *lw = theSession->ListingWindow();, h* Z* c$ s3 z+ f- b
  40.   lw->Open();5 R, u! O5 m6 |- l
  41.   Assemblies::Component * rootcomponent;" E  Z7 G" n5 Q1 V" O, t
  42.   Part *workpart;
    " H0 ^% k! s' m5 ^- `! }* V2 d
  43. rootcomponent = theSession->Parts()->Display()->ComponentAssembly()->RootComponent();
      ~# p" H6 H( r7 i; `, S4 `6 B
  44. workpart = theSession->Parts()->Work();
    9 G0 E% \3 J) q" o0 r) C- U
  45. lw->WriteLine("The workpart is : "+workpart->FullPath()+ "\n" );2 {/ `) t) Z4 |! o) o
  46. if(rootcomponent==NULL)
    / S; Y; ~7 Z3 f
  47. {  ; K9 g1 M4 ~6 Z$ {3 n, x
  48.     lw->WriteLine("The part is not an assembly ! \n " );
    5 A$ l; A/ F  {* b# j
  49. }% Y4 W) e8 S) S
  50. else
    , A9 ?7 i1 O# B6 b2 q' V
  51. {
    # u7 U6 \$ e/ H- H
  52.   lw->WriteLine("The rootcomponent is : " +  rootcomponent->DisplayName()+"\n");
    6 @2 Z5 H& ?6 t  s+ W0 r
  53.   lw->WriteLine("The children components are : \n");
    # v% R0 X9 ^+ Y* C
  54.      getchildren(rootcomponent,4);5 x" e0 R0 ~$ h( t/ ?# k
  55. }</p><p>}
    ' a1 s6 g3 m3 [1 y3 Q2 }
  56. </p><p> </p>
复制代码
& g; U- l4 L. f! H
该会员没有填写今日想说内容.
回复

使用道具 举报

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

    我知道了