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

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

[复制链接]

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

320

主题

226

回帖

9784

积分

管理员

PLM之家NX|TC专家

积分
9784
发表于 2013-12-4 16:36:55 | 显示全部楼层 |阅读模式

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

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

x

+ @) `8 [  A9 D. F0 u2 bNX二次开发源码: 使用NX OpenC++查询装配组件并判断加载状态
( i) O% v# I4 M9 a7 V6 k
& p  o8 M4 n7 Y2 O$ S, y2 U& _

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

NX二次开发源码: 使用NX OpenC++查询装配组件并判断加载状态
' o0 b8 y4 G6 |) D! p: z2 b( r. l
  1. <p>static void geTChildren(Assemblies::Component *rootcomponent,unsigned int indent)
    4 M1 p# j$ i9 I# F
  2. {      
    ' ?: }/ e8 ^+ E$ ]4 {( ]
  3.   4 h; \" P8 q4 H
  4.   unsigned int ii;; b/ @! N8 b, c- j
  5.   char space[MAX_LINE_SIZE+1] = { " " };8 q2 {& _1 R. \% a7 v4 `/ Z1 |
  6.    for (ii = 0; ii < indent; ii++) strcat(space, " ");
    6 v. V( I- Q- O0 [+ \7 G) R6 P
  7.   std::vector<Assemblies::Component *>components;- z. W; K" ^7 M! E) n
  8.   Session *theSession = Session::GetSession();
    . x# E  E& L, d7 f8 ~1 F- Z* d! q
  9.   ListingWindow *lw = theSession->ListingWindow();3 |$ Q) _0 F0 H: c7 v
  10.      lw->Open();+ Z8 [/ i0 N$ N; Z& H
  11.   components = rootcomponent->GetChildren();
    " z4 p# ]% R' |& I
  12.       for (int i = 0 ; i <components.size();i++)) e) `. p  b* ]# L; H' C3 {
  13.       {3 Z: O$ b0 c# \. B$ A2 b/ B
  14.        Part *childpart = dynamic_cast<Part*>(components[i]->Prototype());  R2 v3 T2 ^6 `  G5 Z& y) p
  15.      
    . ?3 |. C2 r6 t, p8 f
  16.       if(childpart==NULL)
    4 z) R# f+ z" m& P( q+ f/ ~6 H
  17.        {) n. W) W3 o( K/ J5 W: s' O3 m
  18.         lw->WriteLine(space+components[i]->DisplayName()+"\t"+"Status: not loaded!");
    0 D+ u7 y% k8 A: E
  19.         }
    8 A) n- Z' Q8 V
  20.        else % b& B% h7 _8 F' T* G' n$ i
  21.        {  a7 z# q: t5 p0 d
  22.         if (childpart->IsFullyLoaded()); b: ]( J/ H- W$ ]# O9 i
  23.          {
      `8 _/ |) q( \
  24.           lw->WriteLine(space+components[i]->DisplayName()+"\t"+"Status: IsFullyLoaded!");
    5 Y# e+ @( b1 R! b; P# f
  25.          }
    - H; M9 [: h4 p! n
  26.         else  ! T3 B6 b8 ~8 S: G! i- t% l5 r
  27.          {
    $ _: {& B) p, n9 d' J3 R6 y+ `. S
  28.           lw->WriteLine(space+components[i]->DisplayName()+"\t"+"Status: IsPartiallyLoaded!");
    1 N5 Z/ y! a5 g4 n+ L: x0 Y: a  [
  29.          }
    $ ]' Q. U7 f& R# `) j. N" T; R
  30.         
    ! M3 r6 L# A% f, s, |4 X
  31.       
    , p" o, s6 _: q3 \2 @0 h1 g4 A; e- v
  32.         getchildren(components[i],indent+5);% L! x+ O( ?; p$ t0 C
  33.       }1 Z' v6 |* U% s2 O8 a
  34.       }' c7 ?9 c; G8 O6 J7 H7 k. j, v
  35. }</p><p>static void do_api()4 V. R2 o8 Y% F2 y
  36. {7 ~- I$ t2 u2 d& B; v' M: l
  37. //list the components
    5 M( M( T% W: e/ i; G, G3 F3 v- g
  38.   Session *theSession = Session::GetSession();- ?" X7 k- H; l& d7 o$ v0 Z8 p
  39.   ListingWindow *lw = theSession->ListingWindow();. q8 U* [. x5 n9 S& Q
  40.   lw->Open();
    - P& `" C9 ?% Y
  41.   Assemblies::Component * rootcomponent;
    # h% L4 ^4 ^6 v; G- e& i9 h/ [3 L; O
  42.   Part *workpart;& _4 j, n3 \8 F4 G5 t. u+ Q' ^
  43. rootcomponent = theSession->Parts()->Display()->ComponentAssembly()->RootComponent();7 r0 }. {+ k6 r- A) O7 H
  44. workpart = theSession->Parts()->Work();
    0 }' R  N* r2 I. n
  45. lw->WriteLine("The workpart is : "+workpart->FullPath()+ "\n" );7 @' I+ L. \2 N2 n* V8 C$ k
  46. if(rootcomponent==NULL)
    4 D! K! I' G- i# e4 M) h4 {
  47. {  4 f& p1 d1 q  n, f0 {" Y0 q
  48.     lw->WriteLine("The part is not an assembly ! \n " );
    ; X1 Y7 t. `9 g9 Q! ~" ^
  49. }
    : G4 t" Q! [' T4 {% q6 M% s) D
  50. else1 s" y, V4 i  l3 C; j, Z
  51. {6 m' |" B+ V1 j. n) {: G; \+ B
  52.   lw->WriteLine("The rootcomponent is : " +  rootcomponent->DisplayName()+"\n");
    1 O! p3 f% D2 u6 V% f* W- M
  53.   lw->WriteLine("The children components are : \n");
    5 L& t8 l- i" @& u, d
  54.      getchildren(rootcomponent,4);! d2 K" F5 u' \. {
  55. }</p><p>}
    : Y" W- m3 H% R8 [$ \" m% T
  56. </p><p> </p>
复制代码

& H6 X1 Q9 W; m) p  Q: f; N' U$ g
该会员没有填写今日想说内容.
回复

使用道具 举报

全部回复1

7

主题

31

回帖

170

积分

注册会员

积分
170
发表于 2013-12-8 00:59:17 | 显示全部楼层
嗯,这个不错
上海点团信息科技有限公司,承接UG NX,CATIA,CREO,Solidworks 等CAx软件,Teamcenter,3D Experience等PLM软件,工业4.0数字化软件的实施\二次开发\培训相关业务,详情QQ 939801026 Tel 18301858168 网址 www.doteam.tech
回复 支持 反对

使用道具 举报

发表回复

您需要登录后才可以回帖 登录 | 注册

返回列表 本版积分规则

  • 发布新帖

  • 在线客服

  • 微信

  • 客户端

  • 返回顶部

  • x
    温馨提示

    本网站(plmhome.com)为PLM之家工业软件学习官网站

    展示的视频材料全部免费,需要高清和特殊技术支持请联系 QQ: 939801026

    PLM之家NX CAM二次开发专题模块培训报名开始啦

    我知道了