ObjectARX CAD批量打印

c++ ObjectARX CAD批量打印

struct resbuf rbBackGroundPlot;acedGetVar(_T("BACKGROUNDPLOT"), &rbBackGroundPlot);if (rbBackGroundPlot.restype == RTSHORT && rbBackGroundPlot.resval.rint != 0){int nOld = rbBackGroundPlot.resval.rint;rbBackGroundPlot.resval.rint = 0;acedSetVar(_T("BACKGROUNDPLOT"), &rbBackGroundPlot);rbBackGroundPlot.resval.rint = nOld;}AcDbLayoutManager* pLayMan = acdbHostApplicationServices()->layoutManager();if (NULL != pLayMan){//get the active layoutAcDbLayout* pLayout = pLayMan->findLayoutNamed(pLayMan->findActiveLayout(TRUE), TRUE);//获得当前布局AcDbObjectId  m_layoutId = pLayout->objectId();//获得布局的IdAcPlPlotInfo plotInfo;AcDbPlotSettingsValidator* pPSV = acdbHostApplicationServices()->plotSettingsValidator();plotInfo.setLayout(pLayout->objectId());//必须设置AcDbPlotSettings* m_pSetting = new AcDbPlotSettings(pLayout->modelType());m_pSetting->copyFrom(pLayout);pPSV->refreshLists(m_pSetting);m_pSetting->setShadePlot(AcDbPlotSettings::kAsDisplayed);m_pSetting->setShadePlotResLevel(AcDbPlotSettings::kNormal);m_pSetting->setScaleLineweights(false);m_pSetting->setPrintLineweights(true);m_pSetting->setPlotTransparency(false);m_pSetting->setPlotPlotStyles(true);m_pSetting->setDrawViewportsFirst(true);m_pSetting->setShowPlotStyles(true);if (suffix == ".pdf"){es = pPSV->setPlotCfgName(m_pSetting, L"DWG to PDF.pc3", L"ISO_FULL_BLEED_A4_(210.00_x_297.00_MM)");//"ISO_FULL_BLEED_A4_(297.00_x_210.00_MM)"es = pPSV->setPlotPaperUnits(m_pSetting, AcDbPlotSettings::kMillimeters);pPSV->setPlotWindowArea(m_pSetting, extent.minPoint().x, extent.minPoint().y, extent.maxPoint().x, extent.maxPoint().y);pPSV->setPlotOrigin(m_pSetting, (extent.minPoint().x + extent.maxPoint().x) / 2, (extent.minPoint().y + extent.maxPoint().y) / 2);pPSV->setPlotType(m_pSetting, AcDbPlotSettings::kWindow);es = pPSV->setCustomPrintScale(m_pSetting, 1.0, _ttof(bl) / 1000.0);//PDF}else{es = pPSV->setPlotCfgName(m_pSetting, L"CASS_RASTER_JPG.pc3", L"UserDefinedRaster (1200.00 x 1600.00像素)");//"UserDefinedRaster (1782.00 x 1260.00像素)"es = pPSV->setPlotPaperUnits(m_pSetting, AcDbPlotSettings::kPixels);es = pPSV->setPlotType(m_pSetting, AcDbPlotSettings::kExtents);es = pPSV->setCustomPrintScale(m_pSetting, 1.0, _ttof(bl) / 18000.0);//JPG}es = pPSV->setPlotRotation(m_pSetting, AcDbPlotSettings::k0degrees);										es = pPSV->setCurrentStyleSheet(m_pSetting, L"acad.ctb");//全部配置名称 /*AcArray mMediaList;pPSV->plotDeviceList(mMediaList);std::vector arrMediaNames;pPSV->canonicalMediaNameList(m_pSetting, mMediaList);for (int nIndex = 0; nIndex < mMediaList.length(); ++nIndex)arrMediaNames.push_back(mMediaList[nIndex]);*/// Specify that we want our plot centered by AutoCAD...es = pPSV->setPlotCentered(m_pSetting, true);es = pPSV->setUseStandardScale(m_pSetting, FALSE);pPSV->setZoomToPaperOnUpdate(m_pSetting, true);plotInfo.setOverrideSettings(m_pSetting);// 验证这些设置。AcPlPlotInfoValidator validator;validator.setMediaMatchingPolicy(AcPlPlotInfoValidator::kMatchEnabled);es = validator.validate(plotInfo);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::kDialogTitle, _T("Plot API Progress"));pPlotProgDlg->setPlotMsgString(AcPlPlotProgressDialog::kCancelJobBtnMsg, _T("Cancel Job"));pPlotProgDlg->setPlotMsgString(AcPlPlotProgressDialog::kCancelSheetBtnMsg, _T("Cancel Sheet"));pPlotProgDlg->setPlotMsgString(AcPlPlotProgressDialog::kSheetSetProgressCaption, _T("Job Progress"));pPlotProgDlg->setPlotMsgString(AcPlPlotProgressDialog::kSheetProgressCaption, _T("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::kMatchEnabled);//es = validator.validate(plotInfo);// Begin document.  The version we call is dependent // on the plot-to-file status.//const TCHAR* szDocName = acDocManager->curDocument()->fileName();CString szDocName = acDocManager->curDocument()->fileName();CString outPutFilePath = szDocName;int n = outPutFilePath.ReverseFind('.');outPutFilePath = outPutFilePath.Left(n);//outPutFilePath +=  ".jpg";outPutFilePath += suffix;//if (m_bPlotToFile)es = pEngine->beginDocument(plotInfo, szDocName, NULL, 1, true, outPutFilePath);//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(L"Plot Engine is Busy...");}pLayout->close();m_pSetting->close();}


本文来自互联网用户投稿,文章观点仅代表作者本人,不代表本站立场,不承担相关法律责任。如若转载,请注明出处。 如若内容造成侵权/违法违规/事实不符,请点击【内容举报】进行投诉反馈!

相关文章

立即
投稿

微信公众账号

微信扫一扫加关注

返回
顶部