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

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

[复制链接]

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

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

mildcat 楼主

2013-12-4 16:36:55

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

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

x

5 V. x: W1 _3 m" t  PNX二次开发源码: 使用NX OpenC++查询装配组件并判断加载状态
- z+ b) a7 S1 Q. L* c  w8 {! J9 e8 }3 [( |/ p2 A/ I0 r& t

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

NX二次开发源码: 使用NX OpenC++查询装配组件并判断加载状态
4 L% ]  x. F5 T& y
  1. <p>static void geTChildren(Assemblies::Component *rootcomponent,unsigned int indent)$ P- j( ~, _) {& o
  2. {      
    / ~" d1 |& Y+ Q/ i2 ~
  3.   
    & _4 l9 g, X9 z: G
  4.   unsigned int ii;
    " u& T# T2 Z* w
  5.   char space[MAX_LINE_SIZE+1] = { " " };. x$ t/ D$ g' Y8 b6 A0 C7 w5 i
  6.    for (ii = 0; ii < indent; ii++) strcat(space, " ");
    5 s) w- k. p% h$ K
  7.   std::vector<Assemblies::Component *>components;$ d2 |% j- Z& P' J$ D
  8.   Session *theSession = Session::GetSession();
    5 A& @% ~/ w/ e5 P9 o5 _
  9.   ListingWindow *lw = theSession->ListingWindow();4 r9 O* B) D  Q9 V; f
  10.      lw->Open();( T5 w! v/ j5 p4 v9 `& r' E% e
  11.   components = rootcomponent->GetChildren();( Z' x0 C/ b5 H2 P7 r+ F' F
  12.       for (int i = 0 ; i <components.size();i++)  P; P( A7 w2 D- p# r: o( i
  13.       {
    $ g8 U% j3 J# q
  14.        Part *childpart = dynamic_cast<Part*>(components[i]->Prototype());
    7 E) T4 S1 @; O8 z9 F
  15.      3 {8 D1 Y5 y) T! w# C9 W  ]
  16.       if(childpart==NULL)3 y+ \! t* f/ {! Z8 T2 w
  17.        {& ~0 [" V) B; G) ]5 V& ~/ z. B
  18.         lw->WriteLine(space+components[i]->DisplayName()+"\t"+"Status: not loaded!");+ G# @8 C  V% B
  19.         }
    4 m: w( p5 W% A' ]( F: Q
  20.        else
    5 k6 Y+ k% h1 m
  21.        {) z) p2 r& ?# t
  22.         if (childpart->IsFullyLoaded())
    + L- X, ?8 ~9 I1 u. v0 E  B) P2 H
  23.          {0 d8 r; y9 N; v. O9 Q; N5 z
  24.           lw->WriteLine(space+components[i]->DisplayName()+"\t"+"Status: IsFullyLoaded!");
    & _9 y1 B7 z: n" `
  25.          }
    . j% s8 }7 B; K( F9 _
  26.         else  3 }5 z' _0 ?* l# n8 J6 H) X7 O, C2 M
  27.          {
    2 K5 x% Y8 X, p  b! r) A$ m# Q
  28.           lw->WriteLine(space+components[i]->DisplayName()+"\t"+"Status: IsPartiallyLoaded!");% l3 {- K) f" K& G3 I% b
  29.          }
    ' F# q* _/ s' u& @( L- ]& v# b# P6 M
  30.         
    ; t. `* H$ T. A% e0 Q
  31.       
    0 @/ @+ n: g. x6 Q
  32.         getchildren(components[i],indent+5);
    : _% s2 j2 w5 Y5 D+ ~7 Q
  33.       }' d3 b5 X, m" Q
  34.       }! C. Z( b! s0 b/ S, @
  35. }</p><p>static void do_api()
    , G; j, f# O, `  x6 N
  36. {
    & D/ T/ h/ b6 v! x! D4 N) I
  37. //list the components
    $ Z9 O- C: v$ M  {0 k
  38.   Session *theSession = Session::GetSession();
    ' g7 B3 z# ^" T8 _" m( b6 J
  39.   ListingWindow *lw = theSession->ListingWindow();
    3 d( Y) a3 Q0 V8 P) X* ^6 k
  40.   lw->Open();
    + y+ _+ X3 T9 w' l
  41.   Assemblies::Component * rootcomponent;% B7 A. O( M8 D( m, Y
  42.   Part *workpart;
    & I! z$ r+ F' P) h& T
  43. rootcomponent = theSession->Parts()->Display()->ComponentAssembly()->RootComponent();( ], E1 H5 C9 ^- y# U
  44. workpart = theSession->Parts()->Work();3 Z9 X* x5 e" r; Z& ~8 m4 c2 ]
  45. lw->WriteLine("The workpart is : "+workpart->FullPath()+ "\n" );
    7 c# P5 b$ z% F% K* ^
  46. if(rootcomponent==NULL)
    - J+ D4 @% p% u. ?+ C7 R* H
  47. {  2 k1 m+ ~) s+ ~/ \! n: P
  48.     lw->WriteLine("The part is not an assembly ! \n " );
    ) M; A6 Q/ `- e1 V2 M
  49. }9 f* W- ?$ h5 }" B4 s) A+ E
  50. else2 G6 @' |9 D1 x
  51. {: V/ O# O5 C' N
  52.   lw->WriteLine("The rootcomponent is : " +  rootcomponent->DisplayName()+"\n");. U9 A" Z: l, Z. A* W
  53.   lw->WriteLine("The children components are : \n");
    $ r% m4 I& a  H- a% U2 |
  54.      getchildren(rootcomponent,4);
    6 Y; I7 y$ U' i% F- P6 ]
  55. }</p><p>}' w7 `) \+ g. D8 \5 ?+ R) }
  56. </p><p> </p>
复制代码
0 y# G# C. n" H, g. W% 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二次开发专题模块培训报名开始啦

    我知道了