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 2166 0

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

admin 楼主

2018-1-10 10:12:25

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

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

x
- A. @1 |( Z. `9 F2 r/ |' r' X
Catia二次开发源码分享: 获取装配所有组件列表
0 s& D8 R  s3 K) r6 s% Z
1 z& [) F6 n7 S2 \6 |! ?9 j* E( K- E
& a) ]7 M  I# D6 N[mw_shl_code=c,true]/* ----------------------------*/
! x& R5 Q) r3 t/ O* ?        /* 2. Retrieves Root Product   */
* a$ h' a. O) |# e        /* ----------------------------*/2 j0 \# o" J$ ?
        % T$ b5 A. }; B- G% R- n
        // Begin navigation throUGh the document => start with the RootProduct.# u* d8 u/ A1 H; B1 |: {" ~% G4 {0 n
        CATIDocRoots* piDocRootsOnDoc = NULL;
+ r. }; j* R6 U        rc = pDoc->QueryInterface(IID_CATIDocRoots,  ]$ o  e! x6 d
                                      (void**) &piDocRootsOnDoc);
8 T( @3 p+ p: n( s4 V5 j        if ( FAILED(rc) ) return 3;  c: x6 d* M* S0 y! b# D
        7 t8 K: K& i) H% g5 k2 Y3 t7 k
        // get the root product which is the first element of root elements6 Q0 Z9 D/ i3 v0 X/ L" n6 g
        CATListValCATBaseUnknown_var* pRootProducts =
3 n$ `8 C2 Q4 h- P7 E' o3 b                piDocRootsOnDoc->GiveDocRoots();
( Q6 n' g6 R( H* V, c        CATIProduct_var spRootProduct = NULL_var;
' e. O8 @3 Q0 d. s9 x! y        ( E! h2 r2 a1 _: r* [7 E
        if (pRootProducts && pRootProducts->Size())
1 Z* D( C, |' c+ c8 U/ x* P* c        {  
" j( S1 e4 d# O+ k/ Y( D                spRootProduct = (*pRootProducts)[1];7 M9 ~& ^) V0 B2 Z2 r
                delete pRootProducts;
3 r% ]8 K: k5 K+ D! j5 o                pRootProducts = NULL;
1 f' s8 q+ T1 I4 H! |        }/ _$ H5 K: Y$ P8 W$ T: ~
/** @anchor err_1 piDocRootsOnDoc not set to NULL after release */
2 j4 c7 R' }5 F0 S$ h        piDocRootsOnDoc->Release();
0 Z' T: I" r; d! }# }        piDocRootsOnDoc = NULL;7 n. Q5 u/ @! o, R
        & A) D4 O4 j* h. m; J
        // Get CATIProduct handle on the root product.( w. F% D1 J6 M  S# A3 E' n/ G
        CATIProduct *piProductOnRoot = NULL;
- y; C5 Q7 L6 F7 Q# I0 B        rc = spRootProduct->QueryInterface(IID_CATIProduct,; w- ?  J- h# y
                                               (void**) &piProductOnRoot);
; [5 p* E- m0 o# I! \        if ( FAILED(rc) ) return 3;7 R5 y) C2 Y  h- ]
3 n& S  F6 ]4 s8 d  u7 v$ S
        /* ---------------------------------------*/
. O$ l% h) R, T" x5 C1 h        /* 3. Retrieves children under the root   */& B% P) q( `2 ~
        /* ---------------------------------------*/
3 [8 F3 h7 ^5 ]% R$ I: B        ; D3 v" G! f: M8 w4 r) t+ i* H
        int nbOfDirecTChidren = piProductOnRoot -> GetChildrenCount() ;( P# i: n! x! z1 E, u& i) T. f
        cout << " Number of direct children under the root = " << nbOfDirectChidren << endl << flush;3 z7 i4 q  y& A+ k% I# F4 i
        0 f; l! o' d4 A, _
        // then on a root product, get all the children agregated to it.
; r/ x/ w! `1 S2 N! |9 a" p        CATListValCATBaseUnknown_var*   ListChildren =
: s! p$ q; Z  @" M  ?                piProductOnRoot->GetAllChildren();
) {* T* g$ h, q! A* G$ ]/** @anchor err_2 piProductOnRoot not set to NULL after release */ - p, A# }/ p' @" |* E: M. c7 @
        piProductOnRoot -> Release();
/ b1 \, o$ X8 J/ m1 s" a        piProductOnRoot = NULL;
' T1 J. h! f; W* l6 L& Q        if(NULL != ListChildren)# A, G1 j5 A' M1 s7 I: \( @
        {
* ~9 ~4 O4 `; r: o# X' \               
2 q6 V1 s0 \. z                int numberOfChildren = ListChildren->Size();
" G5 s4 q# @  n  `) C& ^6 @! q                cout << " Number of all children under the root = " << numberOfChildren << endl << flush;2 e5 C8 Q. f' T" I9 g. U
; m8 l6 o( L* @' e
                /* -----------------------------------------------------------*/9 d3 j- t& D% D1 }/ X: R
                /*  4. For each child, get its partNumber, and InstanceName   */+ P% b. p7 F1 o
                /* -----------------------------------------------------------*/# u) t4 I" R! M- r6 ^
                CATIProduct_var spChild = NULL_var;
) y/ e# r0 W$ t# ?                for (int i=1;i<=numberOfChildren;i++)
# Z! y9 M0 V$ f2 Z/ T% u+ D. \                {
* l0 b5 s6 I7 d$ t7 \                        spChild = (*ListChildren);
+ H/ c+ H2 j4 A0 f4 r4 F/** @anchor err_3 spChild not tested before use ( if !! ) */
- J3 w+ i7 x7 g$ O* c( U                        if ( NULL_var == spChild ) return 4;- V7 [9 }! u: @( t) M! ^) G% O
                        CATUnicodeString partNumber = spChild -> GetPartNumber();* l7 f+ {. w& S. u
                        CATUnicodeString instanceName (" ");1 }; w, k' z8 k, S3 E
                        rc = spChild -> GetPrdInstanceName ( instanceName ) ;0 P$ f$ s  e+ G
                        if  ( FAILED(rc) ) return 4;
$ q& {5 i3 V. V( |2 y8 ~                       
- ~( J. F* o( B/ C                        cout << " child number : " << i << endl << flush;
+ [9 L3 b6 D  A9 ]! m' \+ e+ ^# s0 U- E                        cout << " has as part number : " << partNumber.CastToCharPtr()  << endl << flush;9 h$ K- x; R  K# Y, P6 _& c  Z2 n/ g
                        cout << " and as instanceName : " << instanceName.CastToCharPtr() << endl << endl << flush;  \( o5 `- ~7 X5 ~: Y, M" M1 H
                }8 k" R- e8 t4 G7 o& j2 E9 c
                delete ListChildren;* Z6 m& _3 b$ |
                ListChildren=NULL;* |3 ~( i+ t6 x, p; g( ?
        }        3 e5 U2 `' m( H
        /* -------------------------------------------- */
4 k$ E1 R+ ~7 U& [( `' c# ?8 w        /*   Ends the session                        */0 D0 K  j! R3 e  j; W0 _
        /* -------------------------------------------- */[/mw_shl_code]
$ M7 L" g( o) e! j, x
上海点团信息科技有限公司,承接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二次开发专题模块培训报名开始啦

    我知道了