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

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

[复制链接]

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

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

mildcat 楼主

2013-12-4 16:36:55

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

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

x
* p' R' l/ a, x# e( P0 E" h% b. Y
NX二次开发源码: 使用NX OpenC++查询装配组件并判断加载状态7 [# S. f% \  |/ \3 [9 f" Z

+ Y( [+ J' i# |0 K

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

NX二次开发源码: 使用NX OpenC++查询装配组件并判断加载状态
* t2 ^3 m" ^) T5 m4 w$ V
  1. <p>static void geTChildren(Assemblies::Component *rootcomponent,unsigned int indent)
    / F$ m, u% E$ C/ G) T3 h# i
  2. {       4 w. G9 u3 H4 f3 Q5 x4 S
  3.   
    & @- ~* b! T+ h6 v9 u9 V
  4.   unsigned int ii;
    / b3 c  P9 y, H9 O  j- k: W* P. i
  5.   char space[MAX_LINE_SIZE+1] = { " " };/ o. Q' u0 |/ v1 Z9 x2 J2 v
  6.    for (ii = 0; ii < indent; ii++) strcat(space, " ");2 Z0 t3 x' p3 K
  7.   std::vector<Assemblies::Component *>components;
    8 K5 f8 {, e3 @9 P# q3 b
  8.   Session *theSession = Session::GetSession();
    7 f! q9 S2 d' s3 E2 }
  9.   ListingWindow *lw = theSession->ListingWindow();
    ; _! @. W8 P  p- I. ?; y7 e
  10.      lw->Open();
    $ [2 c" T- S, C3 ?+ J
  11.   components = rootcomponent->GetChildren();: B7 R8 r- m! _- U+ ^' s1 W
  12.       for (int i = 0 ; i <components.size();i++)+ T1 J: f/ j  k5 g0 z4 N  g9 O
  13.       {( S- I" A5 p1 S& g) g
  14.        Part *childpart = dynamic_cast<Part*>(components[i]->Prototype());9 z0 `: Q# Q8 o# R- ?* ]# u
  15.      
    5 F: U( T6 Z0 c% T& _; m1 L+ u/ `  l
  16.       if(childpart==NULL)0 }" Y, t7 ?7 I3 ]
  17.        {
    3 f7 O/ B) m3 ]& Z1 S2 w- V% N; k
  18.         lw->WriteLine(space+components[i]->DisplayName()+"\t"+"Status: not loaded!");! J& Y. s4 C- R0 x, u
  19.         }
    ' w* S9 p/ t1 I4 Q
  20.        else 9 |( Z6 D! Y  |) G9 Q
  21.        {* f) ?2 S/ w  E# d3 u5 X
  22.         if (childpart->IsFullyLoaded())3 R+ v. Q7 d- n0 b/ x3 [- C1 ]
  23.          {
    $ o! T$ a: }  t0 m/ a5 b+ a; w$ r
  24.           lw->WriteLine(space+components[i]->DisplayName()+"\t"+"Status: IsFullyLoaded!");& P% k3 c, \2 x
  25.          }
    : P+ ^+ ^! g% {9 c- Q7 N
  26.         else  0 n$ ?0 D2 G3 c& z3 w
  27.          {
    + X4 H: x6 Z. m) O' i0 K
  28.           lw->WriteLine(space+components[i]->DisplayName()+"\t"+"Status: IsPartiallyLoaded!");9 x6 [- l% I3 e/ `
  29.          }7 W, w0 |% |$ s) v
  30.         ) b/ b2 l  N, x
  31.       
    . g: b/ O9 Q- F5 |2 F
  32.         getchildren(components[i],indent+5);1 g. l1 \8 x/ P. N. I
  33.       }) o4 y' s# L" F$ f! o" t  q
  34.       }
    ; J% ^7 T0 u) `) ?+ L
  35. }</p><p>static void do_api()& `7 f% ]5 x* h! }
  36. {. a/ z. X/ l* J( `+ J* x8 w) }" ~8 e
  37. //list the components
    7 v) a2 W8 ~. }. O4 f
  38.   Session *theSession = Session::GetSession();* u5 H. y7 ^. {0 F6 I' W
  39.   ListingWindow *lw = theSession->ListingWindow();
      \" ]6 `  }1 e4 N2 `7 @& f
  40.   lw->Open();  \: t4 k  \5 ~6 }4 {
  41.   Assemblies::Component * rootcomponent;; `) c' m0 U2 M0 d9 A/ U8 Q# D
  42.   Part *workpart;! d3 i5 i. b: B9 |5 h  k1 d5 a/ ^
  43. rootcomponent = theSession->Parts()->Display()->ComponentAssembly()->RootComponent();. L( ~% C. n% ]" c4 f
  44. workpart = theSession->Parts()->Work();
    2 U1 J. m0 H; u8 z' l1 H. M+ X% j
  45. lw->WriteLine("The workpart is : "+workpart->FullPath()+ "\n" );) p# B* v+ z% V  d  X
  46. if(rootcomponent==NULL)
    8 {8 H- ^2 C8 o. P! I$ h$ r
  47. {  6 P: R) C& F/ q7 M3 E* _
  48.     lw->WriteLine("The part is not an assembly ! \n " );7 C8 w" e6 @9 Z0 }
  49. }) X- {; Y" j& T& r
  50. else
    + g) g  o3 u* p8 p
  51. {
    ; n0 Z& T- j8 ?; i. l
  52.   lw->WriteLine("The rootcomponent is : " +  rootcomponent->DisplayName()+"\n");
    1 r3 |& [# W& i9 Q- |7 p0 A
  53.   lw->WriteLine("The children components are : \n");
    ! D. q5 P( ]5 d# \+ B, {5 D
  54.      getchildren(rootcomponent,4);
    6 w6 t4 z) u5 n" v1 h, P, E" l7 s1 B
  55. }</p><p>}- R/ y% E& d* W8 d8 c
  56. </p><p> </p>
复制代码

$ w# o; F+ g3 R, E) W! p% g, [. 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二次开发专题模块培训报名开始啦

    我知道了