NX二次开发中,CAM加工的一些属性设置和查找
1,查找刀具属性tag_t tool_id=NULL;
double tool_diam=0;
UF_OPER_ask_cutter_group(oper_tag,&tool_id);
UF_PARAM_ask_double_value(tool_id,UF_PARAM_TL_DIAMETER,&tool_diam);//查找直径
char tool_text;
char ch_s="", ch_f="",*ch_p=NULL;
double tool_s=0 ,tool_f=0;//主轴转速,进给
if(UF_CALL(UF_PARAM_ask_str_value(tool_id,1158,tool_text))==0)//属性文本
{
ch_p=strstr(tool_text,"S=");
if (ch_p!=NULL)
{
int i=0;
ch_p=ch_p+2;
while((48<=*ch_p&&*ch_p<=57)||46==*ch_p)//当指针指向为数字或者小数点
{
ch_s=*ch_p;
i++;
ch_p++;
}
ch_s='\0';
if(i!=0)
{
tool_s=atof(ch_s);
}
//uc1601(ch_s,1);
}
ch_p=NULL;
ch_p=strstr(tool_text,"F=");
if (ch_p!=NULL)
{
int i=0;
ch_p=ch_p+2;
while((48<=*ch_p&&*ch_p<=57)||46==*ch_p)//当指针指向为数字或者小数点
{
ch_f=*ch_p;
i++;
ch_p++;
}
ch_f='\0';
if(i!=0)
{
tool_f=atof(ch_f);
}
// uc1601(ch_f,1);
}
}
2,
//主轴开
UF_PATH_spindle_on_t spindle_data;
spindle_data.speed = tool_s;
spindle_data.maxrpm = 10000.0;
spindle_data.mode = UF_PATH_SPINDLE_MODE_RPM;
spindle_data.direction = UF_PATH_DIRECTION_CLOCKWISE;
spindle_data.speed_flag = TRUE;
spindle_data.maxrpm_flag = TRUE;
spindle_data.range_flag = FALSE;
UF_PATH_create_spindle_on( path_id, &spindle_data, NULL );
//主轴关
UF_PATH_create_spindle_off( path_id, NULL );
3,//打开刀具补偿
UF_PATH_cutcom_tcutcom_data;
cutcom_data.cutcom_mode = UF_PATH_CUTCOM_LEFT;
cutcom_data.plane_type = UF_PATH_PLANE_TYPE_NONE;
cutcom_data.cutcom_on_status = UF_PATH_CUTCOM_ON_BEFORE_ENGAGE;
cutcom_data.cutcom_off_status = UF_PATH_CUTCOM_OFF_AFTER_RETRACT;
cutcom_data.adjust_register = 1;
cutcom_data.full_cutcom_output = TRUE;
cutcom_data.adjust_flag = TRUE;
UF_PATH_create_cutcom( path_id, &cutcom_data, NULL );
//关闭刀具补偿
cutcom_data.cutcom_mode = UF_PATH_CUTCOM_OFF;
UF_PATH_create_cutcom( path_id, &cutcom_data, NULL );
页:
[1]