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

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

admin 楼主

2018-1-10 17:48:41

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

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

x

$ d  v' F3 h. x9 b5 m* ], |( k9 |- S( R, L2 `
NX二次开发源码分享: 获取当前Reference Component的通用方法  n3 W; i+ r  L$ k% |
; s& {. Q3 v& d& u1 f; o

+ C0 Z4 ?4 |" P
% S# \  n: @# g& B9 x- l1 o+ J2 L; h; J, |

8 E; [5 u$ S) Y2 b0 L[mw_shl_code=c,true]static logical attribute_exists(Component cmpnt, char *title), d1 m% A4 Z: S: i5 m
{: Z) F- Y( ~- l/ D

! o( k/ v1 ~1 ?) H+ q6 R//  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.( h" ?, v2 ]8 G9 x& ~1 F7 m
   
1 X* C0 M9 f+ r# p8 f1 W. |+ _    logical
5 E, K# m0 c# e$ u! Y        hasRefAttr = FALSE;
6 L( [) c& [5 S+ S8 Z
$ {' h& l$ o: U5 H' ~  K    hasRefAttr = cmpnt.HasUserAttribute(RO, NXObject::AttributeTypeAny, -1);, n! X4 C1 ?* R  Q! {4 B: z9 d
  ?5 z1 A( i. W  {) p# e* o
    if(hasRefAttr == TRUE)
) h5 j; B$ G+ `% ?4 D4 }3 f    {
! [3 G1 P( d, D        return TRUE;  A+ y# Q/ m- D% N; ]
    }' [( K0 @: C  L% a1 S" n3 u  J

4 v; f# A+ R4 Q" e. `    return FALSE;
. X  V, J0 i. _, E: Y( {# O/ C/ U* h( g; M2 S( \
}
8 ?3 m* g. P% L% J  {( z
" Q9 X6 p* ]6 c+ ^1 [* d, _static tag_t ask_next_of_type(tag_t part, int type, tag_t object)
8 {. V" t2 P6 ^# W, M( T% Z{, p! X; x- X- Z
    UF_CALL(UF_OBJ_cycle_objs_in_part(part, type, &object));; a. K; i! a- `
    return (object);
& }2 S6 {9 b& F  i0 P}% j5 c" h3 W( |! K

6 z0 Y2 q) a2 xstatic void do_it(void)
' C" Y; K4 c; a) D- M{
" R9 l3 A* ~) R4 D5 A8 D, o6 ^    // Assumes that the display part is the top of the assembly
& R$ j* D, @6 D( y# H' I4 }  }% }. g; q' m1 x, A
    tag_t
* M0 I  |# L! A/ N        dispPart = UF_PART_ask_display_part();
8 C6 ?6 I/ `4 `# F: N, j7 Y9 E' a" y- ]( U* c
    if(NULL_TAG == dispPart) & l& ^2 N. }+ T* r& ~
    {
# J1 j% m9 Y. f- v        ECHO("Program requires an active displayed part");
( C. H$ ?& @% C2 O! x( y: P( W        return;
2 z' _+ N( p0 D' W* H. C    }( s5 i$ ^! B. s; i, V% o/ b" }* J0 s
! ?8 o) S0 U  P8 v/ a/ f0 y% B
    tag_t
2 K! `8 k; l$ ^, M9 C. j% Q8 B3 O        compTag = NULL_TAG;) m: b3 ?- |! @7 e; p$ T8 k8 `: q
  H8 M/ T- i3 K! D5 e$ K
    while((compTag = ask_next_of_type(dispPart, UF_component_type, compTag)) != NULL_TAG)  W9 L  a, J) ^0 }
    {+ F/ B; ]/ b# n! I" j) z
        char0 Q8 a% A( S! i% b) h
            msg[512] = {""},
! ^: X) \+ h% X4 o3 S' ]1 x' w            fSpec[256] = {""};- X, q) ^4 f; ^$ Z
7 v4 c5 U" t, _: H
            tag_t& X& d8 s& \+ H, ~
                protoPart = UF_ASSEM_ask_prototype_of_occ(compTag);
: I0 I+ O# K% G1 N: h
) w5 b5 O6 D6 Q3 r2 u5 m            UF_CALL(UF_PART_ask_part_name(protoPart, fSpec));
' W8 j4 U6 X) m4 p1 ]
, H. P. T3 e0 h% C, u            // uncomment to see all component names:
: o& [9 k# ^7 N0 n6 c, U% Q            //sprintf(msg, "Component Part: %s\n", fSpec);  Q" P  {0 R7 ~! {
            //ECHO(msg);
7 I3 r% D  K# i" P, k- W  ^" R5 `, d% x5 Z' \, \0 `8 U$ _) O- M
            Component *theComponent = (Component *)NXObjectManager::Get(compTag);
, s; [$ r; E! J7 A: @% v' c& r            if (attribute_exists(*theComponent, RO))$ @6 g1 \% J) k$ y: h
            {
6 q) r9 b& n7 |" b1 M7 I                sprintf(msg, "**** Reference-Only Component: %s\n", fSpec);* s9 h& v$ K; K! v( ]0 R* y" s% s
                ECHO(msg);
9 e0 L1 k. O, l5 G/ q3 p2 B7 S4 t            }% j9 s! Y/ ^+ v/ ~% P
    }
  X: J. R" _, c}[/mw_shl_code]& ]& i9 B+ ?3 i& X
上海点团信息科技有限公司,承接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二次开发专题模块培训报名开始啦

    我知道了