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-国产软件践行者

[二次开发源码] NX二次开发源码分享: 获取当前Reference Component的通用方法

[复制链接]

2018-1-10 17:48:41 2057 0

admin 发表于 2018-1-10 17:48:41 |阅读模式

admin 楼主

2018-1-10 17:48:41

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

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

x
2 X7 f( K1 x( [) q- e& P

3 w/ k9 r! A8 i: P! uNX二次开发源码分享: 获取当前Reference Component的通用方法, f. C3 M, o2 P- U4 z) A5 y$ b3 N

+ m* ^' \" m3 Y) x* m
. L3 @3 @/ a" j# H  F, l: O
9 m9 K6 N+ |$ K; x  r
- I- N  |6 d& ?6 b2 Q( A. p6 W) T2 i# E. t1 D
[mw_shl_code=c,true]static logical attribute_exists(Component cmpnt, char *title)  G2 b. C& r. R& t$ q: v7 h% W
{
( a1 E7 }% ]5 e0 K2 b! m( j* \
! {9 H& F/ L7 D% v//  The traditional method of asking for all of the components recursively//  does not work if you are looking for reference-only components,//  because they are not retured when you ask for the children.////  Also, asking for the AssembliesGeneralPropertiesBuilder.ReferenceComponent //  Property  does not work in versions earlier than NX12.////  The workaround is to cycle for components the old-fashioned way,//  and then ask whether each one has the REFERENCE_COMPONENT attribute.////  If you have multiple occurrences of a given component in the assembly,//  each one will be reported.
. W, l& ~) q0 }. v0 R. Q    ' y9 e. [; F& E
    logical
) h% N* y. e) P- l$ v        hasRefAttr = FALSE;
9 g4 r  T! v- F# I# S; Q1 N+ u4 n6 o# b: k
    hasRefAttr = cmpnt.HasUserAttribute(RO, NXObject::AttributeTypeAny, -1);5 ]3 r8 \& V& |4 @2 M& r7 h

9 v2 t  m& g2 H! R' L4 d    if(hasRefAttr == TRUE)6 j% e3 L  j8 ^4 @7 z- W3 q$ R
    {
0 R1 {2 U, g' M* a9 B        return TRUE;
" E% q- l' w' Q# f- e! X! O    }, n0 |* W4 k  a8 d7 J( _4 z1 m
& s. a& o. Q6 ?! w! r  h: F
    return FALSE;
+ d6 V+ D2 F3 r, C; }
9 [% F' c& u5 _% {* @+ i}
5 b! n' R1 H  V3 h
+ U3 f$ q# V8 M8 d0 ?) p7 A- {% ~) m4 {static tag_t ask_next_of_type(tag_t part, int type, tag_t object)- _9 n$ @4 z: Z( w
{/ q" Z, C7 Y7 b8 O( k/ [# `0 \) y
    UF_CALL(UF_OBJ_cycle_objs_in_part(part, type, &object));
4 C! E- X9 M: F1 m1 Z+ N, n    return (object);
" `, e& ~4 D3 z. @6 l3 G3 e}
6 ]  v7 y  F4 d9 c, D. w1 [3 U$ ]* X; ~) M4 _5 G+ }% ~
static void do_it(void)
% m2 d5 ]+ X& V. x8 F  s" Z{
% J/ Q% A1 `) U! ?    // Assumes that the display part is the top of the assembly9 k( U2 J5 ]0 H% J! J7 D

* Z' `  ]4 W1 o  T1 C    tag_t
- j. m/ J) u% Y# X( p        dispPart = UF_PART_ask_display_part();" f+ T) f- o7 Q. e) @
" p* d* N+ B; _0 ?
    if(NULL_TAG == dispPart) / o( D1 p+ A- ~4 C
    {
; M+ T% _: a6 j- A$ ?! P3 p        ECHO("Program requires an active displayed part");: }; h# O& x* K6 e& N+ S4 n
        return;/ _; D3 f) _8 B7 L4 ~
    }1 B' x5 M- r1 _" s2 Q: N+ |/ Q

  ?" @7 J5 ~; X    tag_t
: M9 w$ B* K% l        compTag = NULL_TAG;: M3 \1 t, ?4 V& [; j
7 x4 I& w7 _9 }
    while((compTag = ask_next_of_type(dispPart, UF_component_type, compTag)) != NULL_TAG)8 P0 ~/ a/ ?3 w2 C, c
    {. p+ ]; c$ M5 x" R: x% V) l8 O4 U
        char0 V* ?4 {$ {- O1 k
            msg[512] = {""},) Y$ K% J( I5 `8 b0 G9 I! K$ E
            fSpec[256] = {""};
: e* |0 y$ M% y! D* P- Q; ]# H6 E3 c; Q. `4 L
            tag_t
/ C' K2 G4 o( j                protoPart = UF_ASSEM_ask_prototype_of_occ(compTag);" r' `( ?2 |5 ]$ \$ P- S6 i. f8 E# _
8 s! w$ e7 U6 ^4 m9 g& h
            UF_CALL(UF_PART_ask_part_name(protoPart, fSpec));
1 D0 G4 U6 H- p; Y. j; }
; C3 B6 k5 K. ]. p& o            // uncomment to see all component names:
; k1 k, A# _. S) |- W; B! f            //sprintf(msg, "Component Part: %s\n", fSpec);8 k2 F6 o9 y4 ?5 t- u$ p+ I* _
            //ECHO(msg);# [! v' @9 `% `/ G+ Z8 j+ J1 _) q
7 z" q* t2 k3 `3 h
            Component *theComponent = (Component *)NXObjectManager::Get(compTag);
0 e7 W' H& K. M& A            if (attribute_exists(*theComponent, RO))
! U/ @' A" E( r# M            {
2 {! x4 Y" c6 U& k2 a4 D! e/ ~                sprintf(msg, "**** Reference-Only Component: %s\n", fSpec);, g3 ?+ m* m, R1 `
                ECHO(msg);
1 n' G& A! o: f            }
) Q( L/ Y* s' ]* ^  v' z; o& l+ U    }+ E5 b7 L" S. J! Y  T  x. u
}[/mw_shl_code]0 [6 Y' f7 C0 d& Z3 s
上海点团信息科技有限公司,承接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二次开发专题模块培训报名开始啦

    我知道了