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

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

admin 楼主

2018-1-10 10:12:25

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

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

x

4 Y8 d; N- j% m: F" q2 `& X/ Q) NCatia二次开发源码分享: 获取装配所有组件列表
" @6 Y. G( f3 k- A
/ y  P$ h; m) A, f( E' I' }) _# J2 t' i$ A0 n
[mw_shl_code=c,true]/* ----------------------------*/
- U8 n0 }8 X! \" o        /* 2. Retrieves Root Product   */
! w% W8 m: k# \0 [+ }. S        /* ----------------------------*/
8 P0 v  T0 f2 }/ h$ w       
! q& B0 g0 [8 C        // Begin navigation throUGh the document => start with the RootProduct.
# A/ r# V. d$ b: q5 s9 u. p* v        CATIDocRoots* piDocRootsOnDoc = NULL;1 @' J! i- S6 a( K. E  _; R- P
        rc = pDoc->QueryInterface(IID_CATIDocRoots,3 Y! {# a  M: [/ C+ c: J: B
                                      (void**) &piDocRootsOnDoc);3 Q" e* A8 n1 h/ H$ A
        if ( FAILED(rc) ) return 3;
0 T0 g4 S' T0 B( V4 f5 m. V        3 O/ ]7 b% y0 x- ?, y0 ^$ D
        // get the root product which is the first element of root elements
; f3 X+ v0 n, E/ [+ s4 i$ k0 B        CATListValCATBaseUnknown_var* pRootProducts = ) j4 X% O9 I& x+ n4 I5 x
                piDocRootsOnDoc->GiveDocRoots();: J# n! }* F3 B1 d! \
        CATIProduct_var spRootProduct = NULL_var;
: x' k3 T# c& a1 h       
8 z& @+ L& V8 X1 {        if (pRootProducts && pRootProducts->Size())
) C- z$ e' [- i: g# r, \4 a* b' c4 L        {  4 z6 N3 t- y- h( N) M: w: C
                spRootProduct = (*pRootProducts)[1];
+ v, t8 I) n/ W/ @                delete pRootProducts;" M- v3 n9 E5 ?7 u/ x6 `- R$ C
                pRootProducts = NULL;
7 Y! P' M3 X: _, Y, z5 O        }
+ {/ O' ?7 y6 y4 b( W0 r6 o/** @anchor err_1 piDocRootsOnDoc not set to NULL after release */ ) T. e0 H$ S# F0 ^- d
        piDocRootsOnDoc->Release();
3 M) ~6 a; l" u3 y2 i6 L$ K        piDocRootsOnDoc = NULL;/ y- _- x6 m8 _: j8 w+ e$ v
        6 }9 N. X. C* |6 l
        // Get CATIProduct handle on the root product.8 E4 v4 U; y' @* H6 s) N
        CATIProduct *piProductOnRoot = NULL;6 n. \0 \6 R7 m9 h2 H" j! _2 j( y
        rc = spRootProduct->QueryInterface(IID_CATIProduct,! c5 ]- d  P& X& _: f5 p5 ^1 k
                                               (void**) &piProductOnRoot);  a8 z$ ?( D( \) n* I
        if ( FAILED(rc) ) return 3;  @* C( E6 O0 j
; [2 ^0 Y! s1 V1 X5 M& T
        /* ---------------------------------------*/
3 o/ G. B" U# ?5 \5 A        /* 3. Retrieves children under the root   */
0 b8 C, e" D9 D# b% ]& Y8 g        /* ---------------------------------------*// n: B. }% b: r$ C0 s
        - K2 x9 b8 Y6 K0 m) Q# p- `: w
        int nbOfDirecTChidren = piProductOnRoot -> GetChildrenCount() ;8 {. \; A. |( y: v- |- [* R
        cout << " Number of direct children under the root = " << nbOfDirectChidren << endl << flush;- `  j. D+ n& Z7 w. G; h
       
1 f! w; X* m. G. V  y( j" [. s        // then on a root product, get all the children agregated to it.  ^7 I( J  Z" r  K
        CATListValCATBaseUnknown_var*   ListChildren =; }3 K, X1 T3 L! ?
                piProductOnRoot->GetAllChildren();4 n# F) g% T( j8 X# L" K# s2 i; p
/** @anchor err_2 piProductOnRoot not set to NULL after release */
  b6 i! m. L9 e8 K3 L) O# h' J' y        piProductOnRoot -> Release();1 S# O' ^/ M+ Y5 h; @
        piProductOnRoot = NULL;
' k) j$ E2 ?8 f2 h. g* `        if(NULL != ListChildren)  H- s1 ~1 S0 D$ N$ F0 S3 Z# `
        {9 i, m) A" x/ Q6 I; G
               
( t/ n7 H9 H: z* n                int numberOfChildren = ListChildren->Size();6 l: P% M% W' }1 r- f. H
                cout << " Number of all children under the root = " << numberOfChildren << endl << flush;
$ ]6 M! K; ~  _2 N% @2 U+ J# k. B$ ]
                /* -----------------------------------------------------------*/: F& ?6 z+ D, e- Y+ g8 a
                /*  4. For each child, get its partNumber, and InstanceName   */' I5 {1 i2 @; }7 y8 q5 G, z3 X
                /* -----------------------------------------------------------*/
6 q4 P1 e4 i; b9 @( k                CATIProduct_var spChild = NULL_var;
- q' [6 z' t7 a                for (int i=1;i<=numberOfChildren;i++)) v4 w/ S, v; Q
                {
+ s4 |! x; l: k$ d6 |                        spChild = (*ListChildren);' z' Q9 {4 ]" J
/** @anchor err_3 spChild not tested before use ( if !! ) */
7 \$ Z) Z& e, W# G; X                        if ( NULL_var == spChild ) return 4;6 g6 o2 u, M+ e: p0 q( P
                        CATUnicodeString partNumber = spChild -> GetPartNumber();
0 i0 o5 F, m/ C8 j  s( _                        CATUnicodeString instanceName (" ");3 f% ?7 H3 j$ r  W& O, g" a# ?
                        rc = spChild -> GetPrdInstanceName ( instanceName ) ;1 s) s( i& y" p3 C0 P% ^
                        if  ( FAILED(rc) ) return 4;
; N0 S2 {/ b% k6 y                        , M/ K- e7 G1 g, o5 t5 \
                        cout << " child number : " << i << endl << flush;
0 h% ~! C* u5 l5 U! ?3 Y                        cout << " has as part number : " << partNumber.CastToCharPtr()  << endl << flush;
2 f; O9 h1 z& b                        cout << " and as instanceName : " << instanceName.CastToCharPtr() << endl << endl << flush;
: c/ R5 C: K0 \- \$ K                }
" b% |/ |2 ?' r  ^! _8 s                delete ListChildren;* N9 T' O- h! \2 {
                ListChildren=NULL;
9 R7 x! m1 t. F1 x        }        7 w4 B* w) F6 y5 d/ _" u( W
        /* -------------------------------------------- */
" J' H) M6 Q% I- U: H/ r        /*   Ends the session                        */
, {: m+ u- m  {6 r        /* -------------------------------------------- */[/mw_shl_code]: T2 c' m" o4 Z8 f" N
上海点团信息科技有限公司,承接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二次开发专题模块培训报名开始啦

    我知道了