PLM之家PLMHome-工业软件与AI结合践行者

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

[复制链接]

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

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

mildcat 楼主

2013-12-4 16:36:55

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

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

x

2 _9 `1 b! ~2 T! h0 ~; i& FNX二次开发源码: 使用NX OpenC++查询装配组件并判断加载状态
7 N/ [/ b; Z7 {+ ~# V% ^# V% d9 u$ }

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

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

# f; V3 U6 K1 @* n# N$ L0 D' w0 j1 G
  1. <p>static void geTChildren(Assemblies::Component *rootcomponent,unsigned int indent)0 P% @3 W# ?5 y8 y) J3 _2 t) @3 K# m
  2. {       / C' O5 J1 \4 I6 Z1 ?# n. W
  3.   ! F, M% `6 u7 _; e& {
  4.   unsigned int ii;
    : ^7 `$ e8 V) p5 ^) o, \8 Y9 p
  5.   char space[MAX_LINE_SIZE+1] = { " " };
    % w+ |  h! z$ N, @- R  i1 M
  6.    for (ii = 0; ii < indent; ii++) strcat(space, " ");
    8 ], r9 D$ N* C1 ^2 h* ^6 h
  7.   std::vector<Assemblies::Component *>components;
    # e7 h! g( @( O! Z. ~
  8.   Session *theSession = Session::GetSession();
    ) w0 C* f7 F5 z5 z6 f' e
  9.   ListingWindow *lw = theSession->ListingWindow();
    ) b$ u4 c4 Y' D& V9 P
  10.      lw->Open();
    % o, N7 Q  d- [( S
  11.   components = rootcomponent->GetChildren();% d7 Y2 |( m( o! `. g* g6 d
  12.       for (int i = 0 ; i <components.size();i++)
    + B4 w- B3 ~# D) F; }* }3 @1 e4 }
  13.       {
    + b, h6 S7 ?/ u( G
  14.        Part *childpart = dynamic_cast<Part*>(components[i]->Prototype());
    8 Y' _7 T- r! A' b- K* z
  15.      
    1 n4 U3 w- a* W8 E/ _6 Q0 A( S
  16.       if(childpart==NULL)
    # _2 a, G1 j# T9 S: w+ M5 c
  17.        {8 F0 n6 O3 X9 b6 V! e3 j: R
  18.         lw->WriteLine(space+components[i]->DisplayName()+"\t"+"Status: not loaded!");
    2 B  U* {- R* p9 v; p0 d
  19.         }' [: a+ N. I) I) v! R( T' e' J0 ~+ S7 X+ W
  20.        else
    4 R1 @0 O: |. }/ ?2 u& n" `# D5 @
  21.        {: a* n" s* A" z9 I
  22.         if (childpart->IsFullyLoaded())
    ) Y. I; x2 s( Y$ l/ e. ?
  23.          {7 H; z% W7 x0 {" O6 c
  24.           lw->WriteLine(space+components[i]->DisplayName()+"\t"+"Status: IsFullyLoaded!");' b  j4 w: W! W6 P0 X' x$ ?1 b) J: {
  25.          }
    3 Z, t5 Y: E' K& |: c- F  Y
  26.         else  + d" r, x6 Q$ }
  27.          {
    : R6 M3 ^6 u2 J. b* ], o3 z& ?' o4 W
  28.           lw->WriteLine(space+components[i]->DisplayName()+"\t"+"Status: IsPartiallyLoaded!");; i  C. G: ^! R& t' F
  29.          }
      }, T+ T$ U5 `# B- A( l' Y8 M
  30.         + n' @$ {. }0 Q5 e
  31.       
    / X7 M9 h) U2 c( R' {9 c) n6 f
  32.         getchildren(components[i],indent+5);
      _9 H9 f! W0 K0 O5 p1 u
  33.       }- j8 ~1 `+ }' f4 m: p5 M2 J
  34.       }6 H" U5 w- k; t/ h5 ~; Y6 _
  35. }</p><p>static void do_api()- q* [& w. Z, K/ M
  36. {
    + j$ I! V! h  v  n
  37. //list the components
    + W% e& T  G' w7 v) G
  38.   Session *theSession = Session::GetSession();  w1 y$ Y+ X" Q+ G- g
  39.   ListingWindow *lw = theSession->ListingWindow();
    : L: N  |  u- G  h& M
  40.   lw->Open();
    0 h, H" {. z- [6 |+ s
  41.   Assemblies::Component * rootcomponent;) T3 b8 H: @/ g1 m7 S- j0 {
  42.   Part *workpart;8 X* F5 t1 a& n# V: m( Q5 v: w. w
  43. rootcomponent = theSession->Parts()->Display()->ComponentAssembly()->RootComponent();- Q0 C& ]" w- I) [) h
  44. workpart = theSession->Parts()->Work();" U6 }$ K: A/ K
  45. lw->WriteLine("The workpart is : "+workpart->FullPath()+ "\n" );
    . _% ~  B" H4 d3 K- R
  46. if(rootcomponent==NULL)
    5 W1 O  S) ~. S6 K1 D
  47. {  
    ; L, l6 r4 g. {7 p; m, u
  48.     lw->WriteLine("The part is not an assembly ! \n " );* s- v8 `; \& \, b  _* Q
  49. }6 e/ o4 G0 A2 n0 b: |
  50. else
    6 n" ?3 B1 k3 G/ {
  51. {8 y4 d$ n/ [! H- b( I) O( q
  52.   lw->WriteLine("The rootcomponent is : " +  rootcomponent->DisplayName()+"\n");
    & v5 n& K- V7 `2 \* `: q! Z
  53.   lw->WriteLine("The children components are : \n");
    * s6 }  }; Y' q& e9 N) o4 h
  54.      getchildren(rootcomponent,4);2 z2 S5 m: o" l5 J. [/ L4 ~
  55. }</p><p>}
    : V! W1 M# O: R5 ^6 s
  56. </p><p> </p>
复制代码

8 t, X/ }7 t6 h1 h9 t$ d, m: X6 S5 r% c8 I
该会员没有填写今日想说内容.
回复

使用道具 举报

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

    我知道了