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

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

admin 楼主

2018-1-10 10:12:25

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

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

x
/ X8 r: ]6 o8 y9 B
Catia二次开发源码分享: 获取装配所有组件列表* ?0 \0 Z. ?$ U4 g
; ?& h0 S. e8 @3 x

. P6 F, \5 Z& D5 T2 m9 I[mw_shl_code=c,true]/* ----------------------------*/1 O. d" n. W( j8 h% K0 f, h
        /* 2. Retrieves Root Product   */
( t( H3 z' U8 z        /* ----------------------------*/4 a# }: w* U) s3 C  F
       
3 B" t. @- v( m        // Begin navigation throUGh the document => start with the RootProduct.
4 q) T9 Q# Z2 o. }# w/ S! V        CATIDocRoots* piDocRootsOnDoc = NULL;
( X7 t, ?4 b( j5 j" j        rc = pDoc->QueryInterface(IID_CATIDocRoots,
) G, O  B7 c& C4 ]( V8 S                                      (void**) &piDocRootsOnDoc);) \5 ^; [* Y; \- N
        if ( FAILED(rc) ) return 3;
! p7 L5 x$ `! d1 p$ i$ n       
( M  F! D9 _$ N+ Q" a$ [; |1 z$ L$ x        // get the root product which is the first element of root elements2 g5 v3 E- w7 l1 V3 p/ S# a
        CATListValCATBaseUnknown_var* pRootProducts = ) l* f4 a4 `: [& T/ s
                piDocRootsOnDoc->GiveDocRoots();
; D% e$ H* _: I$ J        CATIProduct_var spRootProduct = NULL_var;
0 p; P8 p$ F& P/ l- F+ Y6 T       
" F3 g: j5 i$ M1 X8 j" }: ?        if (pRootProducts && pRootProducts->Size())& O& {/ y' n  L& ?' s2 |' n
        {  
9 u7 f* x6 v+ m! ^  Y  t                spRootProduct = (*pRootProducts)[1];
, G0 H* p; n1 T0 M1 p' y8 l                delete pRootProducts;
# R9 Y; @6 @& J' G1 z( Y2 k                pRootProducts = NULL;$ H8 i6 D: E- N; E& N! W) J# O- o
        }' }* {+ A6 j8 t, ~& ^
/** @anchor err_1 piDocRootsOnDoc not set to NULL after release */ 6 [5 H2 M# S) D; O; J
        piDocRootsOnDoc->Release();
0 Y, _) s# }# ^! H        piDocRootsOnDoc = NULL;
! T2 I- _& o% r; U8 c* r          k3 z: E# {4 O& G
        // Get CATIProduct handle on the root product.
6 z' m' q; ^; ^; }5 q        CATIProduct *piProductOnRoot = NULL;
- ]( M1 r6 |8 o        rc = spRootProduct->QueryInterface(IID_CATIProduct,) K: m  O/ v3 e7 h+ t6 G
                                               (void**) &piProductOnRoot);
+ _" I$ M7 A) O9 Q3 N1 V1 t# u        if ( FAILED(rc) ) return 3;! D1 b5 e& A% L
2 u8 K4 V7 ]6 U" Y# R8 Z
        /* ---------------------------------------*/% r% X! ?& B: p& ~% R
        /* 3. Retrieves children under the root   */
5 N! c) l4 n+ G& Y9 Z1 v, [! v& k        /* ---------------------------------------*/" K1 D) I8 E+ h/ V8 e
        $ q/ J' b0 ]) J) D" B! y' ]
        int nbOfDirecTChidren = piProductOnRoot -> GetChildrenCount() ;9 g; G2 \0 W' u, m. V7 V+ n
        cout << " Number of direct children under the root = " << nbOfDirectChidren << endl << flush;
2 L6 U; h6 g) E& Y8 n       
7 A% j( c3 ]5 `        // then on a root product, get all the children agregated to it.
$ f: y# p) d3 \4 e; O        CATListValCATBaseUnknown_var*   ListChildren =9 Y4 l% U. L: f; s
                piProductOnRoot->GetAllChildren();. j2 a- l, [4 M0 E
/** @anchor err_2 piProductOnRoot not set to NULL after release */
8 Q% w+ h; A1 G1 @( G4 S        piProductOnRoot -> Release();) [. O/ w& r6 g
        piProductOnRoot = NULL;, @  w5 |* ?' H' V! P4 f: N/ N
        if(NULL != ListChildren)  g% b1 e7 E2 V# c  ?
        {
1 R: I7 Q5 o1 O# X, Y' p8 G                # y( }% j( n1 ^# Q% x
                int numberOfChildren = ListChildren->Size();$ a# r: ]: j! y, M4 A8 G7 D
                cout << " Number of all children under the root = " << numberOfChildren << endl << flush;2 k3 d/ \! o$ k. M4 n

" X. O- p5 m: l5 t! p                /* -----------------------------------------------------------*/
# }; y  c3 c% Y( c. d" r                /*  4. For each child, get its partNumber, and InstanceName   */
) A- h, q7 t+ Z" P9 l2 `                /* -----------------------------------------------------------*/
/ {8 L9 c/ D0 `( u) ]5 I0 O                CATIProduct_var spChild = NULL_var;
3 n) G! ?: E* b; N7 @5 _3 s                for (int i=1;i<=numberOfChildren;i++)
  @% ?6 L& l' P6 F, v* D3 Y                {4 v$ E( }* [6 b  m
                        spChild = (*ListChildren);% p3 c" ^: ^5 i/ }$ Q
/** @anchor err_3 spChild not tested before use ( if !! ) */
, Z4 P2 h( c& h6 Y4 |                        if ( NULL_var == spChild ) return 4;
2 B* v% D2 f& z# [/ ?  W                        CATUnicodeString partNumber = spChild -> GetPartNumber();* E* I3 ~* n- h! X/ l
                        CATUnicodeString instanceName (" ");3 {& e. d( q/ P# \
                        rc = spChild -> GetPrdInstanceName ( instanceName ) ;+ U# r; B" D  t- X
                        if  ( FAILED(rc) ) return 4;
- X4 Y. z% o' P5 C( t+ {) k                       
; z2 ~. @! E, s$ G                        cout << " child number : " << i << endl << flush;( L2 n6 K! e8 U( B  Y/ R
                        cout << " has as part number : " << partNumber.CastToCharPtr()  << endl << flush;( _% U$ O* l4 Z
                        cout << " and as instanceName : " << instanceName.CastToCharPtr() << endl << endl << flush;0 V9 `- \( }$ |  Z( K- K
                }
) u9 s+ A4 z+ j* W                delete ListChildren;- {2 T3 z: x/ _2 F( o
                ListChildren=NULL;( i5 d4 @6 G, E8 c; J: A
        }        5 g" B! _1 l! o' U
        /* -------------------------------------------- */
: X  J9 _& d1 Z& Q4 t        /*   Ends the session                        */
$ `7 y+ z) E% l5 R9 H: ~, f% U& y        /* -------------------------------------------- */[/mw_shl_code]9 W, Y8 Q. C3 M7 y* ?: ?6 h
上海点团信息科技有限公司,承接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二次开发专题模块培训报名开始啦

    我知道了