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

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

admin 楼主

2018-1-10 10:12:25

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

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

x
) l- `5 {7 ^& i$ h
Catia二次开发源码分享: 获取装配所有组件列表4 r+ ^6 B+ F2 m/ v7 n

+ s- T/ g+ m9 |3 b4 \  |. b" K- T: z. Z* S0 e+ u8 O& a
[mw_shl_code=c,true]/* ----------------------------*/
: Y$ I* A( F) H8 P6 x7 `# l" E        /* 2. Retrieves Root Product   */
, z3 }1 W' g; V/ a" u% w) B        /* ----------------------------*/1 c. {4 J7 A# {0 ]
       
3 R! N4 V7 B, v/ P( ]  X8 t4 Y        // Begin navigation throUGh the document => start with the RootProduct.
: m; P7 ^, j( E9 D! T2 m2 E4 J5 U( a        CATIDocRoots* piDocRootsOnDoc = NULL;
4 k8 E) w( w  ]& O9 ^- l        rc = pDoc->QueryInterface(IID_CATIDocRoots,
4 N7 O5 v# T% w% n+ l& s3 j                                      (void**) &piDocRootsOnDoc);
. P, \7 ]8 G3 z) [, u9 q        if ( FAILED(rc) ) return 3;
" l, L% W+ d% [# Z        ( q9 ?4 z7 e* o5 x
        // get the root product which is the first element of root elements" w% A' N' O* H2 u" C7 u: E+ ^
        CATListValCATBaseUnknown_var* pRootProducts = 5 @2 ^. ]6 T. K' i7 u" N
                piDocRootsOnDoc->GiveDocRoots();& f+ i3 h% A; j" Y) H
        CATIProduct_var spRootProduct = NULL_var;7 q2 [0 P1 I; D7 d
        7 s( p- l  }7 w
        if (pRootProducts && pRootProducts->Size())
) l) T% b: a# ~5 N0 S        {  ! G0 I  h) a7 H8 U* m4 N
                spRootProduct = (*pRootProducts)[1];' u9 U" B* `0 O7 i: i0 e, s) z
                delete pRootProducts;
3 K/ n2 G' E: X( Z5 ]& o( u                pRootProducts = NULL;! i2 T. h0 [/ d2 b" M+ M
        }
7 }, D4 r* W5 \! s# ~/ L/** @anchor err_1 piDocRootsOnDoc not set to NULL after release */ # d6 s  n3 N* V; X- X9 O% k) O
        piDocRootsOnDoc->Release();/ k7 Y) P6 l4 E
        piDocRootsOnDoc = NULL;: N+ `# b4 K# e% h7 ^: [
        ) `9 Y; ~% @4 B; b. L
        // Get CATIProduct handle on the root product.# W3 Q* S8 e* U0 Y  f9 [1 M' c
        CATIProduct *piProductOnRoot = NULL;
& P7 V0 T5 m1 }+ M        rc = spRootProduct->QueryInterface(IID_CATIProduct,
4 K1 K0 v! E# i7 @8 }: U                                               (void**) &piProductOnRoot);$ R, Q% r) g6 \+ i
        if ( FAILED(rc) ) return 3;
5 D/ ~; G* Q4 a: Q* k. c+ y
- R4 `6 w5 S9 c, X. T. Y        /* ---------------------------------------*/; ~( R, s+ W* w, q- P
        /* 3. Retrieves children under the root   */
$ s* ~) k' _; C+ P7 D/ a4 H        /* ---------------------------------------*/
1 r: z; m, j# D2 U; A$ U( G       
/ a- E" |8 P- R& o, f( j9 @+ S; \6 y        int nbOfDirecTChidren = piProductOnRoot -> GetChildrenCount() ;8 [4 z( V8 {5 U! l7 X3 I! ~# a! U
        cout << " Number of direct children under the root = " << nbOfDirectChidren << endl << flush;
) |# b7 m. I; }0 v6 |$ P- e       
) }0 u/ \" l6 H: q2 ?* L        // then on a root product, get all the children agregated to it.; M/ y: b- M5 A2 |* Y
        CATListValCATBaseUnknown_var*   ListChildren =5 n; \$ L+ }3 E; R6 h/ C: A
                piProductOnRoot->GetAllChildren();
+ E. U* ]; z8 k) L& q& b: ~2 N- T/** @anchor err_2 piProductOnRoot not set to NULL after release */ + I. d# w* _; k  P2 z5 j& n+ i
        piProductOnRoot -> Release();% w# m$ `$ S- l$ T- L, S
        piProductOnRoot = NULL;
; r% k6 R$ b" i( Z8 A, o3 f; b9 P        if(NULL != ListChildren)
6 k- j' e/ }" s# a0 C7 O; K        {
# r8 s' \9 g9 W" ]/ n7 @% m# W, D6 {$ d                * d3 W& O/ d3 b, F8 B5 S! Y
                int numberOfChildren = ListChildren->Size();
! u& \, ~9 d3 K" i& ?, Z2 S- Q                cout << " Number of all children under the root = " << numberOfChildren << endl << flush;! |+ F4 g3 n" B& N! u: U
" \# h, o8 R2 n7 c
                /* -----------------------------------------------------------*/- g( M" m0 l$ \0 y8 _9 F- b; X
                /*  4. For each child, get its partNumber, and InstanceName   */6 u4 T2 V5 B5 u$ K3 W/ `& r' `+ n
                /* -----------------------------------------------------------*/& Q9 J9 Y" P  D& u/ v
                CATIProduct_var spChild = NULL_var;
# F/ n. U" D- z2 x6 F. m; [                for (int i=1;i<=numberOfChildren;i++)* u2 Q0 w1 N4 e- z# c
                {2 u+ P/ S; l, v. j5 I1 q- v
                        spChild = (*ListChildren);
6 Y) @2 ^7 D+ ^5 h% T/** @anchor err_3 spChild not tested before use ( if !! ) */
" q4 Y  t( Q+ w7 n                        if ( NULL_var == spChild ) return 4;; E) K( @/ M0 G
                        CATUnicodeString partNumber = spChild -> GetPartNumber();
+ o1 x( h. g  ~+ F7 d                        CATUnicodeString instanceName (" ");% I* F" j7 N8 e/ j1 d, ?
                        rc = spChild -> GetPrdInstanceName ( instanceName ) ;
2 m" r3 {7 D* a! @; N2 f+ |                        if  ( FAILED(rc) ) return 4;7 G5 h) V. M, A2 I5 R- c) }
                        7 C: D& i$ P, j. _. T/ G
                        cout << " child number : " << i << endl << flush;( _: N% D9 \  g0 o" [1 c6 n
                        cout << " has as part number : " << partNumber.CastToCharPtr()  << endl << flush;
. r. x9 T- C1 z' M3 E+ `+ ^+ m                        cout << " and as instanceName : " << instanceName.CastToCharPtr() << endl << endl << flush;3 @' {9 o1 [3 [6 l% W1 m: W
                }8 L: D- \0 ^, ?1 I% y/ Y$ c
                delete ListChildren;
* b% n: t/ M: E- r                ListChildren=NULL;& O; o9 E# Z3 T- B% Y# K2 Q
        }       
8 ]* C; Z/ u5 K) t6 X! S        /* -------------------------------------------- */* F7 u, V' A4 h$ O& a- R$ N
        /*   Ends the session                        */! B# F/ ~! L7 X" r4 q
        /* -------------------------------------------- */[/mw_shl_code]3 W/ ?/ g! N% O9 o" v. Q
上海点团信息科技有限公司,承接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二次开发专题模块培训报名开始啦

    我知道了