NX/UG二次开发—CAM—用户自定义刀轨(UDOP)

用户定义刀轨是指:在需要一种无法由标准制造处理器完成的加工方法时,使用NX以外的处理器生成刀具路径的操作。这可能是你自己的或第三方的代码。入口函数udop。以下是程序框架,可以往里面添加你的代码

extern void udop(char *param, int *status, int parm_len)
{
    char                                   op_name[UF_OPER_OPNAME_LEN];
    UF_UDOP_id_t               udop_id;
    UF_UDOP_purpose_t    purpose;
    UF_OPER_id_t                oper_id;
    UF_PATH_id_t                 path_id;
    UF_CAM_exit_id_t          exit_id = (UF_CAM_exit_id_t)param;   
    UF_UDOP_ask_udop( exit_id, &udop_id);
    UF_UDOP_ask_oper( udop_id, &oper_id);
    UF_UDOP_ask_purpose( udop_id, &purpose);
    UF_OPER_ask_name( oper_id, op_name);
    UF_OPER_ask_path( oper_id, &path_id);   

    if( purpose == UF_UDOP_GENERATE )
    {
          “写刀轨”;
    }
    if (purpose==UF_UDOP_USER_PARAMS)
    {
          “打开对话框”;
    }
}

//创建直线刀轨

UF_PATH_linear_motion_t    line_motion,*line_motion_ptr = &line_motion; 
line_motion_ptr->feed_value =1000.0;
line_motion_ptr->feed_unit =UF_PATH_FEED_UNIT_PER_MINUTE ;
line_motion_ptr->type = UF_PATH_MOTION_TYPE_RAPID;
UF_VEC3_copy(tool_axis, line_motion_ptr->tool_axis);
UF_VEC3_copy(startPt, line_motion_ptr-> position);
UF_PATH_create_linear_motion(path_id,line_motion_ptr);
UF_VEC3_copy(endPt, line_motion_ptr-> position);
UF_PATH_create_linear_motion(path_id,line_motion_ptr);

//创建圆弧刀轨

UF_PATH_circular_motion_t  cir_motion,*cir_motion_ptr = &cir_motion; 
cir_motion_ptr->feed_unit = UF_PATH_FEED_UNIT_PER_MINUTE;
cir_motion_ptr->type = UF_PATH_MOTION_TYPE_CUT;
UF_VEC3_copy(tool_axis,cir_motion_ptr->start_tool_axis);
UF_VEC3_copy(tool_axis,cir_motion_ptr-> end_tool_axis);
UF_VEC3_copy(tool_axis,cir_motion_ptr-> arc_axis);
cir_motion_ptr->tolerance = 0.005;
cir_motion_ptr->feed_value =curves[i].speed;
cir_motion_ptr->type = UF_PATH_MOTION_TYPE_CUT;
UF_VEC3_copy(point1,cir_motion_ptr-> start);
UF_VEC3_copy(point2,cir_motion_ptr-> arc_center);
UF_VEC3_copy(point2,cir_motion_ptr-> end);
UF_PATH_create_circular_motion( path_id, cir_motion_ptr);

//创建螺旋刀轨

UF_PATH_helical_motion_t helical_motion,*helical_motion_ptr=&helical_motion; 
helical_motion_ptr->feed_unit=helical_motion_ptr->feed_unit=UF_PATH_FEED_UNIT_PER_MINUTE;
helical_motion_ptr->type=helical_motion_ptr->type=UF_PATH_MOTION_TYPE_CUT;
helical_motion_ptr->tolerance=helical_motion_ptr->tolerance=0.001;
helical_motion_ptr->feed_value =curves[i].speed;
helical_motion_ptr->arc_radius = curves[i].radius;
helical_motion_ptr->shape = UF_PATH_SHAPE_CIRCULAR_CW;
helical_motion_ptr->material_side = UF_PATH_SIDE_LEFT;
UF_VEC3_copy(point1, helical_motion_ptr-> start);
UF_VEC3_copy(point2, helical_motion_ptr-> arc_center);
UF_VEC3_copy(point3, helical_motion_ptr-> end);
UF_PATH_create_helical_motion( path_id, helical_motion_ptr);

有问题可以留言交流。

发布了18 篇原创文章 · 获赞 10 · 访问量 1万+

猜你喜欢

转载自blog.csdn.net/u012077233/article/details/87894289