PLM之家PLMHome-国产软件践行者

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

[复制链接]

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

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

mildcat 楼主

2013-12-4 16:36:55

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

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

x

" ^8 r& b& b/ R6 M+ [NX二次开发源码: 使用NX OpenC++查询装配组件并判断加载状态8 Z  A: @8 m+ m

8 ~, j1 K0 ~. p. b/ T

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

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

2 j' X5 l9 ]- p) ]+ X! c/ ^
  1. <p>static void geTChildren(Assemblies::Component *rootcomponent,unsigned int indent)7 \8 r7 ]0 Z4 a1 s$ X1 {
  2. {       ( z- m- z. M, N9 z7 |4 t; g
  3.   
    ' Y+ j2 c& x: I" u
  4.   unsigned int ii;
    ) y  T$ u! I1 J; y' L& P2 C
  5.   char space[MAX_LINE_SIZE+1] = { " " };
    % h( m7 R' u& f3 ?: x! ~) E6 e
  6.    for (ii = 0; ii < indent; ii++) strcat(space, " ");9 |# q- q% T4 Y' O) a4 e
  7.   std::vector<Assemblies::Component *>components;0 t, c& o9 L' `* ]
  8.   Session *theSession = Session::GetSession();
    * d: O! b$ G7 j
  9.   ListingWindow *lw = theSession->ListingWindow();( Q+ ?8 F) [4 }) H5 {& u3 y& A' F
  10.      lw->Open();3 `% Q/ x' n- n0 d9 L! K) N$ ^
  11.   components = rootcomponent->GetChildren();
    9 T0 t, ~0 a% s, @4 X) U. |1 \- @& O
  12.       for (int i = 0 ; i <components.size();i++)/ x1 u( i4 I4 x
  13.       {
    - f" C: R3 ]0 C3 c$ L. k
  14.        Part *childpart = dynamic_cast<Part*>(components[i]->Prototype());" G( B# [' Q' A3 c% o  I" b
  15.      
    2 @9 X. f+ ]! H' a; I% r- |
  16.       if(childpart==NULL)
    8 ]3 h' \6 e. ]
  17.        {
    0 O5 A% k6 m5 [* n. O
  18.         lw->WriteLine(space+components[i]->DisplayName()+"\t"+"Status: not loaded!");
    / y" M$ y5 u9 R2 ]: z- J& ]
  19.         }
    5 }1 N7 j3 R( K1 M# K& }0 ~7 d7 G
  20.        else , v/ l- ?$ Z/ ?# s1 q7 c
  21.        {& V7 M% p9 T+ y6 P) ]
  22.         if (childpart->IsFullyLoaded())
    - N: O  ^: h( S- K
  23.          {
    % H) S) h  ~0 r7 X; B6 ?
  24.           lw->WriteLine(space+components[i]->DisplayName()+"\t"+"Status: IsFullyLoaded!");
    8 F3 P6 X0 q$ o3 ~8 c; V
  25.          }
    . ^1 \. ?8 B3 e, k
  26.         else  
    " Y. j3 W+ ^9 W- E
  27.          {' u5 f& y* T8 M+ x( K- ?0 j
  28.           lw->WriteLine(space+components[i]->DisplayName()+"\t"+"Status: IsPartiallyLoaded!");
    7 l8 r8 e2 X8 [- O
  29.          }
    + Z/ t7 H! E: J$ G0 D8 L( k- _/ l
  30.         / D* c$ f' ]  O
  31.       
    6 Z. E/ d' J6 m: D" Q
  32.         getchildren(components[i],indent+5);# ^2 y* G( ~2 L" {
  33.       }
    3 _- E, h4 G; t9 R9 o/ Y
  34.       }4 F* h. M. W  Z. t0 F1 D
  35. }</p><p>static void do_api()
    ! x1 ~4 l7 I6 y4 b& i( ^1 n. D/ `% F
  36. {
    : G: ~& `2 e% h$ g
  37. //list the components8 V5 F9 |: S2 K# b* Z, V* z7 Y
  38.   Session *theSession = Session::GetSession();0 l$ A. o0 ]1 \+ I" f
  39.   ListingWindow *lw = theSession->ListingWindow();: l4 s$ M; a0 C, Y
  40.   lw->Open();2 }" F( ~8 [: `% v- Y/ c+ ~
  41.   Assemblies::Component * rootcomponent;
    - d) ?2 W: ~2 \/ Z
  42.   Part *workpart;
    # ^+ D8 f' K; j0 d! A" p
  43. rootcomponent = theSession->Parts()->Display()->ComponentAssembly()->RootComponent();
    , m0 s) `" ~7 A8 a, A
  44. workpart = theSession->Parts()->Work();
    & U! d, p; e6 z; p7 m9 A
  45. lw->WriteLine("The workpart is : "+workpart->FullPath()+ "\n" );  e! b+ |" o* J; j6 \
  46. if(rootcomponent==NULL)
    6 d: [5 @7 ~" h/ ~
  47. {  ) R" H" o$ @" j1 [. `
  48.     lw->WriteLine("The part is not an assembly ! \n " );: ^; N6 K7 I3 I6 p- E% t# ]% g1 R2 k
  49. }
      h: q% x0 z1 p4 u8 Q1 K# d3 I
  50. else6 o0 e5 Z% g, @1 s$ ^! d
  51. {1 \4 t% i" i, G- E
  52.   lw->WriteLine("The rootcomponent is : " +  rootcomponent->DisplayName()+"\n");
    6 d" `& c/ P3 k  G
  53.   lw->WriteLine("The children components are : \n");# P2 p+ L7 }& a8 M- D
  54.      getchildren(rootcomponent,4);5 ~* u; N3 [4 f6 r$ M
  55. }</p><p>}& u5 Q8 E6 k9 V
  56. </p><p> </p>
复制代码

# G9 \& m# \% k6 R/ K8 q
该会员没有填写今日想说内容.
回复

使用道具 举报

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

    我知道了