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

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

admin 楼主

2018-1-10 10:12:25

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

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

x

: {6 P" C5 e' Z5 \- vCatia二次开发源码分享: 获取装配所有组件列表
+ s! w  X3 d1 C) t4 @; T% K
. L5 ?5 a2 o8 t9 V  R" A
  V5 \; P6 Y2 H  W% G2 H5 x[mw_shl_code=c,true]/* ----------------------------*/; O$ v3 h" B7 Y) e0 t
        /* 2. Retrieves Root Product   */) Q2 z5 \( u$ e1 l2 A
        /* ----------------------------*/
1 Y- v; B5 y, b! v0 t$ Y- A2 h       
; _3 y3 G' ?- R/ R        // Begin navigation throUGh the document => start with the RootProduct.
  a  r! l- Z+ Q7 C7 b$ d        CATIDocRoots* piDocRootsOnDoc = NULL;
* Y4 Y; f" E* B( m+ R% x# A        rc = pDoc->QueryInterface(IID_CATIDocRoots,
8 K9 x1 t% k  J# |; [                                      (void**) &piDocRootsOnDoc);; n0 Z  A! V' f( j+ E
        if ( FAILED(rc) ) return 3;
$ M# q. V' Q; U! l" x! f9 w       
6 `' e2 N$ s8 ?5 G0 u+ y        // get the root product which is the first element of root elements
, m& C. \* }' w# q% R4 w+ y, b        CATListValCATBaseUnknown_var* pRootProducts = ! A( G' W$ E( s8 A/ A9 n
                piDocRootsOnDoc->GiveDocRoots();
+ g7 c9 i9 m; i+ P4 }$ Y/ \        CATIProduct_var spRootProduct = NULL_var;; `6 \# c$ q: U; l( C
        1 o  `2 K8 j8 g1 U1 {8 A
        if (pRootProducts && pRootProducts->Size())! t' P# b' v% b
        {  / S8 m1 E- Z1 R: _! M
                spRootProduct = (*pRootProducts)[1];
8 n  k: T# ~+ x5 y                delete pRootProducts;
8 f4 J" f9 H$ A2 d                pRootProducts = NULL;
" q5 |+ Y/ S! M) \        }. W7 v  F8 M1 v) M
/** @anchor err_1 piDocRootsOnDoc not set to NULL after release */
1 o2 O5 {: `: d9 F: C: x        piDocRootsOnDoc->Release();
( `6 \: R" w' O( f  S        piDocRootsOnDoc = NULL;  L% ?. e, v) S3 z' u* a2 p
       
2 g- l1 O3 d& u: L& m( ~- R        // Get CATIProduct handle on the root product.) c+ ]+ T: |7 k+ J
        CATIProduct *piProductOnRoot = NULL;
' j, T+ K$ ^8 B( x5 I5 [- }* I+ y  K        rc = spRootProduct->QueryInterface(IID_CATIProduct,* I$ U, C" p1 b* G, P
                                               (void**) &piProductOnRoot);
5 a$ d8 Z4 m  q# ~1 q        if ( FAILED(rc) ) return 3;( M, t6 c! t6 W9 i, I' n

) Z- `# ^8 }9 ?! \  P        /* ---------------------------------------*/, o9 ^; \( w5 x. m7 l* b
        /* 3. Retrieves children under the root   */* J( D" r2 C  ]! W1 K% w
        /* ---------------------------------------*/. R6 ~, Z6 S6 b' L* \; f, L, y
        9 K# y2 A# B6 W  e8 w
        int nbOfDirecTChidren = piProductOnRoot -> GetChildrenCount() ;
* K" F* s1 U3 ?& P; g+ E6 O        cout << " Number of direct children under the root = " << nbOfDirectChidren << endl << flush;! q% u, K% q' Y6 ~
       
+ i! S# e" u0 P  D        // then on a root product, get all the children agregated to it.
2 T& \' p4 h, K" ]; h8 [7 }        CATListValCATBaseUnknown_var*   ListChildren =# n* i* ?# l4 Q* r5 e8 ~) I  W! D/ G
                piProductOnRoot->GetAllChildren();
/ B7 M8 j5 K" W6 r2 z/** @anchor err_2 piProductOnRoot not set to NULL after release */
# F  V! [& o* U, N4 K        piProductOnRoot -> Release();
) ?* b! A0 ?7 B6 E        piProductOnRoot = NULL;
' A+ u( N$ u* J  r+ k' K; L: U        if(NULL != ListChildren); H$ s- J2 [; J9 N  o2 Z
        {' k( u* N5 U7 `0 U2 Y; u
                # I1 Q/ V5 s+ c& t* m: Y% L
                int numberOfChildren = ListChildren->Size();
* H7 K* k+ K( _9 E                cout << " Number of all children under the root = " << numberOfChildren << endl << flush;
* T* r+ D1 u, b- G
% {/ O/ }: G. y! |+ o, I# E                /* -----------------------------------------------------------*/
. ~4 V' j7 C  u& M" i                /*  4. For each child, get its partNumber, and InstanceName   */' \9 K/ {2 {6 i# o+ c, ?
                /* -----------------------------------------------------------*/+ B* p% n0 U5 T% i
                CATIProduct_var spChild = NULL_var;1 Y1 m! W, R9 z2 d. b
                for (int i=1;i<=numberOfChildren;i++)
8 D6 @: l2 ]' B% }                {
9 s4 ]: }+ Q' O3 m6 s( A                        spChild = (*ListChildren);! l, X6 b1 n; [2 h" Z5 x
/** @anchor err_3 spChild not tested before use ( if !! ) */ 4 I: U: v. ^6 Y
                        if ( NULL_var == spChild ) return 4;0 Y# U( x4 @4 _* @
                        CATUnicodeString partNumber = spChild -> GetPartNumber();6 O) D8 J* V- ~* P: t
                        CATUnicodeString instanceName (" ");
4 Y, h/ y4 p4 C$ N( C7 J& u                        rc = spChild -> GetPrdInstanceName ( instanceName ) ;
2 B  k6 P6 }  ?1 b                        if  ( FAILED(rc) ) return 4;8 M4 g7 G* N# S  ]9 J+ f
                        4 f' @  i& W- b' D5 h; q
                        cout << " child number : " << i << endl << flush;! e; ^/ E; V9 g' T8 A* ^- X
                        cout << " has as part number : " << partNumber.CastToCharPtr()  << endl << flush;- u0 n" E+ T$ e8 p/ l
                        cout << " and as instanceName : " << instanceName.CastToCharPtr() << endl << endl << flush;8 L* C2 W. E9 H" R) R: d8 E2 C
                }3 [; R! f, O* a! n4 _! y
                delete ListChildren;
; \! `0 Y" W# S( z                ListChildren=NULL;" {+ z! D& U  z4 b8 g* h* g
        }        ; d" o. d. _% n
        /* -------------------------------------------- */
- X' z" H7 B4 O" P' S2 N        /*   Ends the session                        */
! C* v" @8 N; V0 @, p        /* -------------------------------------------- */[/mw_shl_code]! R/ L' D: p, J2 ?' 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二次开发专题模块培训报名开始啦

    我知道了