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

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

admin 楼主

2018-1-10 10:12:25

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

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

x
# N5 O3 ^# t( M4 t0 ~1 r$ I
Catia二次开发源码分享: 获取装配所有组件列表
6 ]: H, I5 N& e- z
2 a3 X! T( J1 _/ e0 [# u- D% m7 |( r
; c! Q' f2 U. ]5 X" A  g, z  P[mw_shl_code=c,true]/* ----------------------------*/3 m2 K6 v" Y2 a% c" z
        /* 2. Retrieves Root Product   */8 f! Z- P. W2 w
        /* ----------------------------*/: w- n* X3 T8 |8 i" d- \1 P8 A
        5 B" n* s5 }& S1 V  D/ [
        // Begin navigation throUGh the document => start with the RootProduct.% K4 u* @; n! g' ^( H' F) r
        CATIDocRoots* piDocRootsOnDoc = NULL;
8 c1 e) k' Z, o" n6 V% P- i        rc = pDoc->QueryInterface(IID_CATIDocRoots,
- V( o# j( B* _                                      (void**) &piDocRootsOnDoc);
0 z! u; l9 ]& p$ E- p  }7 h        if ( FAILED(rc) ) return 3;
& U1 \% I3 W" x$ ]3 [. Z4 ~( |/ ]          |7 l, j) Z. j; @. g& _5 h' @
        // get the root product which is the first element of root elements8 Q5 y( x* _8 ]5 }! {
        CATListValCATBaseUnknown_var* pRootProducts =
$ a6 F! p1 a  I# U                piDocRootsOnDoc->GiveDocRoots();
: a8 I) v: v) Z7 ^7 H9 c8 v! a        CATIProduct_var spRootProduct = NULL_var;+ s# J0 T& j6 f$ t1 {
       
' y5 r3 c8 e) h- X9 T0 t1 V        if (pRootProducts && pRootProducts->Size())& m% t, i1 u) o1 m  R; O2 z
        {  & P* r& }7 G' e) \9 _
                spRootProduct = (*pRootProducts)[1];2 H) P; w0 O# d8 d
                delete pRootProducts;$ T3 R  X5 W# ^/ d1 S
                pRootProducts = NULL;& w/ O7 q* h$ h9 T- a
        }
, k9 H- Q, U- ~1 y( {( V/** @anchor err_1 piDocRootsOnDoc not set to NULL after release */
! [( u. @7 \% m# v3 A$ X        piDocRootsOnDoc->Release();
1 ?, Y3 I& o( l  |; v  H        piDocRootsOnDoc = NULL;
* S+ ^+ L/ b. N, J% x6 u$ c        3 p6 ]2 d- T( X, r
        // Get CATIProduct handle on the root product.
/ }! W" F0 A( F5 l7 M2 }5 N        CATIProduct *piProductOnRoot = NULL;" R0 u- o& g1 I9 _) y
        rc = spRootProduct->QueryInterface(IID_CATIProduct,
- B: n) f7 w* W* O. X( c                                               (void**) &piProductOnRoot);
- a1 d2 U# C4 F1 N! c4 B        if ( FAILED(rc) ) return 3;
5 b! Z6 m$ N0 |9 a9 A
$ |- r6 }0 T  u7 Q        /* ---------------------------------------*/  q4 |' C7 w% l2 a0 s: m
        /* 3. Retrieves children under the root   */
1 w5 f- A* Z9 Z6 D% Z1 L        /* ---------------------------------------*/
1 J. {- P! b+ W7 o       
2 T+ G6 T: Y, k7 n& E+ Z        int nbOfDirecTChidren = piProductOnRoot -> GetChildrenCount() ;
1 T% R& I5 W& n- m        cout << " Number of direct children under the root = " << nbOfDirectChidren << endl << flush;
0 m; {" l6 |( {8 c        / L/ z8 p" Q/ |: h3 @
        // then on a root product, get all the children agregated to it.
% j8 n7 p/ d: P        CATListValCATBaseUnknown_var*   ListChildren =- E# H  Q# ~+ E2 w( c: }
                piProductOnRoot->GetAllChildren();
8 j& h7 X4 [2 ^: e* G& O: _; o/** @anchor err_2 piProductOnRoot not set to NULL after release */ # p* F0 n. R: M3 |) b
        piProductOnRoot -> Release();
, A$ G( `' Q$ d, R        piProductOnRoot = NULL;) @. U9 `! W% @5 W$ l" \7 q
        if(NULL != ListChildren)& X5 c: \# r8 r; X, x7 e9 ?& J6 T
        {) Q  J. p+ {; v; a3 a4 `- b6 i
               
8 a2 S; B2 i# W- Y                int numberOfChildren = ListChildren->Size();8 E+ i/ Q8 }) \  \. T+ t
                cout << " Number of all children under the root = " << numberOfChildren << endl << flush;3 p( m6 s  h* ^: L$ M

0 l* A& V% D% d# S7 Q- ]9 V; B                /* -----------------------------------------------------------*/
9 t  M9 ~* K. \                /*  4. For each child, get its partNumber, and InstanceName   */
5 n: b3 ]$ O  `3 l) i                /* -----------------------------------------------------------*/* o" ]: _/ J, ^( ^' h& X/ r- a
                CATIProduct_var spChild = NULL_var;
- @( w' p/ m5 c6 O/ k4 b% v5 {. ?                for (int i=1;i<=numberOfChildren;i++)
: I9 c* H0 w# e( o5 [                {* U2 \$ [# Z9 J+ T/ V$ b8 ]( f
                        spChild = (*ListChildren);4 _1 j1 u) x- {8 Y& x# v/ g9 c0 ?
/** @anchor err_3 spChild not tested before use ( if !! ) */ 8 {% i8 X% E: {- O8 i
                        if ( NULL_var == spChild ) return 4;
  r/ \2 X: n+ N- ]. _                        CATUnicodeString partNumber = spChild -> GetPartNumber();5 D# v" ]+ u5 D$ x2 _2 x- j
                        CATUnicodeString instanceName (" ");
: @; Q7 i+ G' g! p4 ?) g" Y8 O                        rc = spChild -> GetPrdInstanceName ( instanceName ) ;
8 _; \8 ~- i# b: M$ M% P                        if  ( FAILED(rc) ) return 4;
3 h- c. U/ m, c3 c$ l) L& T8 Y                        / D6 i- E4 i) L/ p+ }5 I2 B2 }
                        cout << " child number : " << i << endl << flush;" X+ x3 Q" N; A
                        cout << " has as part number : " << partNumber.CastToCharPtr()  << endl << flush;
( r* D& ]( t* o                        cout << " and as instanceName : " << instanceName.CastToCharPtr() << endl << endl << flush;1 Y2 u5 r, G0 o  z+ c
                }" I( @$ B+ a8 s! k( g: [) z
                delete ListChildren;( f" b5 C2 s. h! X+ ^: ]
                ListChildren=NULL;
) M/ ~. k2 }7 i. a        }       
6 w' E5 Y+ F3 O0 e- u6 d4 u        /* -------------------------------------------- */& F' J- P- h/ h& T
        /*   Ends the session                        */
. T7 G/ L2 X2 s; v4 e- B# Q        /* -------------------------------------------- */[/mw_shl_code]# o, ^' i; N4 D, H& b# K8 _4 d2 C; `
上海点团信息科技有限公司,承接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二次开发专题模块培训报名开始啦

    我知道了