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

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

[复制链接]

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

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

mildcat 楼主

2013-12-4 16:36:55

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

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

x
; V5 U4 z/ p  N
NX二次开发源码: 使用NX OpenC++查询装配组件并判断加载状态; {# `9 v( ?, W  T. S% F. Q
9 A% Z- P, O9 ]2 S5 G; w9 Q

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

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

$ G( H/ z- X4 ]2 K+ [5 q" Y; E
  1. <p>static void geTChildren(Assemblies::Component *rootcomponent,unsigned int indent)( |6 D2 _/ G# U
  2. {      
    1 s" J3 ^; X/ x5 H6 i
  3.   6 t! E6 p2 Z* P
  4.   unsigned int ii;  u6 d' {  [) j5 v9 ]
  5.   char space[MAX_LINE_SIZE+1] = { " " };; G+ w7 h, k* d
  6.    for (ii = 0; ii < indent; ii++) strcat(space, " ");
    2 f' m( [5 U" i
  7.   std::vector<Assemblies::Component *>components;, x5 X/ G6 W" A: k
  8.   Session *theSession = Session::GetSession();, ^9 w: ^* {& I8 O# j6 K& U( s& v$ v- |
  9.   ListingWindow *lw = theSession->ListingWindow();
    ' E  P- }  U: f% j
  10.      lw->Open();* y2 _4 ]- N- |' E: r5 h( u
  11.   components = rootcomponent->GetChildren();8 u0 S! T6 ^- p* I; J7 J
  12.       for (int i = 0 ; i <components.size();i++)
    ' i6 M4 y' T2 k$ \
  13.       {
    0 o( c: g) N" d9 [
  14.        Part *childpart = dynamic_cast<Part*>(components[i]->Prototype());- _7 X. m' n- g6 @8 }9 U
  15.      
    6 @8 \1 n" P' R; k1 O: ]
  16.       if(childpart==NULL)# f  K7 Q; ~% t; r5 J, J
  17.        {
    ) P0 _+ M4 |# b( @+ k' U
  18.         lw->WriteLine(space+components[i]->DisplayName()+"\t"+"Status: not loaded!");9 m5 y9 p* a/ D4 s/ Y
  19.         }
    / N- N# P1 g7 d; B0 j* f$ \; @
  20.        else 4 N* \/ Y3 w6 n6 c( g% u
  21.        {/ r5 }2 C$ |* ?' F- H4 H8 D
  22.         if (childpart->IsFullyLoaded())
    3 g9 B; b6 j. w7 s
  23.          {
    # Q) ~+ ~) h, P" {
  24.           lw->WriteLine(space+components[i]->DisplayName()+"\t"+"Status: IsFullyLoaded!");
    % Y% N: p, b# b
  25.          }& m0 f  c. A4 [+ b% Z% i# z! d
  26.         else  ' T8 [! [/ e! L3 G; ?* m' J
  27.          {
    ; W! x% Y& x( u7 v7 @/ C4 c
  28.           lw->WriteLine(space+components[i]->DisplayName()+"\t"+"Status: IsPartiallyLoaded!");  F5 Q; e4 r: G. R; I
  29.          }4 m) `* j2 e* J; b# q
  30.         
    ) k5 ]/ A) m: b, r
  31.       ! X* ]1 G$ f; L7 @
  32.         getchildren(components[i],indent+5);6 }* d4 B$ l& E2 w6 H0 @
  33.       }
    : x# [- O8 G2 O# V. Y# e3 i6 A
  34.       }  }6 K* L9 V, v0 @
  35. }</p><p>static void do_api()
    1 p. }+ Z. X* z( q- A' f# y
  36. {4 h- L* O4 q: w5 r
  37. //list the components
    8 C! F* a& k, p' m! g
  38.   Session *theSession = Session::GetSession();
    / ~% ]# t; q. G
  39.   ListingWindow *lw = theSession->ListingWindow();$ ~; S3 o$ e- U2 d, i1 \6 S/ @
  40.   lw->Open();
    # f9 L. E9 P/ Q8 t7 F& Y3 y7 V
  41.   Assemblies::Component * rootcomponent;7 ]1 L, R2 |; |
  42.   Part *workpart;
    2 v& ]" e+ J: ]
  43. rootcomponent = theSession->Parts()->Display()->ComponentAssembly()->RootComponent();) U; T" b3 o- e; h9 I
  44. workpart = theSession->Parts()->Work();
    5 v" G3 I) Q6 t: Q1 D( ]0 a9 s0 T
  45. lw->WriteLine("The workpart is : "+workpart->FullPath()+ "\n" );
    " V0 L6 N. ^4 E% S
  46. if(rootcomponent==NULL)9 {5 @& @* V$ g
  47. {  
    3 r3 ?% g# a* H- |" v
  48.     lw->WriteLine("The part is not an assembly ! \n " );
    $ j7 V+ }6 E! f/ l
  49. }7 p% E: P0 L5 K, z6 [0 S6 b7 t
  50. else$ L, P7 y! g/ d# x5 ^
  51. {* N2 p9 I, J# S1 r$ h1 j
  52.   lw->WriteLine("The rootcomponent is : " +  rootcomponent->DisplayName()+"\n");( C8 g' M7 k$ z8 |% C
  53.   lw->WriteLine("The children components are : \n");
    4 ^6 Y; n' y  m+ Q  j0 J) ~$ g
  54.      getchildren(rootcomponent,4);" [4 m/ ?9 }* d
  55. }</p><p>}
    0 B/ V/ A4 I) d
  56. </p><p> </p>
复制代码
1 V% L4 H; B% I8 i- G: V+ o; |
该会员没有填写今日想说内容.
回复

使用道具 举报

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

    我知道了