PLM之家精品课程培训,联系电话:18301858168 QQ: 939801026

  • NX二次开培训

    NX二次开培训

    适合初级入门或想深入了解二次开发的工程师,本培训结合ufun,NXOpen C++,大量的实例及官方内部的开发技术对于老鸟也值得借鉴!.

    NX CAM二次开发培训报名 NX二次开发基础培训报名
  • PLM之家Catia CAA二次开发培训

    Catia二次开发培训

    Catia二次开发的市场大,这方面开发人才少,难度大。所以只要你掌握了开发,那么潜力巨大,随着时间的积累,你必将有所用武之地!

  • PLM之Teamcenter最佳学习方案

    Teamcenter培训

    用户应用基础培训,管理员基础培训,管理员高级培训,二次开发培训应有尽有,只要你感兴趣肯学习,专业多年经验大师级打造!

  • PLM之Tecnomatix制造领域培训

    Tecnomatix培训

    想了解制造领域数字化吗?想了解工厂,生产线设计吗?数字化双胞胎,工业4.0吗?我们的课程虚位以待!

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

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

[复制链接]

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

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

admin 楼主

2018-1-10 17:48:41

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

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

x

- B. _  u1 e- ^% I* S! h* n
/ G9 r5 V8 ~. a# @NX二次开发源码分享: 获取当前Reference Component的通用方法# i; ~2 n9 ~6 h5 ~

% d$ A! [$ H, u6 p. V* n. N) f2 f/ z

4 W5 v* Y: A3 P0 G6 j9 E! O& P2 @+ _! R9 \% f

' _8 c5 g' m4 G, b3 v3 ?" n. A9 }- _4 z9 k[mw_shl_code=c,true]static logical attribute_exists(Component cmpnt, char *title)
, W1 ^1 K% n  q{1 z9 f6 ?0 T0 q1 x/ h
; z3 P0 p3 ]% L1 T! |1 I
//  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.( y8 }! U! P6 K7 {* B
    1 E3 @; R. y) t" Z# i3 b
    logical1 n  A- c4 u" f
        hasRefAttr = FALSE;
/ t. }3 Y! r0 q6 c* |
3 d$ h" z, r$ d1 n+ V9 _    hasRefAttr = cmpnt.HasUserAttribute(RO, NXObject::AttributeTypeAny, -1);
+ i  N" |( K/ X- U
/ l* d  }$ n; ^2 h0 }    if(hasRefAttr == TRUE)- B: R8 W6 Y0 g( F
    {! y2 `# X- J4 q$ B3 E. y1 n2 ~
        return TRUE;% z2 }( q* p9 R6 j8 M
    }% ?  E5 E5 p* [/ v# D

  t' B& O" H: i+ X% X0 h0 w0 d    return FALSE;( i$ ^0 C8 m/ `4 i& K8 {$ |
2 \, [! i9 N0 L/ ]$ [' S% \
}' G2 }# `. c. A2 K8 r2 W
0 T; L9 `3 v, h% E. x4 y
static tag_t ask_next_of_type(tag_t part, int type, tag_t object)1 N5 U6 @. r$ X' F: F( ?
{
2 Z; B9 L+ P! j- W  w2 v3 J    UF_CALL(UF_OBJ_cycle_objs_in_part(part, type, &object));/ O" W0 k  f- S9 @) J: R0 L3 S
    return (object);* k! L! r7 d5 z% E+ ~
}: y0 }+ q9 @8 }1 s

' A4 I* t2 b; R4 ]  Z* y, Vstatic void do_it(void)# E+ B& C/ Q# f5 F: o& V
{& S* Y; Z- g8 m- B$ i( Q4 [$ |
    // Assumes that the display part is the top of the assembly, S" R+ K0 u3 k, _+ o- o" M, K
$ u- B$ R! l* p5 r: g
    tag_t% ~/ v9 k$ @* E; @! R0 Y: X
        dispPart = UF_PART_ask_display_part();
* z7 p$ C2 o9 D! [5 S) l  F0 y( @" U! D" w
    if(NULL_TAG == dispPart) 4 q, S' |! ^1 y8 n4 V3 _' y+ G
    {
7 v2 J1 G: m& W9 B        ECHO("Program requires an active displayed part");
  ]; z, J2 t: C4 Y' x        return;0 l" B& p; ]! Z% G% w! [
    }
) V% {! N# g3 h6 X/ T( u& K$ E, W" e0 G9 X
    tag_t  L  g7 r8 W0 I* z0 Q
        compTag = NULL_TAG;
4 P* S; s8 x* X$ D9 n4 b) F* {4 g% ]6 ]/ D, |1 m
    while((compTag = ask_next_of_type(dispPart, UF_component_type, compTag)) != NULL_TAG)
, ~* B, o# S: q3 ], J6 {& a    {
" n" y8 J/ G6 {! e- i' ~( x) s        char
6 N! I- U# ^9 X6 i            msg[512] = {""},9 p1 [$ _' ]8 T
            fSpec[256] = {""};) f  d8 J5 T; n. \
( k3 S% q3 P3 Q" n3 S! a" W/ n
            tag_t
/ j/ c1 t8 y4 I; y% q/ o0 p                protoPart = UF_ASSEM_ask_prototype_of_occ(compTag);
) b- E! ?' J: Z/ ~& y
: R, O; ~: }7 ]* C1 X6 n            UF_CALL(UF_PART_ask_part_name(protoPart, fSpec));
' d; j9 b0 N" C
- @6 ?+ W+ h5 q  e7 _. I            // uncomment to see all component names:( i" Y( ]4 I7 V; x# l% z
            //sprintf(msg, "Component Part: %s\n", fSpec);
- }* B. M! h+ V6 D: n0 x% q            //ECHO(msg);
, c5 ^: R8 H( [; t6 x$ d- h/ u% q! K, ~. h! r! J
            Component *theComponent = (Component *)NXObjectManager::Get(compTag);( d' m* ^6 x8 }) }4 u+ R
            if (attribute_exists(*theComponent, RO))
1 f( T7 w% U  y$ b8 K; b            {
2 Q: Z- ]$ v/ q% q( \6 f                sprintf(msg, "**** Reference-Only Component: %s\n", fSpec);
( O. }5 T! H' X. M5 ]0 [+ y( }9 o                ECHO(msg);' b. i9 @1 N7 k+ R+ V" k# o- _
            }! D% Y4 i  N% [3 H# U, g# b
    }* D' o( ~8 w4 f5 x+ _
}[/mw_shl_code]2 i0 h. j  F6 X. f% G  Z
上海点团信息科技有限公司,承接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二次开发专题模块培训报名开始啦

    我知道了