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

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

[复制链接]

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

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

mildcat 楼主

2013-12-4 16:36:55

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

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

x

& b6 i0 S: G& n# O" u( aNX二次开发源码: 使用NX OpenC++查询装配组件并判断加载状态
6 c5 M/ R' Y" N2 B# Z& I( D# H$ W
. c  e& \! q% y  s

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

NX二次开发源码: 使用NX OpenC++查询装配组件并判断加载状态
) S4 B6 Z4 }0 e
  1. <p>static void geTChildren(Assemblies::Component *rootcomponent,unsigned int indent)( W- ]! s$ _/ q0 d
  2. {      
    0 T/ v  L! N! S" X* b+ ]
  3.   
    ; B$ \. O0 q6 r" W
  4.   unsigned int ii;
    / v* e* G$ `, X" t
  5.   char space[MAX_LINE_SIZE+1] = { " " };
    % y  U0 _; a. o4 n! P6 e5 a
  6.    for (ii = 0; ii < indent; ii++) strcat(space, " ");/ D8 p" h# o; r. `
  7.   std::vector<Assemblies::Component *>components;' |+ b+ i* _2 B  ^) w8 D
  8.   Session *theSession = Session::GetSession();8 G$ t; z! p; d
  9.   ListingWindow *lw = theSession->ListingWindow();6 G7 [" J, b* ]* P) y1 [
  10.      lw->Open();: A; m3 Y2 o0 c8 k2 w* d
  11.   components = rootcomponent->GetChildren();1 W% A  j% I5 Y9 K
  12.       for (int i = 0 ; i <components.size();i++)4 `$ l& J4 a+ ^
  13.       {
    $ b- G5 n5 A$ S" j7 T' q9 `
  14.        Part *childpart = dynamic_cast<Part*>(components[i]->Prototype());
    8 k! }) q1 N) F) J1 D8 N* M# Q. H
  15.      
    / j3 g; T7 N" n6 o7 A
  16.       if(childpart==NULL): M; w6 ~6 e0 _; K" m( |
  17.        {4 W& \) G4 F5 {: O
  18.         lw->WriteLine(space+components[i]->DisplayName()+"\t"+"Status: not loaded!");" a0 l1 l. s: P: Z/ O: p5 r, j* I
  19.         }/ Y7 K7 w9 r) f/ N$ O
  20.        else 4 \" C: ]1 ~% L" ~! E) H3 b& U
  21.        {
    - e. X7 V% i( f. r- ?5 w2 o, m
  22.         if (childpart->IsFullyLoaded())
    , m2 t7 _" J2 Z& a0 p
  23.          {( a9 b8 a5 W: G# X
  24.           lw->WriteLine(space+components[i]->DisplayName()+"\t"+"Status: IsFullyLoaded!");5 G: U5 y( ^( }: ?2 _3 K
  25.          }* [, h/ T! T5 p, Z: ]5 P9 j
  26.         else  
    ; V! ~; j. Z$ e6 i0 n
  27.          {
    9 q3 |" U& @/ k
  28.           lw->WriteLine(space+components[i]->DisplayName()+"\t"+"Status: IsPartiallyLoaded!");; ?: N( A1 y1 S9 w1 R
  29.          }
    ) `8 O8 c5 o5 h' [8 s. Q; x9 h
  30.         % X- o5 z1 f! k& F9 j7 v
  31.       
    1 H8 ~/ W. f1 p
  32.         getchildren(components[i],indent+5);# `# d- f9 t  q# N/ P( p
  33.       }
    8 [- I; f$ K% B9 z
  34.       }4 E1 g0 @6 w& A+ A& q0 \! V" ?
  35. }</p><p>static void do_api()4 c+ P2 P6 @6 L9 _3 }+ B* p$ M5 ~
  36. {0 J, G7 m( ^1 x6 k; G/ c( Z
  37. //list the components4 V0 Y1 N" @+ W7 m( Y) h8 s
  38.   Session *theSession = Session::GetSession();
    ! W& j) M) G) l6 z1 }
  39.   ListingWindow *lw = theSession->ListingWindow();4 ]. h8 x" A4 K' f
  40.   lw->Open();
    , B) a" t( U' x2 x9 [9 S
  41.   Assemblies::Component * rootcomponent;
    + j" _! q! ], j
  42.   Part *workpart;: e+ N: g* m7 Q7 E( X
  43. rootcomponent = theSession->Parts()->Display()->ComponentAssembly()->RootComponent();. R) G* ?3 k/ C& I5 f. s
  44. workpart = theSession->Parts()->Work();8 ?, B: a% @, L% V) I
  45. lw->WriteLine("The workpart is : "+workpart->FullPath()+ "\n" );( v8 Z& k7 r  D9 h6 H- R4 j! ]6 v
  46. if(rootcomponent==NULL)
      ~5 X+ H8 r$ s" W6 f
  47. {  
    % ]" y; J/ g% m0 J* ^6 R" @+ K4 H
  48.     lw->WriteLine("The part is not an assembly ! \n " );  `' o3 b1 h! w* I* D% y; ]
  49. }
    . \7 }* X. x. G  {2 H
  50. else
    ) p: z' T* m9 ]& T
  51. {7 a% s$ U, Z2 ^. y8 |* i8 f
  52.   lw->WriteLine("The rootcomponent is : " +  rootcomponent->DisplayName()+"\n");
    ( Z% \7 ~$ ?3 S- j- j# w
  53.   lw->WriteLine("The children components are : \n");- `1 [- d  r- T) N
  54.      getchildren(rootcomponent,4);' C1 P8 X! s. s# W7 A
  55. }</p><p>}+ Z. @: G& e3 K; \; E- o( b1 u, z
  56. </p><p> </p>
复制代码
# x9 |0 `" K+ u0 e  i1 a
该会员没有填写今日想说内容.
回复

使用道具 举报

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

    我知道了