查看: 3374|回复: 0

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

[复制链接]

6

主题

4

回帖

60

积分

管理员

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

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

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

×
这段代码比较简单,但是你可以学习到如何在CAM里面进行二次开发,比如如何初始化CAM环境,如果查找CAM的程序对象,如何获得加工导航器上的选择结果,如何将对象加入组中。* c( q) }) N% Y, ~
, u( y2 s" b3 I+ E$ u) }
static void do_it(void)
( D$ O/ [& p; j' u8 H/ ?6 D{
  y2 |8 S7 O( t* l1 g    char reason[UF_NCGROUP_MAX_REASON_LEN+1];5 r0 Q  P3 U/ Z/ S
    char msg[MAX_LINE_SIZE+1];
' I8 z3 W5 d: y5 G! _5 Y
* c/ s' r, T# c    int object_count,
# S* |% r6 W# t3 S' E  B6 e) O+ K        type,* g6 l" J; u0 Q' f2 D
        subtype;1 Q# c: @; Q' V# t  B0 B
    $ k% U; R0 G/ b7 ~
    tag_t
7 K& Z% }9 W' H6 N  p* c6 H        setupTag,+ N: l: Z" k% A7 o' k% R
        *objects," T  G0 J5 Q/ o& y
        prog_root_tag,
/ f/ c& I# g; f/ l4 c6 w. b5 u% J  ^. r        prog_tag;& m7 ]/ Q! K7 L* R

' s8 q1 [- l/ W. s8 {    logical  is_initialized;8 N( [. z, w+ R2 U
    logical answer;6 ?: ^/ V! a7 ~9 J
  N5 S% ^6 g% M
2 }% ^, [3 @, d
    UF_CAM_is_session_initialized(&is_initialized);
+ @& [& L' q7 u0 e% \! o: @4 L
- R7 p& x% i$ X7 |" E$ J4 L/ J: g. |, P$ G2 J, i2 b+ t5 O
    if( is_initialized == TRUE )* H: u7 a( k2 g/ J: h( n% e/ o
    {   : @  u$ @0 d! |1 |, A& U! l( {
        UF_CALL(UF_SETUP_ask_setup( &setupTag ));
0 A' ^  y* ?0 Q        UF_CALL(UF_SETUP_ask_program_root( setupTag, &prog_root_tag ));* _. j4 E' l/ T9 P* {

/ ^; O' s; @8 b3 U$ {5 p$ ]  // Find the pre-existing geom PROGRAM and get tag
6 N5 V1 D; L, d$ z, e        UF_CALL(UF_NCGROUP_ask_object_of_name( prog_root_tag, "PROGRAM", &prog_tag ));2 \' {1 J4 T: l7 k
4 r# P, X" Y0 `3 ?7 z. L
     /* Get the highlighted/selected operation from Navigation Tool. */# @- [& Y% Z7 Q
        UF_CALL(UF_UI_ONT_ask_selected_nodes( &object_count, &objects )); # Q4 d# i) |  u+ t; e& V1 U6 t

) a7 h! W# n# a" R8 {" y+ `        if (object_count == 1)
! R9 \. W. r7 i/ v! n" n9 h. v        {
2 H) E) ]; P' F3 l; p            UF_CALL( UF_OBJ_ask_type_and_subtype (objects[0],&type,&subtype));
2 K0 Y; H+ a9 M
) H% t4 {) p, E3 X' Y            if (type == UF_machining_operation_type )
! @4 n0 I* F5 S: Y- W; a* G& Q            {8 M& _& ?6 b0 Q2 S- l) F- H; M) r
                UF_CALL(UF_NCGROUP_can_accept_member( prog_tag, objects[0], &answer, reason ));
% o( [9 K- ]7 C" Z  V5 s# g1 q8 a                if( answer == TRUE )" o. Y6 j7 n* q# N8 [1 \( I
                {& J$ q0 f' I/ @2 q
                    UF_NCGROUP_accept_member( prog_tag, objects[0] );  N" \5 \; B6 E, W. s; P- {$ `
                }
, M: k$ r5 L$ J, G' t8 |, K                else
3 ^; C2 K4 ~' {1 s! R6 V                {
' `. B- K8 W! \) d4 U4 v  m                    sprintf(msg,"program group can not accept operation");
" ^: N* Q+ z) U) h5 p                    UF_CALL(UF_UI_write_listing_window(msg));
% [  K. D3 P2 k; N' K: e, {8 w                }
4 S4 b' s6 S8 W  p" y; D' p            }
. d" P. Q- f! ^1 d& j* R            else
; D+ l7 v4 o1 {+ C9 o            {
9 H% B9 Q: ^/ p+ L1 Y                sprintf(msg,"object type is not UF_machining_operation_type");
% w1 \  x5 K# B4 K  k/ ^% k                UF_CALL(UF_UI_write_listing_window(msg));
8 {3 O2 h3 v" R5 |7 g. ?$ I            }- L/ ?8 U) J5 m) X4 V! v
        }/ V7 i( q7 j* e; j% N8 K
        else
2 `% ]3 \, o' U        {
# R8 Z& H6 r$ q  ]* m            sprintf(msg,"Nothing highlighted");  g  q7 a" Y4 w3 i' j+ l
            UF_CALL(UF_UI_write_listing_window(msg));
0 m1 d( K' V. e5 c9 _        }
2 Q# n0 U) m* s  p1 s: Z3 y
0 a, x5 O; ^- n6 O) X: A5 c# q    } // end of if init
  C$ s: P; {/ X) @" x4 q2 i4 W0 p}
" f9 I+ _* W" `" x  R/ Z" T2 F. X$ t1 c/ ?- r+ Y
上海点团信息科技有限公司,承接UG NX,CATIA,CREO,Solidworks 等CAx软件,Teamcenter,3D Experience等PLM软件,工业4.0数字化软件的实施\二次开发\培训相关业务,详情QQ 939801026 Tel 18301858168 网址 www.doteam.tech
回复

使用道具 举报

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

本版积分规则

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