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

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

[复制链接]

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

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

mildcat 楼主

2013-12-4 16:36:55

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

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

x
1 T8 m7 ^# q& F/ F' Y
NX二次开发源码: 使用NX OpenC++查询装配组件并判断加载状态
" \* C3 b: e1 ?  i/ X0 |; U$ n/ K9 M( [2 a' [3 c$ m

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

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

3 h* U: R& |9 f* H. q  t
  1. <p>static void geTChildren(Assemblies::Component *rootcomponent,unsigned int indent)
    5 N  B7 ~0 K0 ?$ \+ r
  2. {       6 ~% i2 w; G% C+ M4 m
  3.   ( l1 K# U* @  ?, E7 P) L. W
  4.   unsigned int ii;( J) x9 ~/ K* t3 _* a7 U' B! `
  5.   char space[MAX_LINE_SIZE+1] = { " " };
    & Y6 j- }3 n! [- z' m, Q
  6.    for (ii = 0; ii < indent; ii++) strcat(space, " ");
    7 Z- P+ \, O; `$ L/ K
  7.   std::vector<Assemblies::Component *>components;
    / @. \4 ~1 A5 @5 ]
  8.   Session *theSession = Session::GetSession();
    5 ^$ L1 V4 O0 \; c! o
  9.   ListingWindow *lw = theSession->ListingWindow();% n& ?  D1 e: e
  10.      lw->Open();7 T5 y/ d9 A8 D' u8 u
  11.   components = rootcomponent->GetChildren();
    8 c8 D/ N. i- o
  12.       for (int i = 0 ; i <components.size();i++)
    - D' ~  R8 n7 l" ?" {/ v2 U
  13.       {
    6 [& F# }8 u! ~4 }( A2 k
  14.        Part *childpart = dynamic_cast<Part*>(components[i]->Prototype());% K: S& j0 _$ C# q6 [2 B: b& K
  15.      
    , b( k7 H" A$ j$ ~
  16.       if(childpart==NULL)
    4 I# h' Z9 m/ L3 V% u" t6 _1 y
  17.        {9 w; o3 l4 h9 k8 a/ K
  18.         lw->WriteLine(space+components[i]->DisplayName()+"\t"+"Status: not loaded!");
    ! `5 U- Q2 l4 j0 }
  19.         }
    ( w) _' D/ ~: G/ x/ n
  20.        else ( c' S$ d2 X; r8 l
  21.        {  P& q# r. m# g! g% ?& _8 W
  22.         if (childpart->IsFullyLoaded())
    2 {4 M) t% a8 y
  23.          {' A- y  ?+ l$ s% z8 }+ e1 B
  24.           lw->WriteLine(space+components[i]->DisplayName()+"\t"+"Status: IsFullyLoaded!");6 O# {$ Q9 V2 D3 N! U
  25.          }6 k+ a0 w, ^: i# [& a$ U! h
  26.         else  
    / m  d! @, N# z( M( ^
  27.          {
    - E5 Y6 ?* t" L6 n. ?: }
  28.           lw->WriteLine(space+components[i]->DisplayName()+"\t"+"Status: IsPartiallyLoaded!");
    ' P0 W" V& [1 A
  29.          }
    : Y3 R9 {7 Y  h* u! a3 N4 {
  30.         / T: p' N' @- t
  31.       6 ]; P- S( z4 f% [7 I4 S" Q( E$ n
  32.         getchildren(components[i],indent+5);
    & S8 C: y3 q) k9 v) V  @( q
  33.       }6 m' E9 u  k3 h( R2 r- ^; J3 R+ ]
  34.       }5 R3 m0 G2 Y! N- V; v6 l
  35. }</p><p>static void do_api()
    4 {- I8 g' N9 ~0 R# Q  I: n  O) F
  36. {' s/ @6 k8 e- I0 `. h
  37. //list the components
    & o( e1 P1 \7 v8 x& x
  38.   Session *theSession = Session::GetSession();
    , ?* f) M. U+ l, u  W6 t, K
  39.   ListingWindow *lw = theSession->ListingWindow();; w( X+ E" Z- P' Z
  40.   lw->Open();4 T$ F+ z" Z  v: N3 f
  41.   Assemblies::Component * rootcomponent;
    " M1 H. ?! d' _2 S# A$ c* S% P* Y
  42.   Part *workpart;
    ; P8 E2 ^/ c# s2 ?; U- m
  43. rootcomponent = theSession->Parts()->Display()->ComponentAssembly()->RootComponent();, Y4 U+ i# P  Q/ T( t
  44. workpart = theSession->Parts()->Work();
    2 I& n) z# ]9 @; C% q
  45. lw->WriteLine("The workpart is : "+workpart->FullPath()+ "\n" );
    . @1 i0 y7 T/ ?% N8 u
  46. if(rootcomponent==NULL)
    ( y' ]& y7 U! |  |( k
  47. {  & Q* i' h/ e$ r- a6 a+ E. L: T
  48.     lw->WriteLine("The part is not an assembly ! \n " );
    , l. H7 T' Y4 P+ y/ R
  49. }4 w( `" J1 G2 Z7 f; y% G5 f/ w
  50. else- l& z' H' Y$ t8 i$ T2 ~
  51. {# E4 p- o- @+ Z( g1 J& O
  52.   lw->WriteLine("The rootcomponent is : " +  rootcomponent->DisplayName()+"\n");4 X5 w# U0 `- n) ]
  53.   lw->WriteLine("The children components are : \n");
    4 _- Q4 S( q2 Q# ~$ B
  54.      getchildren(rootcomponent,4);
    ' c. v! ^# g2 k1 q& P
  55. }</p><p>}
    5 n+ F0 a: Q) D' Q9 J
  56. </p><p> </p>
复制代码

0 z5 U( K  \9 V/ u4 `. r. s
该会员没有填写今日想说内容.
回复

使用道具 举报

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

    我知道了