Applications may choose to use the plot API configuration-time capability, the plot-time capability, or both. They can also include provisions for multi-page documents, plotting to a file, error handling, and overriding the default plot progress dialog box.
Any time the plot engine is accessed through the plot API, the system will plot in the foreground if the BACKGROUNDPLOT system variable is set to 0, and in the background if the BACKGROUNDPLOT system variable is set to 1,2, or 3.
This verifies that the overrides are compatible with the layout settings. For example, paper space and model space settings are mutually exclusive and the specified device must exist.
The following code illustrates a basic use of the API and the default plot progress dialog box, which is discussed further in Plot Progress Dialog Box.
AcPlPlotEngine* pEngine = NULL; if(Acad::eOk==AcPlPlotFactory::createPublishEngine(pEngine)) { // Here is the progress dialog for the current plot process... AcPlPlotProgressDialog *pPlotProgDlg=acplCreatePlotProgressDialog( acedGetAcadFrame()->m_hWnd,false,1); pPlotProgDlg->setPlotMsgString( AcPlPlotProgressDialog::PlotMSGIndex::kDialogTitle, "Plot API Progress"); pPlotProgDlg->setPlotMsgString( AcPlPlotProgressDialog::PlotMSGIndex::kCancelJobBtnMsg, "Cancel Job"); pPlotProgDlg->setPlotMsgString( AcPlPlotProgressDialog::PlotMSGIndex::kCancelSheetBtnMsg, "Cancel Sheet"); pPlotProgDlg->setPlotMsgString( AcPlPlotProgressDialog::PlotMSGIndex::kSheetSetProgressCaption, "Job Progress"); pPlotProgDlg->setPlotMsgString( AcPlPlotProgressDialog::PlotMSGIndex::kSheetProgressCaption, "Sheet Progress"); pPlotProgDlg->setPlotProgressRange(0,100); pPlotProgDlg->onBeginPlot(); pPlotProgDlg->setIsVisible(true); es = pEngine->beginPlot(pPlotProgDlg); AcPlPlotPageInfo pageInfo; // Used to describe how the plot is to be made. AcPlPlotInfo plotInfo; // First, set the layout to the specified layout // (which is the current layout in this sample). plotInfo.setLayout(layoutId);// This is required. // Now, override the layout settings with the plot settings // we have been populating. plotInfo.setOverrideSettings(pPlotSettings); // We need to validate these settings. AcPlPlotInfoValidator validator; validator.setMediaMatchingPolicy( AcPlPlotInfoValidator::MatchingPolicy::kMatchEnabled); es = validator.validate(plotInfo); // Begin document. The version we call is dependent // on the plot-to-file status. const char *szDocName=acDocManager->curDocument()->fileName(); if(m_bPlotToFile) es = pEngine->beginDocument(plotInfo, szDocName, NULL, 1, true, m_csFilename); else es = pEngine->beginDocument(plotInfo, szDocName); // Follow through sending commands to the engine, // and notifications to the progress dialog. pPlotProgDlg->onBeginSheet(); pPlotProgDlg->setSheetProgressRange(0, 100); pPlotProgDlg->setSheetProgressPos(0); es = pEngine->beginPage(pageInfo, plotInfo, true); es = pEngine->beginGenerateGraphics(); es = pEngine->endGenerateGraphics(); es = pEngine->endPage(); pPlotProgDlg->setSheetProgressPos(100); pPlotProgDlg->onEndSheet(); pPlotProgDlg->setPlotProgressPos(100); es = pEngine->endDocument(); es = pEngine->endPlot(); // Destroy the engine pEngine->destroy(); pEngine = NULL; // and the progress dialog. pPlotProgDlg->destroy(); else // Ensure the engine is not already busy... AfxMessageBox("Plot Engine is Busy..."); }