PLM之家PLMHome-工业软件与AI结合践行者

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

[复制链接]

2015-1-4 20:20:10 2929 0

admin 发表于 2015-1-4 20:20:10 |阅读模式

admin 楼主

2015-1-4 20:20:10

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

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

x
这段代码比较简单,但是你可以学习到如何在CAM里面进行二次开发,比如如何初始化CAM环境,如果查找CAM的程序对象,如何获得加工导航器上的选择结果,如何将对象加入组中。+ M, Y$ E4 G% W2 K

/ }+ `  r- \% L" }0 lstatic void do_it(void)' M4 R: X. j( [) [" @" Y* x
{
  M5 s0 I  [  U$ c+ U; R1 \    char reason[UF_NCGROUP_MAX_REASON_LEN+1];" V6 ^% g  e1 d0 W
    char msg[MAX_LINE_SIZE+1];: _, e3 @( C5 j6 k& z9 \/ F
& h- i; I) m7 M' @9 S- z1 s3 r
    int object_count,  w' t& l5 ^/ n
        type,: r8 X  O& O4 E' b* p1 h
        subtype;7 e. Z# n; q& B* m
    / C5 p# P  i, m* Q% m& H
    tag_t
' ]6 \. }- P  Q7 B! B        setupTag,
/ }. A2 }1 N, F- u( I        *objects,. M7 d! V  |2 @& f, W, x: v, i
        prog_root_tag,' d6 |4 E. u( G, i/ ~5 [1 D
        prog_tag;' E  p+ Y* H! f0 b2 s
0 Q$ t* A8 ?; n# |
    logical  is_initialized;+ [& B5 r8 E/ }+ v- f
    logical answer;. u; G- O' {4 o. C- v1 q4 Q# @

6 h. j9 |* q; `& L9 n. E! V
3 {6 `  J" S3 W5 x- y% y: D    UF_CAM_is_session_initialized(&is_initialized);. E3 }/ d5 |+ S

$ L- H/ S, \5 h1 R7 w* e8 I$ h7 k; Q' g4 y* J/ W
    if( is_initialized == TRUE )
8 h: [# z6 `, {0 e( k8 D    {   2 t5 @! `7 W: s
        UF_CALL(UF_SETUP_ask_setup( &setupTag )); ; e$ P9 W, q2 P
        UF_CALL(UF_SETUP_ask_program_root( setupTag, &prog_root_tag ));9 V9 U9 U( ]: k- A5 j& _  m+ Y

9 P/ a8 A/ }( H1 t  // Find the pre-existing geom PROGRAM and get tag* U2 K& F4 |0 w* |4 P/ w
        UF_CALL(UF_NCGROUP_ask_object_of_name( prog_root_tag, "PROGRAM", &prog_tag ));
% N+ e( m0 f! X7 P7 U
3 l8 j4 A  A3 ~& M) S4 j     /* Get the highlighted/selected operation from Navigation Tool. */
5 }" E7 G) m) t$ ^  D0 d        UF_CALL(UF_UI_ONT_ask_selected_nodes( &object_count, &objects )); 9 _3 [1 H& W' F, Q4 \1 y

8 v# F1 P/ U% [9 R        if (object_count == 1)
% `" W: o. T+ Z: ?        {9 {. v- m! g# o& e. O+ W
            UF_CALL( UF_OBJ_ask_type_and_subtype (objects[0],&type,&subtype));
$ Q4 @5 b1 R7 K8 ]9 D; b) U1 P+ X7 m& U. n0 i* N( J, ]' h  @
            if (type == UF_machining_operation_type )) P9 d4 Z! I6 ~5 z5 ^
            {, h0 w2 a! p3 M4 F% W
                UF_CALL(UF_NCGROUP_can_accept_member( prog_tag, objects[0], &answer, reason ));$ r, t" ~' G, J
                if( answer == TRUE )( x9 O/ Q/ V$ t3 n+ T. j
                {
: N" _# Q' B+ j* e  _                    UF_NCGROUP_accept_member( prog_tag, objects[0] );8 P2 r9 W- r; ^
                }
9 z  d" H) w8 D2 H7 d) {                else
7 H: d9 L$ w6 g7 H0 Z( c3 a                {7 K$ t" d4 Q$ X. r/ N
                    sprintf(msg,"program group can not accept operation");
$ ]* m4 P' J7 s- s0 e+ T                    UF_CALL(UF_UI_write_listing_window(msg));% Q3 {& i  k& B& `5 v) B; l  ]" L. k
                }: z1 P1 W" @4 Z2 W; D  a; m9 K2 y
            }
+ d$ v- }! T% M* q! W/ a( ]            else
4 h8 c/ P5 u2 Z! D            {
3 |6 I1 ~. W# V; [! f, i0 D                sprintf(msg,"object type is not UF_machining_operation_type");
1 @% {+ ]1 g5 \/ Z                UF_CALL(UF_UI_write_listing_window(msg));/ i) u* ^% t: Y; ], p0 S2 a
            }8 @9 A6 J6 D6 C# V2 d$ x
        }9 G+ L% r, u1 I0 N
        else/ K) V7 p6 h9 M, k# o
        {; A8 `& l0 F; Y: Y3 t, J, m
            sprintf(msg,"Nothing highlighted");
. U, j1 A1 H: ^- L; g- C" p            UF_CALL(UF_UI_write_listing_window(msg));
3 f! j" x  \6 n7 x        }3 a4 d' H$ [% T; @' {1 I8 W" s5 X

+ k. {$ l1 }+ a    } // end of if init- G6 B* o8 t0 q. z: R* Q
}) b* S3 v* ^$ @! `4 S

9 d( O* ]1 c; n! i) f* B! n
上海点团信息科技有限公司,承接UG NX,CATIA,CREO,Solidworks 等CAx软件,Teamcenter,3D Experience等PLM软件,工业4.0数字化软件的实施\二次开发\培训相关业务,详情QQ 939801026 Tel 18301858168 网址 doTeam.tech
回复

使用道具 举报

发表回复

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

返回列表 本版积分规则

  • 发布新帖

  • 在线客服

  • 微信

  • 客户端

  • 返回顶部

  • x
    温馨提示

    本网站(plmhome.com)为PLM之家工业软件学习官网站

    展示的视频材料全部免费,需要高清和特殊技术支持请联系 QQ: 939801026

    PLM之家NX CAM二次开发专题模块培训报名开始啦

    我知道了