使用绘图 API 
应用程序可以选择使用绘图 API 配置时间功能和/或绘图时间功能。它们还可以包括多页文档、打印到文件、错误处理和覆盖默认打印进度对话框的规定。 注意: 
 
每当通过绘图 API 访问绘图引擎时,如果 BACKGROUNDPLOT 系统变量设置为 0,系统将在前台绘制,如果 BACKGROUNDPLOT 系统变量设置为 1、2 或 3,则系统将在后台绘制。 使用基本配置时和绘图时 API
 以下代码演示了 API 和默认打印进度对话框的基本用法,绘图进度对话框中对此进行了进一步讨论。 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...");
}
父主题: | 
|Archiver|CAD开发者社区
( 苏ICP备2022047690号-1   苏公网安备32011402011833)
GMT+8, 2025-11-4 14:28
Powered by Discuz! X3.4
Copyright © 2001-2021, Tencent Cloud.