arx二次开发调用打印流程说明

arx二次开发调用打印流程说明

Plot Settings ValidationPlot APIMulti-page Documents
Autodesk ObjectARX for AutoCAD 2020: Developer’s Guide > Basic Interaction with AutoCAD > Plot API >

Using the Plot API

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.

Note
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.

To use the basic configuration-time and plot-time APIs

  1. Get the ID of the layout and make it active in the editor. (The
    layout must be active by the time beginPage() is called in step 7.)
  2. Create an AcPlPlotInfo object and set the layout ID on it.
  3. Implement a UI to create an AcDbPlotSettings object (optional).
  4. Pass the AcPlPlotInfo object a pointer to the plot settings object
    (if there is one) using AcPlPlotInfo::setOverrideSettings().
  5. Call AcPlPlotInfoValidator::validate() on the plot info object.
  6. 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.
  7. Create an AcPlPlotEngine object using
    AcPlPlotFactory::createPreviewEngine() or
    AcPlPlotFactory::createPublishEngine().
  8. Call the following functions on the engine:
    beginPlot()
    beginDocument()
    beginPage()
    beginGenerateGraphics()
    endGenerateGraphics()
    endPage()
    endDocument()
    endPlot()

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...");
}

在这里插入图片描述

  • 1
    点赞
  • 8
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值