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

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

[复制链接]

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

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

mildcat 楼主

2013-12-4 16:36:55

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

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

x
9 l! t, D; ^  X4 o, Q* {9 I
NX二次开发源码: 使用NX OpenC++查询装配组件并判断加载状态
# R9 y/ _6 }$ L% D7 D% p: A/ \5 f2 i4 A/ i; n( _! |* g7 m) ^

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

NX二次开发源码: 使用NX OpenC++查询装配组件并判断加载状态
9 p! K: M& m6 K) ~
  1. <p>static void geTChildren(Assemblies::Component *rootcomponent,unsigned int indent)
    ( I6 b) N0 x5 @  c$ o9 s) _- a: X
  2. {      
    4 G6 a! T& ?5 E- `) \, B" v
  3.   3 F* A  n% s: h; s( U7 A; s
  4.   unsigned int ii;9 Y- r) J! X) Q* [# E
  5.   char space[MAX_LINE_SIZE+1] = { " " };
    ) U3 t" X6 p5 Z+ ?/ j* I7 Q
  6.    for (ii = 0; ii < indent; ii++) strcat(space, " ");4 d5 L4 M- o# o1 V7 P
  7.   std::vector<Assemblies::Component *>components;1 O( ?- q7 s1 I% O
  8.   Session *theSession = Session::GetSession();
    / j; ^0 w' [8 G, n- c
  9.   ListingWindow *lw = theSession->ListingWindow();
    - W& ^% o8 `( X; \  X
  10.      lw->Open();( w% J) N/ R0 O& m8 A" z9 O; n
  11.   components = rootcomponent->GetChildren();: K: f3 W+ |7 ]. d* K. J
  12.       for (int i = 0 ; i <components.size();i++)
    3 ]( y: i  Z* l- Y" b
  13.       {
    8 m2 g  ^8 A! |
  14.        Part *childpart = dynamic_cast<Part*>(components[i]->Prototype());3 [; n9 J: @; \) S; }& ~1 f
  15.      6 o- x& _4 w1 @
  16.       if(childpart==NULL)
    ! q# q2 S& P  L
  17.        {
    $ \3 A* f" k- W- }( |4 ^
  18.         lw->WriteLine(space+components[i]->DisplayName()+"\t"+"Status: not loaded!");
    1 \% S/ Z, E1 C4 ^7 U4 L0 d
  19.         }! x5 c  Q4 w, l& d; O  H9 P! A: n
  20.        else ) }+ ^/ C$ u3 G: B. h
  21.        {" k* Z  D! O# T! g1 o4 q) N. Z8 I
  22.         if (childpart->IsFullyLoaded())
    1 c9 W( e. _# h" g( W
  23.          {
    + A% V- F$ ^7 B, V% \4 Q0 D' c
  24.           lw->WriteLine(space+components[i]->DisplayName()+"\t"+"Status: IsFullyLoaded!");
    $ w) V1 [( Y! q( F
  25.          }
    * u! ^" E( d0 [# A) t# S
  26.         else    X; L+ N7 X3 ?& N+ h7 s
  27.          {
    - x: s# M1 y+ T( A) W; m, T+ a( g6 V, y
  28.           lw->WriteLine(space+components[i]->DisplayName()+"\t"+"Status: IsPartiallyLoaded!");
    - d, K, x# U$ {) n: q
  29.          }
    / q: C% i0 n5 K' {, g
  30.         & l+ D8 U2 n1 }. R; F
  31.       
    & f+ h" m2 i1 v( ^. Y+ f9 ~0 L6 O9 e5 M
  32.         getchildren(components[i],indent+5);! g( u$ Y6 b( Z* L" ?3 C
  33.       }
    5 o  O0 k" F5 M( C
  34.       }1 F7 @6 `- h2 h7 q: i2 k+ f
  35. }</p><p>static void do_api()/ m; A: C. ]/ g$ a  g8 Q  d, h1 \
  36. {
    ! t2 I: i2 ^5 d) r1 j2 F  h
  37. //list the components
    ) x+ h+ d8 e, Y+ X4 G* h1 ?. E
  38.   Session *theSession = Session::GetSession();
    3 a+ ?* m6 {& A
  39.   ListingWindow *lw = theSession->ListingWindow();
    & F- I* z) [1 S) [
  40.   lw->Open();7 _" q, u/ J4 X# c' `: w
  41.   Assemblies::Component * rootcomponent;" m: A) g: _5 J/ h0 t8 d7 |
  42.   Part *workpart;) x: \! i: g8 C
  43. rootcomponent = theSession->Parts()->Display()->ComponentAssembly()->RootComponent();; F1 F2 L8 j3 e. d
  44. workpart = theSession->Parts()->Work();
    6 n' S" \0 N( K" I; i
  45. lw->WriteLine("The workpart is : "+workpart->FullPath()+ "\n" );/ Z  w. j" |$ p, K6 O. l, f
  46. if(rootcomponent==NULL)
    ' C) I7 {: K5 E* i2 f; ^8 M5 n
  47. {  : E7 f2 A' G" f+ K/ i& d
  48.     lw->WriteLine("The part is not an assembly ! \n " );8 U7 _8 {- S- b: d" W0 B. F9 ^
  49. }
    . c. w# T: [0 U# V
  50. else+ J2 H2 b; l2 e, v, e
  51. {
    : ^" \+ [5 H0 P) m* x5 \1 q% E
  52.   lw->WriteLine("The rootcomponent is : " +  rootcomponent->DisplayName()+"\n");5 @# Q9 v0 D( L7 ?$ t3 ^4 s
  53.   lw->WriteLine("The children components are : \n");+ F. H2 |) M* u! @. L
  54.      getchildren(rootcomponent,4);
    3 ?0 k! g! h* k6 ]6 ?% A
  55. }</p><p>}
    $ F( f: f0 O( W8 ~/ U) N+ f) o2 g
  56. </p><p> </p>
复制代码
7 f+ @& |8 Q4 j  s6 w! u/ X
该会员没有填写今日想说内容.
回复

使用道具 举报

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

    我知道了