PLM之家精品课程培训,联系电话:18301858168 QQ: 939801026

  • NX二次开培训

    NX二次开培训

    适合初级入门或想深入了解二次开发的工程师,本培训结合ufun,NXOpen C++,大量的实例及官方内部的开发技术对于老鸟也值得借鉴!.

    NX CAM二次开发培训报名 NX二次开发基础培训报名
  • PLM之家Catia CAA二次开发培训

    Catia二次开发培训

    Catia二次开发的市场大,这方面开发人才少,难度大。所以只要你掌握了开发,那么潜力巨大,随着时间的积累,你必将有所用武之地!

  • PLM之Teamcenter最佳学习方案

    Teamcenter培训

    用户应用基础培训,管理员基础培训,管理员高级培训,二次开发培训应有尽有,只要你感兴趣肯学习,专业多年经验大师级打造!

  • PLM之Tecnomatix制造领域培训

    Tecnomatix培训

    想了解制造领域数字化吗?想了解工厂,生产线设计吗?数字化双胞胎,工业4.0吗?我们的课程虚位以待!

PLM之家PLMHome-国产软件践行者

Catia二次开发源码分享: 获取装配所有组件列表

[复制链接]

2018-1-10 10:12:25 2358 0

admin 发表于 2018-1-10 10:12:25 |阅读模式

admin 楼主

2018-1-10 10:12:25

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

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

x

# H- q) k* G/ ^4 S+ [4 d/ f4 s6 `Catia二次开发源码分享: 获取装配所有组件列表4 b! g) k, x. y& `1 q6 ^3 c  ?9 n
; Q; P2 T7 d- R8 M( }) z, r

2 C) g, Q& i/ {" s/ n4 z[mw_shl_code=c,true]/* ----------------------------*/$ b$ y' T, H9 c+ w) G; Q: a& r5 m
        /* 2. Retrieves Root Product   */
- }! B9 ~4 T1 _! c# n2 }. {        /* ----------------------------*/: y" ^9 U* ]( i
        4 m2 l' m! ]( L: @( m) F
        // Begin navigation throUGh the document => start with the RootProduct.
( q1 X4 ]) K* h% J& t        CATIDocRoots* piDocRootsOnDoc = NULL;
# J' _" ]8 m" Y; c) z) e' T        rc = pDoc->QueryInterface(IID_CATIDocRoots,
* p5 z8 Q/ L5 |7 I# r0 r% g                                      (void**) &piDocRootsOnDoc);* r, k/ G- k6 c( _9 r
        if ( FAILED(rc) ) return 3;
- y+ O& E+ J8 a       
% a$ X% n4 h* q+ p        // get the root product which is the first element of root elements
( l! W# E# z: e        CATListValCATBaseUnknown_var* pRootProducts = 3 n$ V* o, w2 W9 k; E1 x/ Y
                piDocRootsOnDoc->GiveDocRoots();0 m4 i2 O+ p' M
        CATIProduct_var spRootProduct = NULL_var;8 u) M* P" e6 e1 Q) h9 x
        9 H9 s6 A& C5 n, k- ?# _' B4 ^7 r7 I' C$ P
        if (pRootProducts && pRootProducts->Size())8 n( h: d# w0 c- S1 A
        {  - s, |8 l1 n6 b! a# _! d' T. q
                spRootProduct = (*pRootProducts)[1];
( r) W' p. t- h) c0 J# x) C$ k                delete pRootProducts;
$ N4 F. b+ |- {% m8 E  F                pRootProducts = NULL;+ o6 H6 `* Z' ]$ Z# q4 g
        }$ K/ s) K' v' I8 o
/** @anchor err_1 piDocRootsOnDoc not set to NULL after release */
% K7 e% z0 J4 \1 \  r' w        piDocRootsOnDoc->Release();
; R- j& U, E5 H- n9 @; |8 M9 K        piDocRootsOnDoc = NULL;! Q& c! R& e& }' k- R4 h! i% R
        7 S# T% Q. h: a& o8 U9 i
        // Get CATIProduct handle on the root product.
  _* q6 k0 I* Q6 k        CATIProduct *piProductOnRoot = NULL;
1 Z2 c  p  q; F4 [0 @        rc = spRootProduct->QueryInterface(IID_CATIProduct,) X  ]. z  z- l5 l! H
                                               (void**) &piProductOnRoot);* R- g) L& Q5 K, J3 \8 T
        if ( FAILED(rc) ) return 3;
0 @7 G- y6 L- T7 S1 F( {: a+ F$ W; T" ]6 n
        /* ---------------------------------------*/
, x( f5 |( V1 R$ _! `2 y1 ~  d        /* 3. Retrieves children under the root   */
+ l- h0 J4 d. T2 Q$ I        /* ---------------------------------------*/( T& W: A! T! @6 B, I1 J, n7 z
       
( M' w% Z: W% t. }9 Y- m0 i; Y  R0 K4 U        int nbOfDirecTChidren = piProductOnRoot -> GetChildrenCount() ;# c+ U- z8 N- ~. c
        cout << " Number of direct children under the root = " << nbOfDirectChidren << endl << flush;0 d: b( |# b6 r4 N% u( b5 U
        1 U/ b7 P+ o) K
        // then on a root product, get all the children agregated to it.5 A  a' E/ L/ X2 g
        CATListValCATBaseUnknown_var*   ListChildren =
8 M& u* x& b0 h                piProductOnRoot->GetAllChildren();; V' h  g: Y/ ]( W& |) }
/** @anchor err_2 piProductOnRoot not set to NULL after release */
# ~6 d. I4 C+ Z" g- e( B        piProductOnRoot -> Release();
3 g. y& k0 ?' G  T3 C7 Z        piProductOnRoot = NULL;
9 f# F) t) f- |        if(NULL != ListChildren)1 H/ Y# O6 ?: `$ o5 S' m( T
        {: x& L9 x0 O, n! `% s1 c. G
               
- T  f* I* a+ k- i7 G. T; T                int numberOfChildren = ListChildren->Size();
* X2 M+ a0 S; _5 N9 h% f                cout << " Number of all children under the root = " << numberOfChildren << endl << flush;  F2 X; E) X) g' E7 P7 z( m% b
# U0 s, {* i: ]. M/ n9 i
                /* -----------------------------------------------------------*/
1 h( z2 x7 V! h8 G) E: r                /*  4. For each child, get its partNumber, and InstanceName   */) {, V. ^6 m; b( h8 s  [
                /* -----------------------------------------------------------*/0 G/ b2 F  U! o, s5 w
                CATIProduct_var spChild = NULL_var;4 g7 I8 D3 {2 o
                for (int i=1;i<=numberOfChildren;i++)+ a+ c/ W9 j% U* A
                {
# }5 |6 V5 L* H8 n" _. D* L5 D                        spChild = (*ListChildren);" _: L5 M0 g# S7 t; E! }
/** @anchor err_3 spChild not tested before use ( if !! ) */ 7 F7 F9 j- ?# `
                        if ( NULL_var == spChild ) return 4;
4 H* X. L$ c: Y* h5 e' J* F5 @                        CATUnicodeString partNumber = spChild -> GetPartNumber();
! g) Y" Y" V0 m. N8 f) q+ h9 o                        CATUnicodeString instanceName (" ");( U5 S7 w# N4 ~5 \+ Y
                        rc = spChild -> GetPrdInstanceName ( instanceName ) ;
6 }# B6 l# l% l7 Q% C' o) |                        if  ( FAILED(rc) ) return 4;
' Y& |( t3 C; i# P( C                        8 ]6 |% ^7 f, ?! ?) L2 ^& h6 F5 b
                        cout << " child number : " << i << endl << flush;: l, _* d3 ~3 h7 h
                        cout << " has as part number : " << partNumber.CastToCharPtr()  << endl << flush;) w, X; N: H4 y
                        cout << " and as instanceName : " << instanceName.CastToCharPtr() << endl << endl << flush;
1 |, d; o$ @4 F9 I                }) D+ ~, ^) p- l) L! b6 C6 \
                delete ListChildren;
6 \6 T% Q( W( d) ~' J                ListChildren=NULL;6 i: g8 \( a1 E2 H" q- X
        }       
7 `# }8 ~# g2 ~        /* -------------------------------------------- */2 k, W4 T( R, F7 H, B) q5 o
        /*   Ends the session                        */
- [6 v. Q$ s; j7 J* ?9 l        /* -------------------------------------------- */[/mw_shl_code]
2 h5 `0 s4 K& d  ~" x) g
上海点团信息科技有限公司,承接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二次开发专题模块培训报名开始啦

    我知道了