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

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

[复制链接]

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

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

mildcat 楼主

2013-12-4 16:36:55

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

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

x
- Z9 M9 G& u2 {- w8 {
NX二次开发源码: 使用NX OpenC++查询装配组件并判断加载状态
. l( m. c6 f. O4 x% ]0 V& ^4 f3 s! }4 c$ l/ N9 g3 A: \

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

NX二次开发源码: 使用NX OpenC++查询装配组件并判断加载状态
" p6 y9 |4 O( k2 @* w% M
  1. <p>static void geTChildren(Assemblies::Component *rootcomponent,unsigned int indent); V. t; W5 S* {# `
  2. {       / z% W. ~9 c( \, Y6 S2 _! \
  3.   
    ' J' q+ j- f+ q' c* X; c3 ~4 r
  4.   unsigned int ii;% B2 y" K. i- |1 C0 \
  5.   char space[MAX_LINE_SIZE+1] = { " " };& h9 @% d/ C, r8 M0 ?* I7 i
  6.    for (ii = 0; ii < indent; ii++) strcat(space, " ");
    4 t/ u7 N! O, |' o
  7.   std::vector<Assemblies::Component *>components;) U' a. _7 H6 M0 I% h9 f' z3 G) W9 Q
  8.   Session *theSession = Session::GetSession();/ ]/ {) S8 r* i& R. K
  9.   ListingWindow *lw = theSession->ListingWindow();
    1 S: e5 H: k4 u' j0 D( Q2 ?4 m# v* I
  10.      lw->Open();
    6 v: C2 D0 }" n# E" w, j/ U
  11.   components = rootcomponent->GetChildren();5 @% Z7 z) A, n; L7 P6 ]
  12.       for (int i = 0 ; i <components.size();i++)4 z. a) B- c0 x& J' m; J
  13.       {" {, D2 E' u8 V: F& z% e
  14.        Part *childpart = dynamic_cast<Part*>(components[i]->Prototype());7 ], V( g1 @0 A- O$ \  D* T
  15.      
    ' S# D. T2 y& z2 o
  16.       if(childpart==NULL)
    ; o. A; h9 g- d6 Y% f( D" T, p
  17.        {7 @3 O6 X6 J2 c
  18.         lw->WriteLine(space+components[i]->DisplayName()+"\t"+"Status: not loaded!");
      t; x' m3 h+ M8 M! s
  19.         }% r/ N: _0 L5 ]+ @5 O
  20.        else : W2 d$ ^# @8 N* ?4 s
  21.        {
    : x6 V; r6 r: k3 q
  22.         if (childpart->IsFullyLoaded())
    & z" S% Q# r1 ]( R
  23.          {
    2 u" P9 x' E. k9 D$ W8 X
  24.           lw->WriteLine(space+components[i]->DisplayName()+"\t"+"Status: IsFullyLoaded!");
    # @- {( @0 N- z. s' a2 ~, ]
  25.          }
    6 y9 ]5 Y, ?' e; Q# U8 \# c
  26.         else  & z  r  n: N7 b$ c5 K. ]
  27.          {
    $ x9 _4 E4 O4 G
  28.           lw->WriteLine(space+components[i]->DisplayName()+"\t"+"Status: IsPartiallyLoaded!");
    , E8 z6 p! u# ~% y6 I- U3 O
  29.          }/ M3 d1 Z! K( x# J% P+ N% ~; s
  30.         ! g4 s$ Z' h& j; E  L
  31.       6 L. c, K; v6 m$ ~% b
  32.         getchildren(components[i],indent+5);7 b' J5 C, r8 k) a- u. f( m
  33.       }
    % u* B! @0 m/ ^4 |, d& h9 g
  34.       }
    # e' \  p% x8 t- e: g
  35. }</p><p>static void do_api()" A4 V/ V( H, N, ^. V* b
  36. {
    ' w6 c  w. I0 B
  37. //list the components
    / v0 |% A/ D* n& g% g1 i9 L
  38.   Session *theSession = Session::GetSession();6 k! S( k* `5 X/ G: @# e
  39.   ListingWindow *lw = theSession->ListingWindow();
    / y3 x- v6 z9 ]6 q! A1 r
  40.   lw->Open();7 c1 m$ F, j; ^. x( w
  41.   Assemblies::Component * rootcomponent;3 \5 K% R$ `/ @3 ?$ `! j) |! S
  42.   Part *workpart;
    1 C7 M) ?* b7 }7 C. P' N3 Z
  43. rootcomponent = theSession->Parts()->Display()->ComponentAssembly()->RootComponent();/ a1 `4 T4 o$ {6 e/ H1 ~
  44. workpart = theSession->Parts()->Work();
    0 p6 r+ R9 I  @: h4 o: ^; U0 U, A
  45. lw->WriteLine("The workpart is : "+workpart->FullPath()+ "\n" );% W* g3 p9 c; q6 u% C6 @
  46. if(rootcomponent==NULL)3 p' L; n* b- ?& i. v. K0 _
  47. {  / P  s; g1 N- M4 M' s
  48.     lw->WriteLine("The part is not an assembly ! \n " );
    3 \2 K8 w7 p* A
  49. }
    3 b" b3 s' b9 I1 I+ N
  50. else
    " A3 j) Q7 T8 T
  51. {
    ; ]1 b" N$ _) u8 P$ r% {: |  c
  52.   lw->WriteLine("The rootcomponent is : " +  rootcomponent->DisplayName()+"\n");' G! {! I2 ?, f/ ]8 w3 ?( v8 V
  53.   lw->WriteLine("The children components are : \n");3 l6 e4 o$ N! `; Y. E2 e& E
  54.      getchildren(rootcomponent,4);- D( ]: ~" a/ q7 ?
  55. }</p><p>}8 k6 Q4 Y# r5 ]$ v( v; q3 S
  56. </p><p> </p>
复制代码

9 R; I9 F) g& ~7 M; x! o2 B
该会员没有填写今日想说内容.
回复

使用道具 举报

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

    我知道了