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

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

[复制链接]

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

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

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

x
0 q) K; I2 `  u% D! o
NX二次开发源码: 使用NX OpenC++查询装配组件并判断加载状态: i' z1 c/ f% [. D/ q3 j8 F) [: H. E
" f, v* ~7 }5 [, C. d  A

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

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

! f( R# @0 o' k6 E8 n: n, `
  1. <p>static void geTChildren(Assemblies::Component *rootcomponent,unsigned int indent)2 r: N; c4 I: R: `1 v: E* |+ S
  2. {      
    1 Y( G  h' A* }: _$ Y
  3.   / h1 K0 L+ h8 ^8 S& t4 Z, c
  4.   unsigned int ii;: W1 V+ S1 o: f: _5 \& G8 ~
  5.   char space[MAX_LINE_SIZE+1] = { " " };. [; I" @2 b$ g% ^! C
  6.    for (ii = 0; ii < indent; ii++) strcat(space, " ");
    1 X$ H  L3 C2 T" u, n
  7.   std::vector<Assemblies::Component *>components;' |' J3 f4 K9 r5 P
  8.   Session *theSession = Session::GetSession();) K. N8 \9 B( a6 U8 s
  9.   ListingWindow *lw = theSession->ListingWindow();9 J( l  K6 n* C2 z7 A% x
  10.      lw->Open();
    # C" X0 Q5 _& l0 U$ o/ r. j, y
  11.   components = rootcomponent->GetChildren();' M7 o! ]- I$ x: G! N6 I2 q% Q
  12.       for (int i = 0 ; i <components.size();i++)2 d% L1 U! f" F$ w* K4 A
  13.       {2 a4 G8 \/ p5 \( [; ^3 f5 ]. k+ ^1 m
  14.        Part *childpart = dynamic_cast<Part*>(components[i]->Prototype());" d) }6 I/ ^* m: g, g+ I
  15.      ( P% v' S' L* f$ c5 ^1 y
  16.       if(childpart==NULL)
    - g5 i7 {; U. r: Y- {
  17.        {
    , a+ H* K" z/ e( G' N
  18.         lw->WriteLine(space+components[i]->DisplayName()+"\t"+"Status: not loaded!");
    & m3 G  _6 ~8 |: g% a! V. a6 G
  19.         }) i6 b% s: b  Q) b; t; y% s
  20.        else
    ' X! W0 o' Z/ X) z2 |
  21.        {# n! f$ V4 s3 I. s2 Q
  22.         if (childpart->IsFullyLoaded())
    . a. C' p8 b0 A2 w% f
  23.          {
    ! ?/ M& b4 }+ m5 h. V' j
  24.           lw->WriteLine(space+components[i]->DisplayName()+"\t"+"Status: IsFullyLoaded!");, D. |7 E) b% W; W. t' f; g9 y
  25.          }
    ( {5 D$ a+ N& j! }- T" b8 b
  26.         else  - P5 U6 O0 A7 x1 r1 R
  27.          {* O  q% U, T8 P! \& ]
  28.           lw->WriteLine(space+components[i]->DisplayName()+"\t"+"Status: IsPartiallyLoaded!");3 U) P: F) i" q- t; M5 j& l, V- L
  29.          }) n1 w" I: m: N5 h5 K: i! c% H
  30.         
    ; z, G& o; S) u: n' O1 Y" a$ m
  31.       & E9 a! v' H  H3 A5 i6 i
  32.         getchildren(components[i],indent+5);: x9 \3 o+ N) f1 a9 @2 {- m
  33.       }. F# g  a) `& ^# w* o- x
  34.       }; f% G, K; S$ Q& m+ Y
  35. }</p><p>static void do_api()
    ! E; \6 h4 A+ ]* o
  36. {
    ! F3 `- t: O4 H2 _* g
  37. //list the components
    ' K% X  |& S* U! x
  38.   Session *theSession = Session::GetSession();7 u$ g: i+ x4 i
  39.   ListingWindow *lw = theSession->ListingWindow();
    5 k" y6 ^- r8 Z+ Q
  40.   lw->Open();
    4 [  J% O  ~! k
  41.   Assemblies::Component * rootcomponent;$ X$ @4 k# o( ^2 h/ U( D. W
  42.   Part *workpart;
    ( ~+ @9 _4 }( F# h: w
  43. rootcomponent = theSession->Parts()->Display()->ComponentAssembly()->RootComponent();' W/ k' C* }0 z2 D% K
  44. workpart = theSession->Parts()->Work();
    % S" L1 {% U7 R
  45. lw->WriteLine("The workpart is : "+workpart->FullPath()+ "\n" );
    2 k8 I1 R3 {# c1 s
  46. if(rootcomponent==NULL)
    ) ]0 e' ^- X% f, \; E  e6 n3 S$ a$ l8 X
  47. {  4 n, E4 p1 G6 D
  48.     lw->WriteLine("The part is not an assembly ! \n " );
    ! O" T3 G+ C& B" Z+ n- `% B
  49. }" q' h. i& z( Z
  50. else
    ! L; r2 K9 S; G7 d
  51. {% C$ Z2 H! ~2 c, n+ _& ?4 J- D
  52.   lw->WriteLine("The rootcomponent is : " +  rootcomponent->DisplayName()+"\n");
    $ l3 m' u( `' k5 b3 B
  53.   lw->WriteLine("The children components are : \n");  V- q( [' n$ O  Z/ e& e
  54.      getchildren(rootcomponent,4);- ^6 v) k2 z1 ^+ k; a- N2 n6 X, G
  55. }</p><p>}0 S6 g1 z& K  ~+ H
  56. </p><p> </p>
复制代码
, Z. a3 ^/ Z+ o
该会员没有填写今日想说内容.
回复

使用道具 举报

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

    我知道了