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

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

[复制链接]

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

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

mildcat 楼主

2013-12-4 16:36:55

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

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

x
/ w! }- N0 V% q  n3 \0 \7 Z& {
NX二次开发源码: 使用NX OpenC++查询装配组件并判断加载状态2 y+ T" P9 [* D' V0 K
+ L+ m2 I5 G( U+ t

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

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

/ G2 Q$ e. p0 `% S
  1. <p>static void geTChildren(Assemblies::Component *rootcomponent,unsigned int indent)% c% u; \! c) x3 u9 N' d, O! f
  2. {      
    9 X" Q5 ~" A' J( t
  3.   ( S. b; u! N) x" L. m0 G) g
  4.   unsigned int ii;$ `& [  F; [3 s* D5 _
  5.   char space[MAX_LINE_SIZE+1] = { " " };0 B; g* i7 Q8 d9 q! Z0 [7 V
  6.    for (ii = 0; ii < indent; ii++) strcat(space, " ");
    2 A5 P& @8 c/ f2 |3 H7 e
  7.   std::vector<Assemblies::Component *>components;
    ) D* R) _& o# z0 z! u0 E. B
  8.   Session *theSession = Session::GetSession();
    4 D+ M$ j2 h+ u1 C% t' h7 x% c
  9.   ListingWindow *lw = theSession->ListingWindow();
    1 l+ p+ W# `) v7 N% N) D5 y- ]' z
  10.      lw->Open();
    8 {) \! z: K4 V, L5 i
  11.   components = rootcomponent->GetChildren();! F2 z( C+ z1 D! ?* u
  12.       for (int i = 0 ; i <components.size();i++)
    ( D8 z8 Z( Z4 g3 e$ i# R; k1 K8 [
  13.       {2 U5 V! p( I1 Q: X
  14.        Part *childpart = dynamic_cast<Part*>(components[i]->Prototype());
    1 _" t1 L  v$ Z% _' h* Y
  15.      
    8 s# ?+ q# N/ g; s1 \+ [8 X& u. A
  16.       if(childpart==NULL)0 x$ r9 ]2 o# ~
  17.        {% J9 C3 l; h1 G& f: n& U/ p0 H: M; [- V/ ^
  18.         lw->WriteLine(space+components[i]->DisplayName()+"\t"+"Status: not loaded!");
    ; y" P0 D8 N9 d/ x1 t- H# F$ u
  19.         }
    ' j+ q2 x8 Y! j( Z; ]/ J
  20.        else , c- R% O7 Z; v$ g# k: I
  21.        {
    ) i3 v" Z8 F3 b
  22.         if (childpart->IsFullyLoaded())" x" H/ U+ S: Q: y; C
  23.          {6 F+ J  J7 n% e! l6 u* b
  24.           lw->WriteLine(space+components[i]->DisplayName()+"\t"+"Status: IsFullyLoaded!");2 j! X9 g3 W+ r4 L) H& h- y
  25.          }! X* r8 q% ?: e* I: y
  26.         else  
    $ B+ m" H  z& l9 ~1 @% S
  27.          {
    ( L8 P9 x' C! O$ v( K
  28.           lw->WriteLine(space+components[i]->DisplayName()+"\t"+"Status: IsPartiallyLoaded!");
      |* K: b9 s0 R/ |- k; K% n
  29.          }1 ]5 g- b) e: |
  30.         
    + d4 h' u. P/ V$ A2 J
  31.       
    * A6 b# @! P' D* Y* K% h1 n' H
  32.         getchildren(components[i],indent+5);! S9 J( r# D7 m
  33.       }
    # a( [+ Y9 f7 P. U- x! J4 {* g
  34.       }
    2 `4 p) H: V/ u9 J: {
  35. }</p><p>static void do_api()
    2 M1 |. I7 u" D. R1 h; S- L
  36. {/ {% a- j* _% H, g
  37. //list the components2 i+ d' ?& a  D
  38.   Session *theSession = Session::GetSession();
    ; C- R' V8 a; I5 e9 n! T
  39.   ListingWindow *lw = theSession->ListingWindow();: [, l1 B2 f( o% H& w6 }$ b
  40.   lw->Open();
    - o  c% ^" A3 \: @; V
  41.   Assemblies::Component * rootcomponent;, d7 P6 C( C3 I" P
  42.   Part *workpart;
    ; F2 T, `: h" S' F2 \
  43. rootcomponent = theSession->Parts()->Display()->ComponentAssembly()->RootComponent();' X# a+ u! f- w' ?1 N7 x6 U
  44. workpart = theSession->Parts()->Work();, s: \( C+ h' A: _1 h( f: l$ L
  45. lw->WriteLine("The workpart is : "+workpart->FullPath()+ "\n" );
    ' ^& N6 A2 C$ C3 I" j; E: ]
  46. if(rootcomponent==NULL)& ^% `$ c8 D# Z' ]$ B
  47. {  
    & s3 W4 Z6 ?% C' q* [( f9 h4 |/ P3 v
  48.     lw->WriteLine("The part is not an assembly ! \n " );3 j  l$ y6 k% N1 T$ j
  49. }
    7 X! u& l% z4 W
  50. else
    + l0 ?. L" B# T8 u& X
  51. {
    " ~4 ^) D( ~8 e2 o9 ]) Y
  52.   lw->WriteLine("The rootcomponent is : " +  rootcomponent->DisplayName()+"\n");6 b  ~) h2 F% ^0 l' l0 \! a
  53.   lw->WriteLine("The children components are : \n");
    ( W1 T: w. l5 U( R! v+ T' \  f
  54.      getchildren(rootcomponent,4);" j. X8 [: ~! [% }0 @+ D
  55. }</p><p>}
    * v8 Q0 N8 ^4 G0 ~# A0 I
  56. </p><p> </p>
复制代码
* ^7 {& {5 b4 o; j# L1 ^0 H
该会员没有填写今日想说内容.
回复

使用道具 举报

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

    我知道了