查看: 3437|回复: 0

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

[复制链接]

2477

主题

1280

回帖

8万

积分

管理员

PLM之家站长

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

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

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

×
这段代码比较简单,但是你可以学习到如何在CAM里面进行二次开发,比如如何初始化CAM环境,如果查找CAM的程序对象,如何获得加工导航器上的选择结果,如何将对象加入组中。
6 w' y8 k8 e2 \. n1 M$ p# k( {/ R& s' |0 l2 w
static void do_it(void)
+ U# e: @+ B, O& K  T: `{
: ?/ Y1 O! c5 a2 p1 [    char reason[UF_NCGROUP_MAX_REASON_LEN+1];
9 V- h& ^4 R& ?1 s! Q2 B% f    char msg[MAX_LINE_SIZE+1];5 c- |& }; d9 p- X; Z% s1 ?
9 u) `+ z5 @1 I2 }# N
    int object_count,/ d# C. A& X; m) c9 @/ ~
        type,) M7 S5 w% t+ s" I- p. W8 j9 A
        subtype;5 ], \# A0 ?' y, t4 D7 t& c
   
. Y0 G0 p7 D* _- t    tag_t
' q; ]" k) p1 h, |# w% f7 i8 h; _        setupTag,
" Y) {5 ^* s' [2 U: ?; h0 |        *objects,% d; P) @* R! s* K/ V6 U
        prog_root_tag,
* h- }2 M, h8 T# F* W: i        prog_tag;
1 W3 a( R# n* w9 T! |! F5 G* \7 x; P8 m% R% c7 u/ x$ M
    logical  is_initialized;
9 o4 D: p' F3 @) o    logical answer;
+ w2 p$ z( N0 V# Z$ R- ?8 x
7 f+ q0 y( X/ L( g9 o8 n) Y3 |2 I! g8 B
    UF_CAM_is_session_initialized(&is_initialized);  Q9 t. b. v. {6 ~* y: _
% u* o: F6 V* R) F
. e1 ^2 }1 q& f: c3 I, x
    if( is_initialized == TRUE )
; J' r! j/ r9 C- O    {   ! y  M! z4 v+ t  y) z
        UF_CALL(UF_SETUP_ask_setup( &setupTag )); 3 k3 o4 B( g& b* Z, {: l8 r0 e
        UF_CALL(UF_SETUP_ask_program_root( setupTag, &prog_root_tag ));
  p! V! D" ^  I0 u6 W, D0 y0 H3 B0 }$ G8 Y. X
  // Find the pre-existing geom PROGRAM and get tag* @/ R; N0 C& M6 R4 l8 r- v, u
        UF_CALL(UF_NCGROUP_ask_object_of_name( prog_root_tag, "PROGRAM", &prog_tag ));
) b* D7 Q- F& R: Z3 E+ m3 s7 J5 C0 s2 Q
     /* Get the highlighted/selected operation from Navigation Tool. */' T/ v3 ?$ q) v" d* j
        UF_CALL(UF_UI_ONT_ask_selected_nodes( &object_count, &objects )); - L6 F- Q( u* W! r" \! r' @  p
) y0 Z$ b4 ^; k% {6 {
        if (object_count == 1)! U- v6 s# U9 |9 r1 ~
        {$ E0 b+ j5 |' v5 u+ {$ V
            UF_CALL( UF_OBJ_ask_type_and_subtype (objects[0],&type,&subtype));0 g8 e) I( g- r5 Y
) y; _# H- c* y
            if (type == UF_machining_operation_type )
- p1 B$ F4 z& V% `( F' V            {
' n7 K3 H0 @' ?                UF_CALL(UF_NCGROUP_can_accept_member( prog_tag, objects[0], &answer, reason ));* F6 s2 j+ s  h$ s8 ~% |
                if( answer == TRUE )
+ ~/ C8 R; [6 f$ ^                {
3 E; i1 Z; w2 V& T                    UF_NCGROUP_accept_member( prog_tag, objects[0] );
: F$ t/ y0 K& u( [- c7 c( b                }
. F# ]# y: \% c7 X( Q                else : J0 d! j; P+ l1 h4 }7 H
                {
+ a- m& ~0 g: g4 o: K- @& ^# @                    sprintf(msg,"program group can not accept operation");
! y( y5 {( h1 H0 C) `) J! N                    UF_CALL(UF_UI_write_listing_window(msg));
. K2 ?3 z3 C4 G- L) q: H+ |                }
7 b; j5 g. l  V# D8 a9 w% z            }
& \* r) b+ R& Y: b4 N9 E  z            else9 `# p6 g! N* K/ }; W$ f) k0 a
            {5 E1 R/ q# C1 _% U
                sprintf(msg,"object type is not UF_machining_operation_type");
% R! |% c3 B* U3 g. W( E( @5 D                UF_CALL(UF_UI_write_listing_window(msg));$ v' V7 Q  U8 u: S+ _7 i
            }: P% U& X  D0 |- S
        }3 {& O8 y* W# d- ?
        else9 r# I% N4 V/ M4 k. \% S& e
        {
+ `2 \3 B* e* a. L8 V" c$ W+ A            sprintf(msg,"Nothing highlighted");
: `8 R3 m/ F8 h/ b, e0 N            UF_CALL(UF_UI_write_listing_window(msg));- O. B6 L+ U8 s! u. m% O* E! s
        }# X; u* Q% ?7 L+ L" Z4 ?

4 A/ K5 W, t' T# |    } // end of if init: F% F4 l9 `6 \& x
}
; p) ]$ x- P9 Z( r6 t8 ~9 x3 \0 c  p/ N# s: b1 W/ @
上海点团信息科技有限公司,承接UG NX,CATIA,CREO,Solidworks 等CAx软件,Teamcenter,3D Experience等PLM软件,工业4.0数字化软件的实施\二次开发\培训相关业务,详情QQ 939801026 Tel 18301858168 网址 doTeam.tech
回复

使用道具 举报

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

本版积分规则

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