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

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

[复制链接]

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

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

mildcat 楼主

2013-12-4 16:36:55

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

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

x

+ ?( Y% f4 H- ANX二次开发源码: 使用NX OpenC++查询装配组件并判断加载状态) b* @1 M" {! Z4 v7 l+ `3 K# X, D
6 ~! U1 E" g$ o; }% J- W- B

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

NX二次开发源码: 使用NX OpenC++查询装配组件并判断加载状态
0 B% W0 n1 `2 h, p
  1. <p>static void geTChildren(Assemblies::Component *rootcomponent,unsigned int indent)
    7 v! B' }/ G0 h
  2. {      
    - `. l: f% R7 \7 e# P6 s
  3.   
    # A9 u/ I$ y0 b# y, b  d
  4.   unsigned int ii;2 U* ~& ~* q: C
  5.   char space[MAX_LINE_SIZE+1] = { " " };# F$ A. y( ~; ^8 f$ s: R' n% Q; s
  6.    for (ii = 0; ii < indent; ii++) strcat(space, " ");/ h/ \* T9 C/ m1 e: M
  7.   std::vector<Assemblies::Component *>components;2 L* X% ?; B( {! b3 T7 w
  8.   Session *theSession = Session::GetSession();8 D% |9 I2 ?) ?
  9.   ListingWindow *lw = theSession->ListingWindow();; U$ d1 G: g7 O* ?
  10.      lw->Open();
    : N3 B$ L; g+ }( N
  11.   components = rootcomponent->GetChildren();
    : S# z( s' g, y" R0 a9 R; I
  12.       for (int i = 0 ; i <components.size();i++)
    ' O" U5 s& a2 y# _
  13.       {
    0 T( F: O2 t, v9 @
  14.        Part *childpart = dynamic_cast<Part*>(components[i]->Prototype());. e0 z* u( d/ N
  15.      
    + Z( Z' A4 ~* m* I3 ]. z2 n: ?: Y
  16.       if(childpart==NULL)
    ) R/ u. Z( ?9 K' z/ `  G8 K! S5 g
  17.        {
    + e+ ]* Z9 w( b; |
  18.         lw->WriteLine(space+components[i]->DisplayName()+"\t"+"Status: not loaded!");: ]9 {5 @- F. f7 A
  19.         }+ G1 Y* G. s( x7 D
  20.        else " y) U* P' B, ]  f8 K( b$ P
  21.        {& v: `, |8 y; N- \- N% Z$ ]% {
  22.         if (childpart->IsFullyLoaded())' R0 g; y! m0 q
  23.          {5 W) v4 f3 G, B$ M" ~- L! ^
  24.           lw->WriteLine(space+components[i]->DisplayName()+"\t"+"Status: IsFullyLoaded!");7 t2 Q- _8 f) q
  25.          }
    / w: D+ j: m* D4 S+ s
  26.         else  ( O, m% k( Z. g
  27.          {0 K: o9 d3 T# b9 [# O
  28.           lw->WriteLine(space+components[i]->DisplayName()+"\t"+"Status: IsPartiallyLoaded!");
    8 H; y1 G, l6 q2 U. T1 B/ N1 o
  29.          }' q( N- P4 [* k. |, I) z
  30.         
    9 [! w4 o+ L( V8 L" I
  31.       
    # q2 m( b8 f' f) B
  32.         getchildren(components[i],indent+5);2 b9 t1 n! J4 h* o  I
  33.       }
    ! X+ I/ T% R) U; t1 J
  34.       }, C5 X( Z# m6 c
  35. }</p><p>static void do_api()
      |6 R( M3 V* @& o
  36. {7 k! b$ U$ |1 P
  37. //list the components% H- c8 t; o0 }
  38.   Session *theSession = Session::GetSession();0 f4 O: k' B1 X6 `. y9 C' l
  39.   ListingWindow *lw = theSession->ListingWindow();2 G' F" d; D3 w% |
  40.   lw->Open();% u. s! X1 o0 _( o
  41.   Assemblies::Component * rootcomponent;$ u+ Y. y* h7 r% `) q
  42.   Part *workpart;
    2 m7 z' K3 r7 r& S% N$ a
  43. rootcomponent = theSession->Parts()->Display()->ComponentAssembly()->RootComponent();
    6 H; j" L3 A* f5 N! K
  44. workpart = theSession->Parts()->Work();, ~; i& o! Q. q0 R( X% ], l+ @' m
  45. lw->WriteLine("The workpart is : "+workpart->FullPath()+ "\n" );- Q' z0 _- W% U# K8 k  J# W, {6 C) l
  46. if(rootcomponent==NULL)
    / \8 ^7 u  J9 u: K3 `
  47. {  : j: {; r5 U3 t+ H$ ^: G' P
  48.     lw->WriteLine("The part is not an assembly ! \n " );
    3 \  m8 J  y$ j: W4 q
  49. }
    8 |. ?% I( Y7 l, k) }) R# T$ N
  50. else
    2 k* J& C0 [" |$ F) x9 W
  51. {. V, c; m" d+ n) q
  52.   lw->WriteLine("The rootcomponent is : " +  rootcomponent->DisplayName()+"\n");8 h* X' ~6 m! f: P! W* N- N
  53.   lw->WriteLine("The children components are : \n");3 _/ I2 p; _. j1 F7 S2 ~
  54.      getchildren(rootcomponent,4);4 ?5 a/ r( ]3 e5 J
  55. }</p><p>}, e5 @) j$ e$ X  T& I$ c' y: l6 X
  56. </p><p> </p>
复制代码

8 Z, u  [+ ^9 q# ^% ^7 x
该会员没有填写今日想说内容.
回复

使用道具 举报

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

    我知道了