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

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

admin 楼主

2018-1-10 17:48:41

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

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

x

& h, Q% B; o% b4 C" C7 T
! C# T8 P0 X- ^( G' Q9 Q. r" @NX二次开发源码分享: 获取当前Reference Component的通用方法& k/ Z/ z" f6 Y5 n+ J
0 Y  y' ?# c. y0 \1 v
) u$ j5 D' [' X
# M: \; d4 [) ]4 Z$ h& W+ b

) k) u$ d0 `* y  T+ a3 [' b  _8 c- M2 f: l
[mw_shl_code=c,true]static logical attribute_exists(Component cmpnt, char *title)
# e- K1 I1 p' {4 z8 D2 U8 F9 p{5 w( J" _; H1 e

. {, ?: V% N( @- u( O1 ^//  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.# {, a  B' M& Z
   
3 `/ `0 R0 m- O# m3 ?2 B    logical
- {) `) Q& _3 x% v' V2 l; W        hasRefAttr = FALSE;
# w- q) q" v( q9 S9 \4 g+ [  c$ z" k" C& b, n; g  m5 m( N8 I) A
    hasRefAttr = cmpnt.HasUserAttribute(RO, NXObject::AttributeTypeAny, -1);+ p. ~; Y% }1 G% d3 B; W) L

. o- d; h5 w4 B/ q. o4 t$ N3 J( X    if(hasRefAttr == TRUE)% y7 W) W8 v$ t
    {4 s* b& c. L2 u
        return TRUE;
" s) A8 P) z0 l" C) b% x    }3 W4 I& [* U0 F- g5 g4 o$ m3 H3 s
* S* F9 F/ ], L6 T
    return FALSE;
# Z) t  Q( @, G+ Q; r
8 E: Z  e0 K* _/ E}
6 F0 u( p6 k- e4 \+ C. k8 L, C
static tag_t ask_next_of_type(tag_t part, int type, tag_t object)
, H. @7 l  Y. O% H+ p5 U" g8 ]{
8 x4 k( `! P9 [# l0 ?    UF_CALL(UF_OBJ_cycle_objs_in_part(part, type, &object));3 |! T3 c4 i* Z8 i8 d  Y
    return (object);- w% \/ B5 V+ [) S: {& J5 C) ?
}
. {( ]  S8 D8 F& {, f7 }6 w- V3 |* n2 {1 ]+ y$ x
static void do_it(void), l* P# T% z0 `; L6 ]# O0 Z, T
{
# O% G6 `% D+ H4 y* F& V% a8 l    // Assumes that the display part is the top of the assembly7 M* ]: Y6 R$ W7 j7 P7 H& U
" J1 T7 z$ i% v8 C
    tag_t
* n, V  v) D+ X/ d' G- i+ \        dispPart = UF_PART_ask_display_part();
, m+ v3 p. T3 g  \, |! s
$ P( [' x9 U) \( ?7 m/ m0 q! E: ~    if(NULL_TAG == dispPart)
  R% S9 N" F# y; D    {
! v* z1 s  ?: }# ~& d7 V        ECHO("Program requires an active displayed part");
1 x, A% d! s4 l" a& B8 y        return;1 w- l2 |- m% T/ C* A
    }& v9 Z. n% M0 s+ _- F

6 C2 l- ?+ `: [1 P    tag_t
  u, @5 z# a: X, D9 p% z        compTag = NULL_TAG;
7 Y/ Z% r( S9 j
2 J) n5 A, t1 g- P' o    while((compTag = ask_next_of_type(dispPart, UF_component_type, compTag)) != NULL_TAG)% H% H7 G0 O  N* q% Q* S
    {- t# j; I. H7 g: o, ?
        char
1 F0 |' O6 H# }4 H; l2 J            msg[512] = {""},* V6 b. f8 Y6 t( U2 J; p
            fSpec[256] = {""};. g" K5 J) ^# f4 z- [0 s& M
: v& [$ ]3 T3 k1 A; e. d
            tag_t& r' U4 B! N, ?4 Z& x  e3 w
                protoPart = UF_ASSEM_ask_prototype_of_occ(compTag);
( E2 ~* Z, O+ q: ^; r# p, U. h: }+ q0 v8 ~  b
            UF_CALL(UF_PART_ask_part_name(protoPart, fSpec));
8 _! ?( [$ i+ y# g+ N
, h( E7 v6 H2 @- n& ^; `4 a            // uncomment to see all component names:
7 E7 n8 E+ t' r& j& `$ ?, Z            //sprintf(msg, "Component Part: %s\n", fSpec);$ K  E& Y: i6 r. ?
            //ECHO(msg);' k% h7 n6 R/ k+ A: \; k) x

' ?- f" I- X  g9 K& V! G; `' D1 q            Component *theComponent = (Component *)NXObjectManager::Get(compTag);' c4 Q; d5 }, ~
            if (attribute_exists(*theComponent, RO))
; F4 v( c  }6 A$ |4 y            {
3 k$ T# h0 l1 ?0 m; _1 g0 J                sprintf(msg, "**** Reference-Only Component: %s\n", fSpec);1 B6 @/ Y, {1 x2 T# r& F$ F/ }+ U$ A
                ECHO(msg);
& W% b% |# p& Q$ L            }6 _3 L* K0 E. b6 e
    }
( O9 X0 U; l. e# Y) u  Q, x}[/mw_shl_code]
$ x6 G+ L, {0 R: V+ l
上海点团信息科技有限公司,承接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二次开发专题模块培训报名开始啦

    我知道了