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

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

[复制链接]

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

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

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

x
  n; V4 b: a2 [5 U
NX二次开发源码: 使用NX OpenC++查询装配组件并判断加载状态- W3 b, s" h, B1 b
) q. f, T) `# Z5 x3 G

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

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

0 U& l4 b, Z3 i
  1. <p>static void geTChildren(Assemblies::Component *rootcomponent,unsigned int indent)
    1 j6 y( Z! G: ~3 U9 W/ F+ T
  2. {      
    5 K; |" d: C1 D' X6 L
  3.   
    / p. [' Z6 j+ _
  4.   unsigned int ii;8 i* K% e5 ~! r. \: F
  5.   char space[MAX_LINE_SIZE+1] = { " " };. [8 m3 B( n- e- U
  6.    for (ii = 0; ii < indent; ii++) strcat(space, " ");) w& r& ~7 v* c" s  k/ U
  7.   std::vector<Assemblies::Component *>components;
    6 a7 K2 j. ~" q% f/ t% V
  8.   Session *theSession = Session::GetSession();/ e1 h4 N, n8 K3 ~
  9.   ListingWindow *lw = theSession->ListingWindow();
    * @0 G8 {( Y# V) c' {) o
  10.      lw->Open();
    & i0 I; ]9 l1 ]& e7 F
  11.   components = rootcomponent->GetChildren();; U' z( i2 o. F' ~
  12.       for (int i = 0 ; i <components.size();i++)* F$ r* s- n& j( j  e% G
  13.       {
    : l8 D- x$ X4 C+ i4 a( V1 h
  14.        Part *childpart = dynamic_cast<Part*>(components[i]->Prototype());$ k6 n- R) ^8 n6 D6 \
  15.      ( ~9 E" N1 }# ]7 D7 }( _
  16.       if(childpart==NULL)) d9 v- B* ~# f8 t2 M' |1 p7 j$ s
  17.        {
    ) s; h' F2 G$ i- Y- _% \$ c: H
  18.         lw->WriteLine(space+components[i]->DisplayName()+"\t"+"Status: not loaded!");
    7 w3 r6 i4 l2 p, t+ g8 p# K) m& [! I2 F5 X
  19.         }
    $ M; w1 c' b4 [
  20.        else 0 Y4 Q8 p& a/ Q" t$ K5 n
  21.        {/ W' I: s  q2 c
  22.         if (childpart->IsFullyLoaded())
    & c  Z# \: L. I6 ]: f, f
  23.          {
    1 {( x% E3 x1 u
  24.           lw->WriteLine(space+components[i]->DisplayName()+"\t"+"Status: IsFullyLoaded!");
    % K, A8 k/ w# g+ q# s  `' @
  25.          }8 d" d- p. k' f" h
  26.         else  * k9 I8 I" d: p  B# p% @" L+ m
  27.          {
    % S1 }3 H  L1 r: P( v  Z, H
  28.           lw->WriteLine(space+components[i]->DisplayName()+"\t"+"Status: IsPartiallyLoaded!");. D, H) S. I! o; v0 c
  29.          }
    2 x5 A! S2 y+ [% C+ L! w' _4 w
  30.         5 z  K- \/ a- m- Z8 c1 u7 B
  31.       ! Z2 G7 d& {1 G& Y
  32.         getchildren(components[i],indent+5);
    - y8 N: k: M) J& d! \! `
  33.       }
    # Q" h, x8 I+ O9 Y
  34.       }% x% W3 p- g9 e
  35. }</p><p>static void do_api()
    ) `4 b5 S8 z6 t3 I# ]
  36. {
    & f& B& r% z% L, f0 L7 K5 J0 V
  37. //list the components
    # }+ A1 Y, r( D
  38.   Session *theSession = Session::GetSession();
    ( Q2 Y/ E0 w  G1 o8 ~8 E3 R* @
  39.   ListingWindow *lw = theSession->ListingWindow();) I$ r  L) o# R0 z
  40.   lw->Open();7 F) S2 w( r% J7 ?1 R4 n& a
  41.   Assemblies::Component * rootcomponent;
    ) t& d$ p0 g9 N; r
  42.   Part *workpart;6 O: }* d" [0 F* S& |! h& J0 p, v
  43. rootcomponent = theSession->Parts()->Display()->ComponentAssembly()->RootComponent();' v5 Y8 J+ l1 ]1 C" A) M; L$ g
  44. workpart = theSession->Parts()->Work();
    , K5 W. ?7 n/ e) Q
  45. lw->WriteLine("The workpart is : "+workpart->FullPath()+ "\n" );
    ( E6 N, M+ B8 S7 c( s3 B
  46. if(rootcomponent==NULL)
    / \, e/ c/ G& _6 R
  47. {  ; `% j. {: ?7 o+ W
  48.     lw->WriteLine("The part is not an assembly ! \n " );
    + M2 f$ ~. Y( u
  49. }
    & K+ p4 w9 w* @
  50. else4 x; G4 l4 v" V4 J4 y9 O' h
  51. {( f5 T; @" ]+ R7 Y% E' w! L
  52.   lw->WriteLine("The rootcomponent is : " +  rootcomponent->DisplayName()+"\n");2 J: r& l6 V8 o- {
  53.   lw->WriteLine("The children components are : \n");
    ) s+ R" m9 U' R$ Q: ]: }! f: f
  54.      getchildren(rootcomponent,4);
    2 g& P- k2 G1 j* }
  55. }</p><p>}
    / ?. C1 W) h, ~5 S# m" q; f7 k! O/ F: P- H
  56. </p><p> </p>
复制代码

' @+ \/ c5 n* X* i( i
该会员没有填写今日想说内容.
回复

使用道具 举报

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

    我知道了