查看: 3099|回复: 0

[二次开发源码] NX加工开发源码分享:移动选择的程式到其他组

[复制链接]

4

主题

3

回帖

44

积分

管理员

积分
44
发表于 2015-1-4 20:20:10 | 显示全部楼层 |阅读模式

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

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

×
这段代码比较简单,但是你可以学习到如何在CAM里面进行二次开发,比如如何初始化CAM环境,如果查找CAM的程序对象,如何获得加工导航器上的选择结果,如何将对象加入组中。0 ~7 t& n) W3 E9 r
/ O* U( u5 s& i
static void do_it(void)# ]6 d4 w7 H. I8 }$ Z
{% g/ M6 O# w) x- h6 X" N
    char reason[UF_NCGROUP_MAX_REASON_LEN+1];
% \+ q- H8 i' @9 |+ W7 C# C    char msg[MAX_LINE_SIZE+1];
( d: s2 |4 U+ P. R. L! s" A) M9 z# _: G; N& ]
    int object_count,! E/ Y: g9 N0 U$ b4 e  l
        type,
% j- o4 e) ^2 H5 P, v9 ^. @6 Q        subtype;+ d* Z1 `0 V, S
    8 O2 V& _  d: _: m: E# K+ V
    tag_t
6 P5 e7 Q) V3 \% [! s$ E6 p) r        setupTag,
5 Y3 |! y7 I. K        *objects,
- N; R/ r% ]  Y        prog_root_tag,$ a( V8 Z6 q' A7 @2 a
        prog_tag;
- r! U' A9 r/ x9 H, e7 Q3 p6 f! B, G: o
    logical  is_initialized;: }" _. @9 d, ^9 m9 i* P
    logical answer;5 V" X; X2 m% G# W1 V

" ]" }6 N) t5 b8 v
% H9 s9 U; R4 [% u    UF_CAM_is_session_initialized(&is_initialized);
" q  u" u3 L! l9 O# B* x0 ^4 h, }% u7 {3 D! F" {+ S

8 o, i9 N5 K* X# i+ R5 ]    if( is_initialized == TRUE )' h% z' V+ q# v8 p! a" f
    {   
8 f4 P' j" c- E* {8 a9 l9 h  P4 e" k        UF_CALL(UF_SETUP_ask_setup( &setupTag )); ) b9 E* N8 d! s5 d0 G. L
        UF_CALL(UF_SETUP_ask_program_root( setupTag, &prog_root_tag ));9 P$ x+ g' x) I+ ]& e

( j9 {! r7 u2 r5 ]  // Find the pre-existing geom PROGRAM and get tag, s9 P2 z9 e5 }% Q- R. {( l3 V
        UF_CALL(UF_NCGROUP_ask_object_of_name( prog_root_tag, "PROGRAM", &prog_tag ));
/ X! q2 Y1 A9 Y. [
5 l- b# j* h8 E6 E4 |     /* Get the highlighted/selected operation from Navigation Tool. */
2 j) F; S# x6 [& \) f        UF_CALL(UF_UI_ONT_ask_selected_nodes( &object_count, &objects )); 2 Y1 W0 m8 S' r) m+ P

  ]1 C2 y6 S8 `        if (object_count == 1)
& g5 R$ m( r$ \2 z' `7 L4 B        {
2 w1 h7 Y" t6 H) d7 C. R            UF_CALL( UF_OBJ_ask_type_and_subtype (objects[0],&type,&subtype));
: S( U* T# @' z# H! i- `
. B" ~3 z9 X6 {6 f5 i            if (type == UF_machining_operation_type )8 S; U$ S) m4 h. b1 }" F1 g
            {. {0 ]3 F8 C( g1 J/ S0 T2 B6 ?
                UF_CALL(UF_NCGROUP_can_accept_member( prog_tag, objects[0], &answer, reason ));
8 m: K, G9 |$ k                if( answer == TRUE )
% V9 M0 t1 s" v& J- s. @9 T                {, E! O" B7 _4 K# d
                    UF_NCGROUP_accept_member( prog_tag, objects[0] );9 O$ f7 c( O- @5 f# n
                }
0 q" b4 U* o3 m* J0 |& N                else
; y; o3 U: |# u5 {0 h                {
6 x. I2 X2 Z1 d) e7 }6 _5 r                    sprintf(msg,"program group can not accept operation");# b; n! J& n8 `9 T! `. O. ]
                    UF_CALL(UF_UI_write_listing_window(msg));$ l8 U) a+ V+ X8 e- d( N9 h
                }% s. @6 q4 L+ d5 L4 g" E* }
            }
. t% Z: ?4 t- E            else
4 ]! e9 w3 I$ x* w% Y7 H7 p( k            {
: a) R9 s0 ?) c( _                sprintf(msg,"object type is not UF_machining_operation_type");5 e- }# Z6 M$ {: Y- D. N
                UF_CALL(UF_UI_write_listing_window(msg));* _7 X+ Q6 U6 x  H  T
            }  e4 ~% K3 I# f8 |+ ^) F) B6 x
        }, h- h) c0 @; I( Q6 w( e
        else
, |9 ]0 e# k& \/ |        {' [7 K. |; {0 c, `; s  v3 N2 }: `
            sprintf(msg,"Nothing highlighted");
2 }/ Q  g5 k; E+ [! h  f3 \            UF_CALL(UF_UI_write_listing_window(msg));
$ L) V- h1 x% F, b        }
6 E" c# Y! x+ @, C1 C
3 U) \( S2 g4 Z    } // end of if init+ H2 T& ^, m( C; ^! @) n
}8 Z- E5 q  M" d( o8 h* ^) I. d0 y- V

$ K' \  V! n% ]- ~
上海点团信息科技有限公司,承接UG NX,CATIA,CREO,Solidworks 等CAx软件,Teamcenter,3D Experience等PLM软件,工业4.0数字化软件的实施\二次开发\培训相关业务,详情QQ 939801026 Tel 18301858168 网址 www.doteam.tech
回复

使用道具 举报

您需要登录后才可以回帖 登录 | 注册

本版积分规则

在本版发帖
关注公众号
QQ客服返回顶部