/*--------------------------------------------------------------------*\
定义变量
\*--------------------------------------------------------------------*/
int format_type=0;
/*
格式类型说明
PRO_IGES_3D_FILE;//设置格式为3D的IGS档
PRO_STEP_FILE;//设置格式为STP档
*/
/*============================================================================*\
Function: FileFormatToIGS
Purpose: Export current model from the igs format
\*============================================================================*/
void FileFormatToIGS()
{
ProError status,(*funp)(ProMdl *);
ProMdl out_model;
status=ProTestEnvironment();
if(status!=PRO_TK_BAD_CONTEXT)
{
format_type=(int)PRO_IGES_3D_FILE;
CreateDirectoryA("IGS",NULL);
funp=MyExportModelTo;
MyPartSelect(funp,0,&out_model);
system("del *__out.log.?");
}
else
{
MyDisplayMessageBox("错误","请先打开部件文件 !");
}
}
/*============================================================================*\
Function: FileFormatToSTP
Purpose: Export current model from the step format
\*============================================================================*/
void FileFormatToSTP()
{
ProError status,(*funp)(ProMdl *);
ProMdl out_model;
status=ProTestEnvironment();
if(status!=PRO_TK_BAD_CONTEXT)
{
format_type=(int)PRO_STEP_FILE;
CreateDirectoryA("STP",NULL);
funp=MyExportModelTo;
MyPartSelect(funp,0,&out_model);
system("del *__out.log.?");
}
else
{
MyDisplayMessageBox("错误","请先打开部件文件 !");
}
}
/*=================================================================*\
FUNCTION : MyExportModelTo()
PURPOSE : 转出部件文件为其它格式档
\*=================================================================*/
ProError MyExportModelTo(ProMdl *mdl)
{
ProError status;
ProName w_name;
ProCharLine c_name,file_name;
double quality[]={0.02,0.01};
ProImportExportFile export_type;
if(*mdl == NULL)
return(PRO_TK_BAD_INPUTS);
status = ProMdlNameGet(*mdl, w_name);
TEST_CALL_REPORT ("ProMdlNameGet()",
"ProTestExportTo()", status, status != PRO_TK_NO_ERROR);
// 设置文件名
ProWstringToString(c_name, w_name);
switch(format_type)
{
case (int)PRO_IGES_3D_FILE:
export_type=PRO_IGES_3D_FILE;
sprintf(file_name,"igs\\%s.%s",c_name,"igs");
break;
case (int)PRO_STEP_FILE:
export_type=PRO_STEP_FILE;
sprintf(file_name,"stp\\%s.%s",c_name,"stp");
break;
}
//把文件名转成宽字符串格式
ProStringToWstring(w_name,file_name);
//输出要求格式档
status = ProOutputFileWrite( *mdl, w_name, export_type, NULL,
NULL, (ProAppData)quality, NULL );
TEST_CALL_REPORT( "ProOutputFileWrite()", "ProTestExport()",
status, status != PRO_TK_NO_ERROR );
return(status);
} |