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

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

[复制链接]

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

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

mildcat 楼主

2013-12-4 16:36:55

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

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

x

$ ~! l  v$ R0 x; L9 oNX二次开发源码: 使用NX OpenC++查询装配组件并判断加载状态, ?0 P( x2 L8 P3 X. @8 p2 d
  ^+ H1 a! j% F6 t. p3 Z) H

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

NX二次开发源码: 使用NX OpenC++查询装配组件并判断加载状态
# f; u4 x! s  f5 q; ^7 ]
  1. <p>static void geTChildren(Assemblies::Component *rootcomponent,unsigned int indent)3 B$ T2 {6 \( K4 W  G( \
  2. {       ) F6 V; o: G4 B) C' z0 l" d8 T+ F2 y
  3.   
    * j6 t8 W& J! ~5 N3 z2 C
  4.   unsigned int ii;/ J% O: l' r% w/ u* B7 ?3 v
  5.   char space[MAX_LINE_SIZE+1] = { " " };
    / G0 {7 ?9 K* _3 C  C1 h: J  J
  6.    for (ii = 0; ii < indent; ii++) strcat(space, " ");
    ! E, |2 A; ~$ A; W
  7.   std::vector<Assemblies::Component *>components;' J5 I. ^" |' T' Q
  8.   Session *theSession = Session::GetSession();: d2 S& N" r! T
  9.   ListingWindow *lw = theSession->ListingWindow();- u9 }( i' b; m8 X6 r) P
  10.      lw->Open();& u( \1 Y$ e2 y4 x  j. k, |) C
  11.   components = rootcomponent->GetChildren();; L4 o" F( j6 R4 M  O
  12.       for (int i = 0 ; i <components.size();i++)* `+ {& L2 j, x+ R$ P3 k
  13.       {) m; f0 L" s# W# F+ s; R  @
  14.        Part *childpart = dynamic_cast<Part*>(components[i]->Prototype());# |% }" Y0 q; Y4 D, c0 B+ h' o
  15.      4 u9 \; y8 n, D4 Y' E+ i" s
  16.       if(childpart==NULL): r6 ]9 O. |2 e+ X
  17.        {
    3 t1 X, v- U' @6 G/ m/ ?" z" s
  18.         lw->WriteLine(space+components[i]->DisplayName()+"\t"+"Status: not loaded!");
    . `9 B7 Z8 U% }. O- @
  19.         }
    9 a" q+ Y& B) q% _2 S5 H! ^9 I
  20.        else
    " G6 J9 @3 d* [; C$ c* S
  21.        {- @  k" n( C$ @) x) a
  22.         if (childpart->IsFullyLoaded())# y; J, \, Q# s" Y( j
  23.          {: p' Q9 S/ W  K5 [7 c8 e& l  ]
  24.           lw->WriteLine(space+components[i]->DisplayName()+"\t"+"Status: IsFullyLoaded!");0 J7 C% G; y5 m( k9 }( g  e
  25.          }  D6 c( }" Y1 z
  26.         else  3 e. C, O+ y0 ^$ A& {( M1 n
  27.          {
    - G2 R2 S/ v" n4 |
  28.           lw->WriteLine(space+components[i]->DisplayName()+"\t"+"Status: IsPartiallyLoaded!");9 o0 m1 _! R% o6 U) B3 H
  29.          }6 J6 c" i. |# n, a
  30.         ' t6 z# g: ~/ z: V2 A5 O9 Q
  31.       
    # R7 m, q- _. C
  32.         getchildren(components[i],indent+5);7 r; E8 `: e9 {/ Z8 _& O5 z, Y
  33.       }
    4 p) N7 R8 B/ r% T8 \9 y$ l
  34.       }
      S, P7 |+ q! W  t8 w* ]' P! y
  35. }</p><p>static void do_api()6 X7 X+ D& M3 W. Z* ?: L2 s
  36. {6 @% y9 P' G$ t+ C  G
  37. //list the components/ G& l" \6 C% h# D3 ^' k
  38.   Session *theSession = Session::GetSession();( x* t& ~$ y- Y+ i0 S; B6 x- B
  39.   ListingWindow *lw = theSession->ListingWindow();
    # A3 D) r0 x" |+ |( {4 r) u
  40.   lw->Open();$ B" f. \" u7 i
  41.   Assemblies::Component * rootcomponent;& n: x& A; v9 E3 p* j( F/ G- ~" c! S
  42.   Part *workpart;: t- U$ ?+ A- \# `! Z* a% j. B2 r
  43. rootcomponent = theSession->Parts()->Display()->ComponentAssembly()->RootComponent();
    7 R1 f; N/ {' W- `$ ?! h: l5 \# i; o
  44. workpart = theSession->Parts()->Work();
    5 Z7 @0 Y0 z4 y# }  I+ J0 [
  45. lw->WriteLine("The workpart is : "+workpart->FullPath()+ "\n" );
    ; t8 ]0 t# j* z$ f. L, ]
  46. if(rootcomponent==NULL); r/ q9 M; P* F8 P4 k. n
  47. {  . c0 y' \4 [9 o2 O2 B& @( j2 p# M
  48.     lw->WriteLine("The part is not an assembly ! \n " );
    4 J+ r8 G/ t: P
  49. }
    3 R0 m  ~3 f/ Q1 M9 r% y# y  ]
  50. else
    # V, c. c* t- `9 [8 ^0 ?. ^0 p
  51. {
    + t5 Z, M. T! A+ c: ]
  52.   lw->WriteLine("The rootcomponent is : " +  rootcomponent->DisplayName()+"\n");  D; G7 @0 }" ?& b/ `
  53.   lw->WriteLine("The children components are : \n");% z- D) M+ d/ l% @$ L8 L
  54.      getchildren(rootcomponent,4);; A7 E2 h3 Q$ x0 }
  55. }</p><p>}& v# p2 o8 h) ~6 Q$ z
  56. </p><p> </p>
复制代码

7 o% A' Y0 B4 `7 v2 X! t
该会员没有填写今日想说内容.
回复

使用道具 举报

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

    我知道了