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

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

[复制链接]

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

320

主题

226

回帖

9784

积分

管理员

PLM之家NX|TC专家

积分
9784
发表于 2013-12-4 16:36:55 | 显示全部楼层 |阅读模式

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

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

x
% z  B5 m# S8 @0 j1 ~2 V2 \
NX二次开发源码: 使用NX OpenC++查询装配组件并判断加载状态8 c8 S5 m/ P$ C
* |  \3 c4 {; B& v, O

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

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

$ H! T  s7 r! o% r8 w3 [. S* O, b
  1. <p>static void geTChildren(Assemblies::Component *rootcomponent,unsigned int indent)
    , l' `. k$ c5 y
  2. {      
    " c; e  ]6 d; U+ n
  3.   6 Y- K& J! f" h+ J
  4.   unsigned int ii;# K* V9 Y& s3 q2 e# W/ B# R' D
  5.   char space[MAX_LINE_SIZE+1] = { " " };
    3 c% P% H& \' _
  6.    for (ii = 0; ii < indent; ii++) strcat(space, " ");8 [8 |- ?$ f- A: P  q
  7.   std::vector<Assemblies::Component *>components;" C7 s. v6 J( \. T. i* Q& [
  8.   Session *theSession = Session::GetSession();
    5 O' U! d2 N0 \
  9.   ListingWindow *lw = theSession->ListingWindow();
    * l3 U8 R+ X  h' y
  10.      lw->Open();
    # r( [2 i9 E2 B/ M4 @
  11.   components = rootcomponent->GetChildren();2 P8 {/ d% P+ i3 P/ L
  12.       for (int i = 0 ; i <components.size();i++)
    , I$ ~' e" y3 b/ h
  13.       {
    0 J+ {; z7 B+ X. s% s
  14.        Part *childpart = dynamic_cast<Part*>(components[i]->Prototype());: w3 p+ n# u* W$ U9 A
  15.      " L2 @# H; W" ^9 \1 ~* s2 c! ?
  16.       if(childpart==NULL)
    : D% t4 R( D5 F) d- e
  17.        {. c3 n+ v' S+ Z" C
  18.         lw->WriteLine(space+components[i]->DisplayName()+"\t"+"Status: not loaded!");! H% F9 Z  s* l6 D/ N: X, [
  19.         }/ H# i) r& C* p+ ]' X% ?- h, J; G% G
  20.        else ; h# U/ y, ?, s$ ]( J
  21.        {
    6 H5 Z$ U: F- a; N
  22.         if (childpart->IsFullyLoaded()). G' e; _- S' s( g, ?0 R
  23.          {
    5 T) _. ]8 L; C! i
  24.           lw->WriteLine(space+components[i]->DisplayName()+"\t"+"Status: IsFullyLoaded!");1 c6 t5 x  ?& H* \9 n# _7 \
  25.          }
    % Y/ a: f, A" G: D7 K0 r5 V
  26.         else  % o1 \  C: Q5 M/ X. V
  27.          {7 o; ~& P* ?: o& G
  28.           lw->WriteLine(space+components[i]->DisplayName()+"\t"+"Status: IsPartiallyLoaded!");5 ?  Q, G5 Y% n8 ?/ i
  29.          }
    9 T8 z% }/ \2 i' Y& [7 r
  30.         
    1 n9 ?2 N( s9 G/ M
  31.       3 t& {  t* F/ Z0 a  I, Y' j
  32.         getchildren(components[i],indent+5);
    6 j" x5 `1 [% w) j! c; f
  33.       }3 a, N5 w- D, [2 m( B1 [7 H
  34.       }
    , G* t/ u: v6 F3 j
  35. }</p><p>static void do_api()
    * A4 f$ M* x3 L* w. u
  36. {& X) D- c" @; f% ~) ~
  37. //list the components
    . Z' m2 T( N6 X+ Q' t3 k( D' |5 K- r
  38.   Session *theSession = Session::GetSession();
    " \2 h- N) |; o% O7 L5 ^
  39.   ListingWindow *lw = theSession->ListingWindow();
    + u! z" |1 u3 e  T* I
  40.   lw->Open();: D& S% C" q) c. l
  41.   Assemblies::Component * rootcomponent;6 F. e, T4 V) I9 S! z. Q
  42.   Part *workpart;' B8 M' c6 d; o
  43. rootcomponent = theSession->Parts()->Display()->ComponentAssembly()->RootComponent();
    1 d7 j9 w4 A# H/ J
  44. workpart = theSession->Parts()->Work();- K$ \4 O/ m0 Q: x4 B0 S; L
  45. lw->WriteLine("The workpart is : "+workpart->FullPath()+ "\n" );  c! H- Z: R& P  Q0 F
  46. if(rootcomponent==NULL)0 y4 t; i9 @- j3 Z. f
  47. {  
    - B) E+ B+ H+ v2 |. L# b
  48.     lw->WriteLine("The part is not an assembly ! \n " );
    # D  V0 f) x% T0 [+ g/ k$ }
  49. }
    $ D" a+ w: X: f' L3 h! y
  50. else% e( i& D, U, F) N& ?9 E) Y6 w) G, W
  51. {
    " B# @$ t1 i* Z. }8 h/ }
  52.   lw->WriteLine("The rootcomponent is : " +  rootcomponent->DisplayName()+"\n");" {4 l/ ?7 {: e) Z0 H# N
  53.   lw->WriteLine("The children components are : \n");
    " e7 z$ m* f% o# i, x# w
  54.      getchildren(rootcomponent,4);
    . k/ U$ B: }+ t) {3 f- ?% j9 d. ]; P+ k
  55. }</p><p>}5 J+ b' s( b- \( c# n# |' Q4 F
  56. </p><p> </p>
复制代码
- ^, l, f! d& }1 u0 T& f* f
该会员没有填写今日想说内容.
回复

使用道具 举报

全部回复1

7

主题

31

回帖

170

积分

注册会员

积分
170
发表于 2013-12-8 00:59:17 | 显示全部楼层
嗯,这个不错
上海点团信息科技有限公司,承接UG NX,CATIA,CREO,Solidworks 等CAx软件,Teamcenter,3D Experience等PLM软件,工业4.0数字化软件的实施\二次开发\培训相关业务,详情QQ 939801026 Tel 18301858168 网址 www.doteam.tech
回复 支持 反对

使用道具 举报

发表回复

您需要登录后才可以回帖 登录 | 注册

返回列表 本版积分规则

  • 发布新帖

  • 在线客服

  • 微信

  • 客户端

  • 返回顶部

  • x
    温馨提示

    本网站(plmhome.com)为PLM之家工业软件学习官网站

    展示的视频材料全部免费,需要高清和特殊技术支持请联系 QQ: 939801026

    PLM之家NX CAM二次开发专题模块培训报名开始啦

    我知道了