NX加工开发源码分享:移动选择的程式到其他组
这段代码比较简单,但是你可以学习到如何在CAM里面进行二次开发,比如如何初始化CAM环境,如果查找CAM的程序对象,如何获得加工导航器上的选择结果,如何将对象加入组中。static void do_it(void)
{
char reason;
char msg;
int object_count,
type,
subtype;
tag_t
setupTag,
*objects,
prog_root_tag,
prog_tag;
logicalis_initialized;
logical answer;
UF_CAM_is_session_initialized(&is_initialized);
if( is_initialized == TRUE )
{
UF_CALL(UF_SETUP_ask_setup( &setupTag ));
UF_CALL(UF_SETUP_ask_program_root( setupTag, &prog_root_tag ));
// Find the pre-existing geom PROGRAM and get tag
UF_CALL(UF_NCGROUP_ask_object_of_name( prog_root_tag, "PROGRAM", &prog_tag ));
/* Get the highlighted/selected operation from Navigation Tool. */
UF_CALL(UF_UI_ONT_ask_selected_nodes( &object_count, &objects ));
if (object_count == 1)
{
UF_CALL( UF_OBJ_ask_type_and_subtype (objects,&type,&subtype));
if (type == UF_machining_operation_type )
{
UF_CALL(UF_NCGROUP_can_accept_member( prog_tag, objects, &answer, reason ));
if( answer == TRUE )
{
UF_NCGROUP_accept_member( prog_tag, objects );
}
else
{
sprintf(msg,"program group can not accept operation");
UF_CALL(UF_UI_write_listing_window(msg));
}
}
else
{
sprintf(msg,"object type is not UF_machining_operation_type");
UF_CALL(UF_UI_write_listing_window(msg));
}
}
else
{
sprintf(msg,"Nothing highlighted");
UF_CALL(UF_UI_write_listing_window(msg));
}
} // end of if init
}
页:
[1]