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

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

admin 楼主

2018-1-10 17:48:41

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

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

x
: G2 F8 \: x  [: |
9 |/ x) v7 h/ m* S, R( J  ]( R
NX二次开发源码分享: 获取当前Reference Component的通用方法+ c8 i' ~9 P$ R) T5 z6 o- i9 T+ n% y
( W( s" y/ X& ]5 j0 s5 P( A
- D2 z; c" A+ T$ m

5 T3 r9 _2 {- y2 R6 u; Y$ P& E
/ k# V( ^1 b2 a2 P- ?8 B3 l2 E: v& w) J- W* L
[mw_shl_code=c,true]static logical attribute_exists(Component cmpnt, char *title)! _2 l9 e% l7 K! j
{4 e, l& I' X( O5 E5 A, d1 n1 @
% r" G/ N, H7 a) g1 U; }
//  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.* z0 K; }3 r' W3 Q- D
   
. {  N: E( S3 J( I    logical
5 b, R/ p9 u5 v/ l6 Y        hasRefAttr = FALSE;. U3 N, I! l7 w- r: Q- Q) x2 o* y: i/ ]7 b
# F8 n5 ^  ^2 z: |" h$ m4 K1 C! J
    hasRefAttr = cmpnt.HasUserAttribute(RO, NXObject::AttributeTypeAny, -1);$ k+ w" M; }2 i$ T, G) J

6 y  t1 f3 ?# t" |' D5 u4 F* j    if(hasRefAttr == TRUE)
+ X5 [5 A6 Q: b9 X% C9 E    {
+ A/ H1 _, S6 U  ?, a* E. w- W        return TRUE;
8 T8 w* C( b4 r; e% v! i    }+ E$ \  g  A* }3 o1 K% V. p
+ H/ _8 y, Z% e# [) G  S
    return FALSE;
8 {  s8 k- f! _9 f
# T6 y. b6 @% g}0 y# G% K3 b- r7 p! R( c

) B2 P* g* h/ Bstatic tag_t ask_next_of_type(tag_t part, int type, tag_t object)0 z4 u+ d- h2 `0 V: u! P# Q
{! c. N/ K- x2 e0 r
    UF_CALL(UF_OBJ_cycle_objs_in_part(part, type, &object));
/ A# B/ ^) I/ Y; K/ o( G" G. h    return (object);1 a' i3 R$ p6 k% c
}, |! A5 ]6 {) i1 V7 x! E
" \- I/ p# _' x' B! v  c5 O
static void do_it(void)  d; R& Q0 M" D- R
{
5 V! E, f1 r8 O6 m. Z    // Assumes that the display part is the top of the assembly2 ]2 `+ v. W! Z/ e7 l! W4 I

6 C- ~. E/ T$ n$ C) Q+ M% {9 q# `    tag_t  s1 ?9 S' P4 J9 O; {
        dispPart = UF_PART_ask_display_part();
! L& U: ~! [4 W. d5 f! C2 r0 {! D& ~8 i4 q; B1 h
    if(NULL_TAG == dispPart)
- h9 ~+ d* X5 |* }3 H' p0 B    {' P( a  u  I  ?7 ~, u2 e5 |
        ECHO("Program requires an active displayed part");
" l4 D( r0 u; }  }( V        return;. u3 F3 W# k  M8 o
    }: H1 T+ D7 C9 c5 N  k5 y  Q

. O; d* y2 n8 m1 H1 L    tag_t4 Z5 {& n  j! u' h+ I; \; J
        compTag = NULL_TAG;1 @( j1 \1 A- z  x% c

, N+ J  X' y3 f    while((compTag = ask_next_of_type(dispPart, UF_component_type, compTag)) != NULL_TAG)
6 [0 `3 f7 g6 L9 p) f    {
  Y6 i; K$ O, d1 e" j' p* z; {        char
: |$ i4 \$ a* @* R            msg[512] = {""},
; u! ?1 p$ n: J/ Q2 p1 [; K# V            fSpec[256] = {""};/ l& Y. v9 s. f+ L2 S
6 {0 V$ Z) F/ W; Q0 }' P" m
            tag_t
& J' D5 N1 o* b9 n                protoPart = UF_ASSEM_ask_prototype_of_occ(compTag);; X# p7 i. W# O5 y- H

" V4 \5 k( l2 ?  j' o            UF_CALL(UF_PART_ask_part_name(protoPart, fSpec));- Z; ]! P7 [; |; Q% M4 S7 G. L

! U2 ^+ @% V. @8 [2 k5 O$ N9 W            // uncomment to see all component names:
9 f6 B: N) P! }) g! f            //sprintf(msg, "Component Part: %s\n", fSpec);
0 a4 d  p5 m8 N3 N2 o0 Y            //ECHO(msg);1 R" S2 T5 w0 O. ]8 s4 y

% c; a3 b  i/ z& J) O            Component *theComponent = (Component *)NXObjectManager::Get(compTag);
; o5 f' T" f# [9 u/ l; a6 w            if (attribute_exists(*theComponent, RO))" f. M% C/ j+ r
            {
* g( x& s+ p9 q! U- V& c# L                sprintf(msg, "**** Reference-Only Component: %s\n", fSpec);+ D6 U$ @; O) n- S3 Y
                ECHO(msg);, {( I% o% U% J- Q
            }
0 d2 i" {1 p4 o" {9 c) x+ E' s    }$ l) S" m% S7 X
}[/mw_shl_code]
0 X  j( A  g7 f% @4 N$ a0 r
上海点团信息科技有限公司,承接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二次开发专题模块培训报名开始啦

    我知道了