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

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

admin 楼主

2018-1-10 17:48:41

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

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

x

4 t3 }, Z7 [0 j( K" z) t* l
7 K$ Y9 }# x9 y+ E6 lNX二次开发源码分享: 获取当前Reference Component的通用方法" r" {% g$ `  ~3 J3 K# r- `
0 s# P- P+ [) `& G8 j5 @6 v

4 |) H* {3 K- `9 T) d0 ?- _+ q1 C; q. f& D$ p0 b0 L
! [2 I( [) `2 l. |$ O! u

7 T, v6 W, a/ H! i0 F# \7 ]5 R[mw_shl_code=c,true]static logical attribute_exists(Component cmpnt, char *title)
; U" v( F( b) \( F9 {6 ^/ L  {{, T) K8 t( G5 r7 b) c

6 x. i8 |8 Z6 p1 _+ [//  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.
( d; y/ T% u( T' Z9 O# M    % m( m( D( `- J# L& d9 s. i
    logical5 r/ @$ `9 @- W$ p
        hasRefAttr = FALSE;
7 a" p$ d$ x. ?' c$ T3 Q' M- P& h, J' B5 A4 Z' D# c  j
    hasRefAttr = cmpnt.HasUserAttribute(RO, NXObject::AttributeTypeAny, -1);
% D* Z# E) s8 {' p! f5 x/ r0 S: m1 u: T/ B# q' V3 w
    if(hasRefAttr == TRUE). z* u( Y( @. u7 x
    {
( c3 o8 |0 ?$ [7 c% f        return TRUE;
( v* M3 ?0 n9 V' c, a6 Y0 l# \/ V5 J1 m0 e    }
3 g" E1 ]/ g) d
0 l; b) j; I' U/ ]( G, I    return FALSE;
: d$ Y& _/ I9 q7 ~% t% w$ [& M8 K# D
}
, O& }! j  @# `, b$ q+ E3 E5 ~) O- s0 |: _& j/ [
static tag_t ask_next_of_type(tag_t part, int type, tag_t object)
) H5 L0 D2 \9 m$ i{- s# l+ W1 K. E6 n; s4 h$ R
    UF_CALL(UF_OBJ_cycle_objs_in_part(part, type, &object));
/ m3 J" a3 B1 @7 z$ o! v9 B) d    return (object);
$ A0 P5 T# L# V; i) s) l% F$ o8 ?}( B0 a1 N; o, J  J9 P
3 _1 [0 S" }5 A. c. Q7 A
static void do_it(void)
5 F3 d# m% h. ^8 v, t{
% R* Y5 V7 s, O5 R+ K    // Assumes that the display part is the top of the assembly+ @2 B) }; {+ @' a

& ?/ ]2 v3 O+ V* c- I) d    tag_t
' F  {+ a; h: k& ]5 ^$ u( R) @        dispPart = UF_PART_ask_display_part();. o% r! T$ ]0 I/ C! W1 |0 t

" c5 `  e4 A7 N3 n% \/ W    if(NULL_TAG == dispPart) + B6 q  \% }* g3 h1 v9 m/ C
    {; ?6 x, M- m" X1 Q# E2 l
        ECHO("Program requires an active displayed part");0 U+ Z7 j9 w, V! w# d9 ]6 H
        return;- r, s, F  ^& A4 [+ y0 n
    }
  M, U+ u: f# A8 g) w8 F; y1 y! J2 l/ A0 }# ^9 l
    tag_t5 R: K' ]$ l- T& E* T" c$ f6 h9 W& T
        compTag = NULL_TAG;, \, i* {  o* G6 }0 n
1 J: l: E& x6 d6 n5 N
    while((compTag = ask_next_of_type(dispPart, UF_component_type, compTag)) != NULL_TAG)) U6 x' h/ O/ V1 g- p" ^' l5 \
    {
! ~7 Y( D8 ?9 `( F1 g        char
' }& o$ R' V3 M0 O            msg[512] = {""},8 K% a/ U9 Q' s
            fSpec[256] = {""};, r& e; x# f1 \- I5 `
3 r) `) Y3 s# E7 \. F
            tag_t1 d& C1 t, [) N& i0 {' X# O
                protoPart = UF_ASSEM_ask_prototype_of_occ(compTag);& h( w1 z. A/ d4 m  p0 G* S1 ?

% I3 o5 P1 d8 D0 c            UF_CALL(UF_PART_ask_part_name(protoPart, fSpec));- a- T/ y3 P9 U* S5 d

# k; ?* E, F6 J9 U+ a* {            // uncomment to see all component names:; b! w" |3 S8 W
            //sprintf(msg, "Component Part: %s\n", fSpec);
& \" [" D! A" r            //ECHO(msg);* C4 r: ?* u9 n8 d* V) N
! G9 E4 s, b4 I- Z) x/ P
            Component *theComponent = (Component *)NXObjectManager::Get(compTag);
. g8 D& H! t6 J, B$ p            if (attribute_exists(*theComponent, RO))4 q4 ?- B* J: y$ r* d; a" a4 Q
            {
( J( ]0 C, m6 ~" z5 }/ o9 v                sprintf(msg, "**** Reference-Only Component: %s\n", fSpec);
4 Z* B* ?  P# f9 V, n                ECHO(msg);
2 g. \7 ?. ?9 F; b: I; ~            }$ H' e, b' `. M* `$ W+ K
    }
1 A- s% l. t* s7 e" s! i9 c}[/mw_shl_code]
) n- B+ X8 f, [5 n
上海点团信息科技有限公司,承接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二次开发专题模块培训报名开始啦

    我知道了