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

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

[复制链接]

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

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

mildcat 楼主

2013-12-4 16:36:55

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

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

x
" j/ ]7 c6 J* h
NX二次开发源码: 使用NX OpenC++查询装配组件并判断加载状态
- J- ^' h: w8 K  t1 k4 |) Q
, F. i1 u; j3 O0 t

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

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

2 j! b/ N! o! s$ z( H( z
  1. <p>static void geTChildren(Assemblies::Component *rootcomponent,unsigned int indent)
    8 v8 c8 e; i$ n9 {) n% W! h
  2. {         M1 ~* V" V" e$ {% c
  3.   
    ! |+ `, s4 C; X: |" U) m
  4.   unsigned int ii;9 z* z- {1 N: u; Q2 D
  5.   char space[MAX_LINE_SIZE+1] = { " " };% i$ g" ^; G6 d9 J
  6.    for (ii = 0; ii < indent; ii++) strcat(space, " ");6 l3 s& L1 T# g' I; @
  7.   std::vector<Assemblies::Component *>components;
    * o. ~& G- h) j% q- R
  8.   Session *theSession = Session::GetSession();
    + Q7 c/ L" d9 T! N
  9.   ListingWindow *lw = theSession->ListingWindow();
    8 v$ B2 t8 ^8 g
  10.      lw->Open();5 E1 {0 ?( X8 r
  11.   components = rootcomponent->GetChildren();
      S7 T5 ?; Q+ L3 S* ?; C
  12.       for (int i = 0 ; i <components.size();i++)
    ; `5 [: ?! V* o8 k* h" {; w" \
  13.       {  P" E1 k% t& s( \9 ^0 [4 ^& d
  14.        Part *childpart = dynamic_cast<Part*>(components[i]->Prototype());
    * o& a" Y) ~6 a0 |7 b7 E
  15.      
    + `% A# o$ w) N0 R0 g; N8 r
  16.       if(childpart==NULL)1 U) i& F& `. B) T  s
  17.        {; V5 S0 w% {) q$ I. V& b
  18.         lw->WriteLine(space+components[i]->DisplayName()+"\t"+"Status: not loaded!");
    % M2 ~' F3 ~9 V7 z
  19.         }
    8 y* k, K* Z( ]! }, r' M
  20.        else
    $ C3 P" M  c7 Z" `2 z' ~  v
  21.        {7 `1 {  b! s; F" D, Q1 s, ?: ^8 P2 ?. a
  22.         if (childpart->IsFullyLoaded())
    9 y2 Q8 O( C7 z0 L# h) K
  23.          {
    ; _' ]5 [$ F0 `
  24.           lw->WriteLine(space+components[i]->DisplayName()+"\t"+"Status: IsFullyLoaded!");9 K% i; e; T1 W8 N1 |- V9 K
  25.          }6 k) w" v. K" E' j8 o
  26.         else  / F" _& c& N! C) k5 I. r2 p
  27.          {
    ( w* u0 @6 y. S" k' p
  28.           lw->WriteLine(space+components[i]->DisplayName()+"\t"+"Status: IsPartiallyLoaded!");2 u* D: w! ^  Q# o4 `( e
  29.          }7 w2 [- V% q3 i- r$ u/ w* C  i
  30.         * Y& k6 @2 T. j% N% c7 a
  31.       
    3 \& t8 ]  c& R5 J& c0 v
  32.         getchildren(components[i],indent+5);
    : ]0 E/ @' a' P3 e
  33.       }
    . O' ?$ l5 W4 {8 S) w
  34.       }) L& x  h+ l! _, Q4 ]2 |$ J. i
  35. }</p><p>static void do_api()
    . @! d# G' _9 S, @: V0 F& g
  36. {
    + v  |, Z/ v; X
  37. //list the components
    8 U4 y' c' X6 v2 z% A- j( W
  38.   Session *theSession = Session::GetSession();
    / `' M' {- t" M$ A) {% S
  39.   ListingWindow *lw = theSession->ListingWindow();' k4 X6 a( J7 }' w; C  u8 ]! c, e
  40.   lw->Open();
    3 U9 _3 E; S: y, H) X$ b' I
  41.   Assemblies::Component * rootcomponent;
    * {! @& F. U4 Q* B
  42.   Part *workpart;
    ( ~4 U+ V" ~4 b8 f2 O  {5 `! h
  43. rootcomponent = theSession->Parts()->Display()->ComponentAssembly()->RootComponent();
    9 B2 H% S* L8 A, ?8 A1 h
  44. workpart = theSession->Parts()->Work();
    + F) n5 w. o' x9 C
  45. lw->WriteLine("The workpart is : "+workpart->FullPath()+ "\n" );1 c' L# j0 G6 ^3 C5 @! ^) u- R7 q
  46. if(rootcomponent==NULL)
    # O- u6 H1 Y4 ?+ I, \
  47. {  
    ' S  y2 e- I7 ?9 p1 f. T  W
  48.     lw->WriteLine("The part is not an assembly ! \n " );
    . [: c! D9 Y+ r2 r$ ^3 r$ Q
  49. }, T( Z% S2 W9 w9 ?
  50. else
    9 V) h+ @( }. N8 }: M5 o+ d/ g
  51. {, r3 Z1 f$ b$ B8 r
  52.   lw->WriteLine("The rootcomponent is : " +  rootcomponent->DisplayName()+"\n");
    4 |0 ~" u- V5 R* g' Y; K
  53.   lw->WriteLine("The children components are : \n");
    6 R7 ~( o+ {  P
  54.      getchildren(rootcomponent,4);$ N# h) V9 E6 |- O
  55. }</p><p>}* C( |" i8 }) s; D
  56. </p><p> </p>
复制代码

& P+ p) c* W% Y4 `+ b) p
该会员没有填写今日想说内容.
回复

使用道具 举报

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

    我知道了