11# hust65 谢谢,论坛上的段代码,能不能帮看下错在哪
int UsrCreateSheet()
{
ProError status;
ProDrawing drawing;
int sheet;
ProSolid solid;
ProVector pos,outpos;
ProView view, pview;
ProVector outline[2];
ProMatrix matrix,inv_matrix,tem_matrix;
ProName w_size;
ProMdlType type = PRO_PART;
wchar_t wname[PRO_LINE_SIZE];
//char fname[30] = "sheets.txt";
//FILE *fp=fopen(fname, "w");
/*--------------------------------------------------------------------*\
Create a new sheet and make it current
\*--------------------------------------------------------------------*/
status = ProMdlCurrentGet((ProMdl)&drawing);
ProDrawingSheetCreate(drawing, &sheet);
ProDrawingCurrentSheetSet(drawing, sheet);
/*--------------------------------------------------------------------*\
Add a solid to the drawing
\*--------------------------------------------------------------------*/
ProStringToWstring(wname,"D:\\debuggingprogram\\cycs\\chabei.prt");
ProMdlRetrieve(wname,type,(ProMdl*)&solid);
ProDrawingSolidAdd(drawing, solid);
/*--------------------------------------------------------------------*\
Create a general view from the Z axis direction
\*--------------------------------------------------------------------*/
ProUtilMatrixCopy(NULL, matrix);
pos[0] = 200.0;
pos[1] = 600.0;
pos[2] = 0.0;
ProDrawingSheetTrfGet (drawing, 1, w_size, matrix);
ProUtilMatrixInvert(matrix,inv_matrix);
ProUtilPointTrans(inv_matrix,pos,outpos);
ProPntTrfEval (pos, inv_matrix, outpos);
//我发现下面的status返回PRO_TK_GENERAL_ERROR,但是不知道是错在哪了
status=ProDrawingGeneralviewCreate(drawing, solid, sheet, PRO_B_FALSE,
outpos, 0.5, matrix, &view);
/*--------------------------------------------------------------------*\
Get the position and size of the new view
\*--------------------------------------------------------------------*/
ProDrawingViewOutlineGet(drawing, view, outline);
/*--------------------------------------------------------------------*\
Create a projected view to the right of the general view
\*--------------------------------------------------------------------*/
pos[0] = outline[1][0] + (outline[1][0] - outline[0][0]);
pos[1] = (outline[0][1] + outline[1][1]) / 2.0;
pos[2] = 0.0;
ProDrawingProjectedviewCreate(drawing, view, PRO_B_FALSE, pos,
&pview);
/*--------------------------------------------------------------------*\
Create a projected view below the general view
\*--------------------------------------------------------------------*/
pos[0] = (outline[0][0] + outline[1][0]) / 2.0;
pos[1] = outline[0][1] - (outline[1][1] - outline[0][1]);
ProDrawingProjectedviewCreate(drawing, view, PRO_B_FALSE, pos,
&pview);
return(1);
}
本帖最后由 hyccai 于 2011-6-1 12:28 编辑 |