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

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

[复制链接]

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

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

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

x
" U  F- ?; g( D) ~9 l# [2 [
NX二次开发源码: 使用NX OpenC++查询装配组件并判断加载状态
0 g7 [2 \, n1 l+ I
. h! f* f# Y- _8 L) `  y) S2 q

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

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

/ |1 K3 a, [' t, Z, B
  1. <p>static void geTChildren(Assemblies::Component *rootcomponent,unsigned int indent)3 Q" G  v0 `: \
  2. {       & [1 T) o2 J1 p1 B1 @) |/ g0 X$ b% X5 }
  3.   7 G+ l' E8 q* r# e+ Q5 i
  4.   unsigned int ii;3 M( n- h, d9 a, U  O' b, l: l
  5.   char space[MAX_LINE_SIZE+1] = { " " };/ w1 E1 j- v1 i
  6.    for (ii = 0; ii < indent; ii++) strcat(space, " ");( h) t4 b9 c% t" S4 |# b3 g
  7.   std::vector<Assemblies::Component *>components;
    0 ~. D" b6 ]% l- t; T* b5 N, }
  8.   Session *theSession = Session::GetSession();
    7 W: w9 \3 ^- {8 [! _; Q
  9.   ListingWindow *lw = theSession->ListingWindow();5 d! r* v! j! }% y
  10.      lw->Open();, P3 p) O0 \$ F  ]
  11.   components = rootcomponent->GetChildren();! D' A+ n' U0 e! s5 F8 K( H
  12.       for (int i = 0 ; i <components.size();i++)8 |7 p  H" k. B6 _6 Q
  13.       {
    1 _" ^- C5 C2 z( d4 \& M5 ]
  14.        Part *childpart = dynamic_cast<Part*>(components[i]->Prototype());
    ; f4 w% N0 j; \* ]
  15.      : I7 S% @  R3 d, c4 |: R
  16.       if(childpart==NULL)
    % h- ^! }4 F7 C$ _/ I
  17.        {) O! S3 j& A# g4 S" g5 H/ S" G6 [
  18.         lw->WriteLine(space+components[i]->DisplayName()+"\t"+"Status: not loaded!");6 I: X; X. P5 @- F: A, }
  19.         }6 P/ e1 o3 m. H' h) H% g4 M  [
  20.        else
    2 Q' x. ?" C+ Z. u& E2 g! Z
  21.        {
    & Y$ b8 k, z6 f" `9 l
  22.         if (childpart->IsFullyLoaded())
    5 ]0 j9 f  V$ R
  23.          {
    8 \1 i( D4 _( W1 P0 A; M
  24.           lw->WriteLine(space+components[i]->DisplayName()+"\t"+"Status: IsFullyLoaded!");8 h; D% ^7 c- X; M/ T
  25.          }
    * s( B, c" [" w/ C, F* z
  26.         else  
    0 k  e5 j* x* O0 J2 U* }
  27.          {
    1 P7 m1 i+ V! x/ O% r! O- D
  28.           lw->WriteLine(space+components[i]->DisplayName()+"\t"+"Status: IsPartiallyLoaded!");
    5 O. b/ j$ o' Z# I8 R/ A) G8 |& @
  29.          }5 y& \' w8 j% @: @( u' y
  30.         
    # F$ D2 q6 h3 _  v( D
  31.       
    4 b1 F8 l/ h& G1 K6 t5 @
  32.         getchildren(components[i],indent+5);
    3 Q# v& F# E8 c4 F* Z
  33.       }
    ) U' F' H$ J: }' L
  34.       }
    ) f( s+ Z1 l& `  K
  35. }</p><p>static void do_api()7 A, ^9 s9 {, x2 J9 ]  L
  36. {0 s+ k( P; b' J5 {
  37. //list the components; l, M& Z. @- u- {
  38.   Session *theSession = Session::GetSession();1 }9 Q) P8 I6 P" I2 G% C
  39.   ListingWindow *lw = theSession->ListingWindow();/ k! E  y; D+ p' I: n1 h, }& d
  40.   lw->Open();2 R  e, {& ]5 e( o/ V0 b' r; v
  41.   Assemblies::Component * rootcomponent;  Z- ^! f' z9 a+ k+ [
  42.   Part *workpart;+ L6 B5 z, ?  O3 Q' m  A3 L
  43. rootcomponent = theSession->Parts()->Display()->ComponentAssembly()->RootComponent();
    ' J9 c' q  O4 d5 E7 x8 N
  44. workpart = theSession->Parts()->Work();7 i- s! A. }3 l( E& X+ C0 u
  45. lw->WriteLine("The workpart is : "+workpart->FullPath()+ "\n" );
    & h& Z: P9 a, ^
  46. if(rootcomponent==NULL)% z- x0 ], h2 T" i+ B- W
  47. {  
      g8 p" M! e% x/ d
  48.     lw->WriteLine("The part is not an assembly ! \n " );
    ; r9 ^* E8 O- b# }1 G) I7 I
  49. }; N  w1 t7 j! _2 o0 p% |" i$ n. A
  50. else
    , p; M& ^0 j  o" q
  51. {) ]" g8 a1 X1 l
  52.   lw->WriteLine("The rootcomponent is : " +  rootcomponent->DisplayName()+"\n");. t7 z; E$ O0 x3 v6 T
  53.   lw->WriteLine("The children components are : \n");
    3 z# O  M% R/ q2 g! [& Y
  54.      getchildren(rootcomponent,4);
    9 w( z* P# f, Y( q5 R0 ~, a
  55. }</p><p>}
    ' \4 l* x& ^; M5 d. f$ `
  56. </p><p> </p>
复制代码

6 F. w' c) N' Z
该会员没有填写今日想说内容.
回复

使用道具 举报

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

    我知道了