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

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

admin 楼主

2018-1-10 10:12:25

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

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

x

% _! X& W+ F2 l- r# ?  OCatia二次开发源码分享: 获取装配所有组件列表
4 {5 ]# E7 o; p, @; b- h' B" X( H& W$ P+ s6 P8 a6 \0 j  x
" H& f0 H4 ]3 E3 A% k- M1 K, {0 B
[mw_shl_code=c,true]/* ----------------------------*/, P" y2 u% f6 |, w  L
        /* 2. Retrieves Root Product   */
. G' S. R' N! ^7 @8 [5 s        /* ----------------------------*/
! `  `8 A; b' I- ]; Q        $ Q8 r. _2 R' {; d5 p- y
        // Begin navigation throUGh the document => start with the RootProduct.
$ ^8 \$ U" Z0 h% Y        CATIDocRoots* piDocRootsOnDoc = NULL;- F- k6 a6 I: H/ ?* ]1 E
        rc = pDoc->QueryInterface(IID_CATIDocRoots,/ ]3 D; D! h) E/ c$ |2 L
                                      (void**) &piDocRootsOnDoc);" A& w' O0 O( c2 H; n) X
        if ( FAILED(rc) ) return 3;
: a- l) A8 W) [+ K       
9 W/ S* Q% M# h+ _. b8 M        // get the root product which is the first element of root elements
- x" d8 T1 K$ C" b* a7 s        CATListValCATBaseUnknown_var* pRootProducts =
0 g" z5 g, Y. p' q                piDocRootsOnDoc->GiveDocRoots();+ m: R2 ~8 \2 z: s8 t0 f2 }& D% g# L
        CATIProduct_var spRootProduct = NULL_var;
% `5 N( l) n; h$ u9 H" I; w       
3 T6 I, D* ^7 n        if (pRootProducts && pRootProducts->Size())# k8 g; @# [7 {* c, Z
        {  
, c9 h3 J% Y( l                spRootProduct = (*pRootProducts)[1];" j* C2 o/ A, Q
                delete pRootProducts;8 i: J' {& f9 @$ n& s2 x% X
                pRootProducts = NULL;# S$ \" D" }1 d6 m
        }6 S# [# j5 Z5 a+ B' @# W, u1 \2 H$ C
/** @anchor err_1 piDocRootsOnDoc not set to NULL after release */
' z% L/ c6 {: f: ~' W! i4 G' O        piDocRootsOnDoc->Release();
! x! S5 w5 c+ Y1 K        piDocRootsOnDoc = NULL;; y# \$ b. c( X# V
        3 B3 m9 _* w/ I9 q7 M# ]( o3 P( I
        // Get CATIProduct handle on the root product.
  d4 A- }/ h2 u        CATIProduct *piProductOnRoot = NULL;4 }4 e2 h+ ^) p/ }# N2 L
        rc = spRootProduct->QueryInterface(IID_CATIProduct,$ }! A( s# {1 p, q# `
                                               (void**) &piProductOnRoot);
8 g2 A! g; h5 y6 p: R        if ( FAILED(rc) ) return 3;% x5 t3 v9 Q+ M

4 C9 I2 l3 p9 T9 q) Z( b) E        /* ---------------------------------------*/  I9 V4 p! B* g: W4 d
        /* 3. Retrieves children under the root   */8 ]0 X$ z3 v! U( v/ @5 w, X: Q4 N
        /* ---------------------------------------*/
' |9 D3 G- f  [! H# ]1 ^8 ?% ?0 j) K       
& Y! m% P+ U- [( \$ T        int nbOfDirecTChidren = piProductOnRoot -> GetChildrenCount() ;6 e% m+ O# t; N4 }. B- @7 H- b2 G2 p
        cout << " Number of direct children under the root = " << nbOfDirectChidren << endl << flush;9 o0 v! C7 q, p$ |* j( I: i8 A; S" k
       
2 x" e" a/ B$ Q$ d1 \1 _        // then on a root product, get all the children agregated to it.- [' F3 o# U% Y; @5 I3 C: v; s
        CATListValCATBaseUnknown_var*   ListChildren =
, ~9 J. S: ~' P7 U" B. v5 d0 E                piProductOnRoot->GetAllChildren();# V. v! l3 [% r
/** @anchor err_2 piProductOnRoot not set to NULL after release */
1 M, T+ e9 j5 l# V$ S/ h0 L        piProductOnRoot -> Release();
2 a/ @$ C2 K& @" s! l        piProductOnRoot = NULL;% R6 P0 ?% @7 R7 ?9 M
        if(NULL != ListChildren)9 g1 Q4 H  D9 H; e2 y2 C0 {
        {
- z3 n, \: R9 y               
1 e$ [* T0 g' S. G# l                int numberOfChildren = ListChildren->Size();
9 A' p  d  h: k7 X- r: D                cout << " Number of all children under the root = " << numberOfChildren << endl << flush;! R: M+ G4 D8 J$ [4 n, k( E
: a  `( z0 l7 `% m8 `) [
                /* -----------------------------------------------------------*/  U2 Y. n# p+ X0 {7 e- U2 k0 L
                /*  4. For each child, get its partNumber, and InstanceName   */2 C. I0 s9 G8 P1 u3 t
                /* -----------------------------------------------------------*/
% O* X6 T# i3 X  S1 G                CATIProduct_var spChild = NULL_var;* c% K# l; Z7 W" x- [5 X! }
                for (int i=1;i<=numberOfChildren;i++)' k$ a1 q& P7 r
                {
& B4 |% {( l" i0 P# Z, G- v2 o                        spChild = (*ListChildren);6 U+ }& }1 N/ @# N# u
/** @anchor err_3 spChild not tested before use ( if !! ) */
9 ]9 S, D4 K$ g, S9 c& @% j                        if ( NULL_var == spChild ) return 4;
9 d: q! a" Z. l3 N7 P% r2 T7 Z3 m6 e                        CATUnicodeString partNumber = spChild -> GetPartNumber();
: P$ O" r$ R" W                        CATUnicodeString instanceName (" ");- b! h* V& e. F  u" j5 c; P% j
                        rc = spChild -> GetPrdInstanceName ( instanceName ) ;
5 f7 I* i1 @6 r% r                        if  ( FAILED(rc) ) return 4;* e! x% L4 Y$ [% ^
                        # J$ E' s+ ~0 v& X
                        cout << " child number : " << i << endl << flush;. B" ?, @" b5 [+ E
                        cout << " has as part number : " << partNumber.CastToCharPtr()  << endl << flush;
  x1 L$ B% ]* O" {5 l! l                        cout << " and as instanceName : " << instanceName.CastToCharPtr() << endl << endl << flush;
7 w: |! W1 c: z- Q- G$ F                }% X. v9 k) C$ g# k
                delete ListChildren;  V( Q1 |. p5 f* z, R% _; c; Z
                ListChildren=NULL;) k7 p$ d5 I, Y# K
        }       
# M( @: @. @/ e- f+ B* P+ j. X        /* -------------------------------------------- */
1 h5 ]4 e2 N, F" i* g1 S        /*   Ends the session                        */
  x9 x5 a* c, G        /* -------------------------------------------- */[/mw_shl_code]
; x3 _! X% A: D6 I/ ]4 }
上海点团信息科技有限公司,承接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二次开发专题模块培训报名开始啦

    我知道了