PLM之家精品课程培训

PLM之家精品课程培训

联系电话:18301858168   |   QQ咨询:939801026
NX二次开发培训

NX二次开发培训

UFUN/NXOpen C++和实战案例

适合初级入门或想深入了解二次开发的工程师,本培训结合ufun,NXOpen C++,大量的实例及官方内部的开发技术。
公众号二维码

关注公众号

点击扫描二维码免费在线高清教程

课程详情
Catia二次开发培训

Catia二次开发培训

市场需求大,掌握核心技术前景广阔

Catia二次开发的市场需求大,人才稀缺。掌握开发技能潜力巨大,随着经验积累将在汽车、航空等领域有所作为。
B站二维码

在线原创B站视频

点击关注工业软件传道士主页

课程详情
Teamcenter培训

Teamcenter培训

全方位培训,从基础应用到高级开发全覆盖

涵盖用户应用基础培训、管理员基础培训、管理员高级培训及二次开发培训等全方位内容,由多年经验讲师打造。
QQ群二维码

加入同行交流

点击扫描二维码加入QQ群

课程详情
×

PLM之家plmhome公众号

课程涵盖: PLM之家所有原创视频

×

关注B站视频

所有高清视频一览无余,全部在线播放学习

×

加入PLM之家QQ群

同行交流,疑问解答,更多互助

PLM之家PLMHome-国产软件践行者

Catia二次开发源码分享: 获取装配所有组件列表

[复制链接]

2018-1-10 10:12:25 2380 0

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

admin 楼主

2018-1-10 10:12:25

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

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

x

0 I  W7 V- t9 y9 R8 iCatia二次开发源码分享: 获取装配所有组件列表* |) B9 Q9 d' V8 G# |
; A) H% b- U' w/ Z7 d, y1 j+ S

! c/ J9 k2 k+ L2 {9 [% M[mw_shl_code=c,true]/* ----------------------------*/
- i7 W+ O1 a; Z        /* 2. Retrieves Root Product   */
6 {! z6 }) P! q- F+ I0 o7 ]+ }        /* ----------------------------*/
! D  W- ~0 d( }; {3 z       
- |2 q' S, q% ?( V5 J! Z) B3 ~        // Begin navigation throUGh the document => start with the RootProduct.$ u' s- f+ s8 z- c
        CATIDocRoots* piDocRootsOnDoc = NULL;9 S- P6 V0 B4 f/ X
        rc = pDoc->QueryInterface(IID_CATIDocRoots,/ J4 s* n& c, A! h& D& G5 T9 a
                                      (void**) &piDocRootsOnDoc);
. ~9 K' @: r6 F8 u        if ( FAILED(rc) ) return 3;; |$ S! X! x7 X3 A  K
        7 L% v6 S) }- u1 I' h. C
        // get the root product which is the first element of root elements
& {) L# |) e$ Q7 u, Z6 q  `" X        CATListValCATBaseUnknown_var* pRootProducts = . F- b# t3 j$ I
                piDocRootsOnDoc->GiveDocRoots();, b8 ~+ z' F4 F9 p. ]
        CATIProduct_var spRootProduct = NULL_var;% E7 I+ V* h9 Q" b/ y( D: Z7 y  a
        " `  @' X* O9 n( [
        if (pRootProducts && pRootProducts->Size())  J/ X5 V* p7 B6 b) W
        {  : `& l3 V  C0 D6 A/ p
                spRootProduct = (*pRootProducts)[1];( o" c3 \& j9 |  L- l" h
                delete pRootProducts;
! c/ F* N; q% K7 n( z                pRootProducts = NULL;
4 J1 O( N, G  N6 @5 T2 |        }- y: c7 f6 N$ Q3 s5 @, U
/** @anchor err_1 piDocRootsOnDoc not set to NULL after release */
% \" n) G* ]: B. s; ~8 r9 u        piDocRootsOnDoc->Release();, X: E' V; Q1 y8 a# s. R
        piDocRootsOnDoc = NULL;
2 f& ?  ?! o- T% o        - s( g6 X- m1 l9 i1 ^
        // Get CATIProduct handle on the root product.
% G8 b2 k  X' h" m5 w        CATIProduct *piProductOnRoot = NULL;
! h; y# h3 d  Q3 m; O        rc = spRootProduct->QueryInterface(IID_CATIProduct,
5 [" r  O% S" G; o% c- n2 @                                               (void**) &piProductOnRoot);* N6 Y3 l3 }$ n, G( O" r1 k4 w' S
        if ( FAILED(rc) ) return 3;
9 N: X# s( W1 C6 p5 u# z* {9 @: y3 m/ `7 N- s
        /* ---------------------------------------*/4 t* e3 K3 \" E; T: Z
        /* 3. Retrieves children under the root   */
+ H1 t/ o% q3 x) @        /* ---------------------------------------*/
- F5 d3 l. B4 M1 _       
$ G& h* n" s; |9 P% d& t$ h* N- U' [4 d; E        int nbOfDirecTChidren = piProductOnRoot -> GetChildrenCount() ;5 S) {4 M) x* l2 I8 U
        cout << " Number of direct children under the root = " << nbOfDirectChidren << endl << flush;% Y  J& x; R" g2 D9 f, Y( F8 G  K
       
% ~1 U* [# ?, a8 X+ V8 `        // then on a root product, get all the children agregated to it.
3 n$ G. f# C$ U/ G* }        CATListValCATBaseUnknown_var*   ListChildren =
. r7 Q* ]9 X2 Q( K! k. W0 J: s                piProductOnRoot->GetAllChildren();
8 m; @$ ?& ~; L; p8 x/** @anchor err_2 piProductOnRoot not set to NULL after release */
6 u: q% |/ v/ Q+ z) c        piProductOnRoot -> Release();
. m  Z: ]! g4 F% r        piProductOnRoot = NULL;
5 l: _1 ^( D8 _) e        if(NULL != ListChildren)
0 q' S5 A! x1 T2 A$ \; Y7 v1 ]        {, P0 J5 b  L- o
                & f" P& `- T+ y6 O; A6 _2 K- `
                int numberOfChildren = ListChildren->Size();
5 P$ X9 Y. T1 ^/ p                cout << " Number of all children under the root = " << numberOfChildren << endl << flush;
7 y* w, C5 B- w5 e" k1 L! z! v
/ `& q$ s: _& s" D  u8 o9 m                /* -----------------------------------------------------------*/, e# \+ ?7 c2 S' H( F
                /*  4. For each child, get its partNumber, and InstanceName   */
3 \, V- F+ M0 m: U' \5 X6 E! X                /* -----------------------------------------------------------*/& T: _( j7 [$ F3 @( a
                CATIProduct_var spChild = NULL_var;
3 w! n5 r  X6 I! q* T                for (int i=1;i<=numberOfChildren;i++)* ]3 T$ a" G- H4 ]5 C) A
                {
) I- P7 r4 T% u0 F" A0 x                        spChild = (*ListChildren);
: j1 ?& m: {+ l0 {5 x6 `! G5 O$ D  {/** @anchor err_3 spChild not tested before use ( if !! ) */
6 r& S6 U" S+ ]  L  M2 z" ]                        if ( NULL_var == spChild ) return 4;, D% o2 `3 ]8 R! O* g4 Q& w* b
                        CATUnicodeString partNumber = spChild -> GetPartNumber();
# j! R* [9 M" ?& f                        CATUnicodeString instanceName (" ");5 [! I3 c8 t  h+ f: S
                        rc = spChild -> GetPrdInstanceName ( instanceName ) ;
7 g: x* |0 Y' x- M+ d% O                        if  ( FAILED(rc) ) return 4;
6 @  [2 R# O& [' R                        * X" r) s, j4 z2 }
                        cout << " child number : " << i << endl << flush;
9 a/ x5 g) P  S' O; t5 O4 V                        cout << " has as part number : " << partNumber.CastToCharPtr()  << endl << flush;
4 S& D# i- ]3 M* G4 _* B, m                        cout << " and as instanceName : " << instanceName.CastToCharPtr() << endl << endl << flush;
! g% Q" u* Z9 z& r                }
3 i! Q/ q8 V2 D) z) a                delete ListChildren;
5 u# n% |. c! m                ListChildren=NULL;  B2 ^, Z6 x% u
        }       
6 @+ w; |, S% m8 L! V) {        /* -------------------------------------------- */2 g. ~* B' c) }# V. e" D, V
        /*   Ends the session                        */
8 Z! y5 u1 z5 X- b5 `6 ]7 V        /* -------------------------------------------- */[/mw_shl_code]: b7 X1 `% ]0 K
上海点团信息科技有限公司,承接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二次开发专题模块培训报名开始啦

    我知道了