/*
Copyright (c) 2019 PTC Inc. and/or Its Subsidiary Companies. All Rights Reserved.
*/
/*-------------------------- Pro/Toolkit includes ---------------------------*/
#include <ProToolkit.h>
#include <ProMdl.h>
#include <ProCsys.h>
/*-------------------------- Application includes ---------------------------*/
#include <TestError.h>
/*================================================================*\
FUNCTION : UserSheetCopy()
PURPOSE : Adds a drawing sheet to the current drawing-type object
\*================================================================*/
ProError UserSheetCopy ()
{
ProError status;
int win_id, sheet_num;
ProCharLine astr;
ProDrawing drawing;
ProMdl mdl;
int sheet_to_copy, sheet_copy;
ProMdlType type;
ProFileName WMSGFIL = {'m','s','g','_','u','g','d','w','g','.','t','x','t','\0'};
ProTKSprintf (astr, "Inside UserSheetCopy()");
status = ProMessageDisplay (WMSGFIL,"USER %0s", astr);
/*------------------------------------------------------------*\
Get the current model
\*------------------------------------------------------------*/
status = ProMdlCurrentGet(&mdl);
ERROR_CHECK("UserSheetCopy","ProMdlCurrentGet", status);
if (status != PRO_TK_NO_ERROR) return(status);
status = ProMdlTypeGet(mdl, &type);
ERROR_CHECK("UserSheetCopy","ProMdlTypeGet",status);
if (status != PRO_TK_NO_ERROR) return(status);
if(type != PRO_DRAWING)
{
ProTKSprintf (astr, "Current model is not a drawing!", status);
status = ProMessageDisplay (WMSGFIL,"USER %0s", astr);
ERROR_CHECK("UserSheetCopy","ProMessageDisplay",status);
return(PRO_TK_GENERAL_ERROR);
}
/*------------------------------------------------------------*\
Create a copy of the current drawing sheet.
\*------------------------------------------------------------*/
sheet_to_copy = -1;
status = ProDrawingSheetCopy((ProDrawing)mdl, sheet_to_copy, &sheet_copy);
ERROR_CHECK("UserSheetCopy","ProDrawingSheetCopy",
(status != PRO_TK_NO_ERROR));
if (status != PRO_TK_NO_ERROR) return (status);
/*------------------------------------------------------------*\
Print a message in the message window
\*------------------------------------------------------------*/
if (status != PRO_TK_NO_ERROR)
{
ProTKSprintf (astr, "Error %d while adding sheet", status);
status = ProMessageDisplay (WMSGFIL,"USER %0s", astr);
ERROR_CHECK("UserSheetCopy","ProMessageDisplay",status);
return(PRO_TK_GENERAL_ERROR);
}
ProTKSprintf (astr, "Sheet No. %0d added to drawing.", sheet_copy);
status = ProMessageDisplay (WMSGFIL,"USER %0s", astr);
ERROR_CHECK("UserSheetCopy","ProMessageDisplay",status);
/*------------------------------------------------------------*\
Update the changes by repainting the window
\*------------------------------------------------------------*/
status = ProWindowCurrentGet(&win_id);
ERROR_CHECK("UserSheetCopy","ProWindowCurrentGet",status);
if (status != PRO_TK_NO_ERROR) return(status);
status = ProWindowRepaint (win_id);
ERROR_CHECK("UserSheetCopy","ProWindowRepaint",status);
return(status);
}