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

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

[复制链接]

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

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

mildcat 楼主

2013-12-4 16:36:55

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

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

x

! K* M& z2 l9 _; n: b5 i0 b3 b# NNX二次开发源码: 使用NX OpenC++查询装配组件并判断加载状态
- H4 M( `, X% h. ~9 E5 C; B* h9 d

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

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

  p0 {& b; |. |6 E! ?' ]
  1. <p>static void geTChildren(Assemblies::Component *rootcomponent,unsigned int indent)
    5 _# J% J. q$ Q: O" }0 c
  2. {      
    : z) {& z$ \+ g' m+ J9 D
  3.   5 M$ G9 X" J4 J# T- Q2 R* n! S
  4.   unsigned int ii;
    ) U6 |: j* C7 S2 O5 e! g! X. C3 f
  5.   char space[MAX_LINE_SIZE+1] = { " " };
    5 g) y$ }2 I$ T3 }1 x+ \
  6.    for (ii = 0; ii < indent; ii++) strcat(space, " ");) E& O" a. C% w4 Z8 }& |" V
  7.   std::vector<Assemblies::Component *>components;. M6 U0 `( |, K3 Y$ l9 W
  8.   Session *theSession = Session::GetSession();
    + J4 G: y4 k: l) x8 s
  9.   ListingWindow *lw = theSession->ListingWindow();0 ]  ~0 ?) t0 n# o4 A% l% c
  10.      lw->Open();
    - T# @! E* t1 e- m% i7 L% A8 u4 \7 d# L
  11.   components = rootcomponent->GetChildren();
    7 E7 F. m* e. ]" g3 H9 R
  12.       for (int i = 0 ; i <components.size();i++)
    7 L4 l7 P' \( w
  13.       {
    , m+ t# ^4 {4 V: p) a
  14.        Part *childpart = dynamic_cast<Part*>(components[i]->Prototype());0 _6 `. \3 K4 o% y! r
  15.      ( ^! A" P7 b& M# ^% [7 A' r7 ]
  16.       if(childpart==NULL)* u# C0 M6 R- t) _+ R7 k
  17.        {& n5 i; r' X1 ~# E* _: }
  18.         lw->WriteLine(space+components[i]->DisplayName()+"\t"+"Status: not loaded!");
    $ f: {- j9 h& @! G/ f* z2 r
  19.         }: S& P# e+ J# N/ F4 X# V
  20.        else : W" ?2 q! n0 @' ]1 n+ Q
  21.        {
    0 V" _3 M9 _1 o# X! ]' n' k
  22.         if (childpart->IsFullyLoaded())" y* y. E. J5 Z$ Y- I' \0 N+ m! }
  23.          {
    ; O$ N; h; W+ k8 V3 |- C4 K. y. _
  24.           lw->WriteLine(space+components[i]->DisplayName()+"\t"+"Status: IsFullyLoaded!");
    0 W$ B; f6 e3 [" ?0 o
  25.          }' v, g4 z! |: U6 H) j; [+ F* [" {
  26.         else  ( {6 x, _0 B, P4 l4 p4 l
  27.          {  H1 a+ E$ Y+ {' ?9 p% X
  28.           lw->WriteLine(space+components[i]->DisplayName()+"\t"+"Status: IsPartiallyLoaded!");
    6 D& R) G, o' _4 A5 k
  29.          }
    ( i% w6 n( E; J
  30.           A2 j5 y# R) q5 t% y3 g
  31.       
    & \7 N+ M1 H8 Q; ?' k3 x
  32.         getchildren(components[i],indent+5);
    - d; }0 O* c# j, r# r
  33.       }
    : }* h# ~6 ]9 ~0 h
  34.       }( w- ^8 l8 e( [* u' |& \$ T: p4 v
  35. }</p><p>static void do_api()& n1 r6 @) b( l  X$ J
  36. {
    " }" G; [9 Z% E4 b
  37. //list the components+ ]) s3 r) _- y/ \; f
  38.   Session *theSession = Session::GetSession();6 y- ]2 c, a, r1 `# S- w2 {
  39.   ListingWindow *lw = theSession->ListingWindow();
    8 o6 O  f3 [- n$ R
  40.   lw->Open();1 v1 w+ v$ H4 y, {6 h
  41.   Assemblies::Component * rootcomponent;" j* u* F. U% z! W
  42.   Part *workpart;
    & a5 y0 T9 z. N5 t( D0 v; j8 T
  43. rootcomponent = theSession->Parts()->Display()->ComponentAssembly()->RootComponent();
    * e  E; [5 Z; G' C% T& D% \
  44. workpart = theSession->Parts()->Work();
    ; O' M2 r' w. Z" d8 O; _  }( x
  45. lw->WriteLine("The workpart is : "+workpart->FullPath()+ "\n" );
    # C8 A1 W; L9 z# q
  46. if(rootcomponent==NULL)
    & R% K4 P0 V, C9 y
  47. {  
    " q" h* K8 E- X3 L
  48.     lw->WriteLine("The part is not an assembly ! \n " );
    - ~" `7 p2 _/ X' n# T1 h
  49. }
    2 _% }) f6 S1 @; D
  50. else
    ' |4 u+ D# k+ O" l; z
  51. {$ M3 R) v) ]3 r3 t
  52.   lw->WriteLine("The rootcomponent is : " +  rootcomponent->DisplayName()+"\n");
    . b* L2 N+ S* g
  53.   lw->WriteLine("The children components are : \n");
    ) d+ j8 e% l( {4 s: ?
  54.      getchildren(rootcomponent,4);+ q% M- P8 M; z) f8 m+ C- n
  55. }</p><p>}8 F& e7 W7 t1 D3 c
  56. </p><p> </p>
复制代码

- ^2 G6 [# O& q- a9 v7 n
该会员没有填写今日想说内容.
回复

使用道具 举报

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

    我知道了