找回密码
 立即注册

QQ登录

只需一步,快速开始

搜索
热搜: 活动 交友 discuz
查看: 179|回复: 0

[每日一码] ARX打印窗口内容到DWF文件

[复制链接]

0

主题

0

回帖

28

积分

管理员

积分
28
发表于 2024-3-14 20:19:38 | 显示全部楼层 |阅读模式
  1. #import "acax19ENU.tlb" no采用namespace
  2. #include "acaplmgr.h"
  3. static void ASDKTS66871采用PlotWindow采用COM采用testPlot(void)
  4. {
  5.   // Use ActiveX interface to get the application object
  6.   IAcadApplicationPtr pAcad = acedGetAcadWinApp()->GetIDispatch(FALSE);
  7.   //get the path to plotter configuration
  8.   采用bstr采用t szPrinterPath;
  9.   szPrinterPath = pAcad->Preferences->GetFiles()->GetPrinterConfigPath() + 采用bstr采用t("\\DWF6 ePlot.pc3");
  10.   // get the current database
  11.   AcDbDatabase *curDocDB = acdbHostApplicationServices()->workingDatabase();
  12.   // get a pointer to the layout manager
  13.   AcApLayoutManager *pLayoutManager = (AcApLayoutManager *)acdbHostApplicationServices()->layoutManager();
  14.   const ACHAR *layoutName = pLayoutManager->findActiveLayout (true);
  15.   // get the current layout
  16.   AcDbLayout *pLayout = pLayoutManager->findLayoutNamed (layoutName, true);
  17.   // if we got it ok
  18.   if (pLayout != NULL)
  19.   {
  20.     Acad::ErrorStatus es;
  21.     // get the plotsetttings class
  22.     AcDbPlotSettingsValidator *pPlotSettingsValidator = acdbHostApplicationServices()->plotSettingsValidator();
  23.     // if we got it ok
  24.     if (pPlotSettingsValidator != NULL)
  25.     {
  26.       // Refresh the layout lists in order to use it
  27.       pPlotSettingsValidator->refreshLists (pLayout);
  28.       // change the current layout plotter
  29.       es = pPlotSettingsValidator->setPlotCfgName (pLayout, szPrinterPath);
  30.       // set the window to plot as the extents of the drawing
  31.       es = pPlotSettingsValidator->setPlotWindowArea (pLayout,
  32.         curDocDB->extmin ().x,
  33.         curDocDB->extmin ().y,
  34.         curDocDB->extmax ().x,
  35.         curDocDB->extmax ().y);
  36.       // set the orgin
  37.       es = pPlotSettingsValidator->setPlotOrigin (pLayout,
  38.         curDocDB->extmin ().x,
  39.         curDocDB->extmin ().y);
  40.       // set to plot centred
  41.       es = pPlotSettingsValidator->setPlotCentered (pLayout, true);
  42.       // setup the plot type to window
  43.       es = pPlotSettingsValidator->setPlotType (pLayout, AcDbPlotSettings::kWindow);
  44.       // set the scale
  45.       es = pPlotSettingsValidator->setStdScaleType (pLayout, AcDbPlotSettings::StdScaleType::kScaleToFit);
  46.       // we have to close the layout here because the last parameter of
  47.       // findLayoutNamed is true, leave layout open
  48.       pLayout->close ();
  49.     }
  50.   }
  51.   // get the current document
  52.   IAcadDocumentPtr pDoc = pAcad->GetActiveDocument();
  53.   // create a plot object
  54.   IAcadPlotPtr pPlot = pDoc->GetPlot();
  55.   // lets plot
  56.   pPlot->PlotToFile("c:\\test.dwf", szPrinterPath);
  57. }
复制代码
您需要登录后才可以回帖 登录 | 立即注册

本版积分规则

Archiver|手机版|小黑屋|膜结构网

GMT+8, 2024-12-29 04:53 , Processed in 0.122179 second(s), 23 queries .

Powered by Discuz! X3.5

© 2001-2024 Discuz! Team.

快速回复 返回顶部 返回列表