[每日一码] ARX打印窗口内容到DWF文件
#import "acax19ENU.tlb" no采用namespace#include "acaplmgr.h"
static void ASDKTS66871采用PlotWindow采用COM采用testPlot(void)
{
// Use ActiveX interface to get the application object
IAcadApplicationPtr pAcad = acedGetAcadWinApp()->GetIDispatch(FALSE);
//get the path to plotter configuration
采用bstr采用t szPrinterPath;
szPrinterPath = pAcad->Preferences->GetFiles()->GetPrinterConfigPath() + 采用bstr采用t("\\DWF6 ePlot.pc3");
// get the current database
AcDbDatabase *curDocDB = acdbHostApplicationServices()->workingDatabase();
// get a pointer to the layout manager
AcApLayoutManager *pLayoutManager = (AcApLayoutManager *)acdbHostApplicationServices()->layoutManager();
const ACHAR *layoutName = pLayoutManager->findActiveLayout (true);
// get the current layout
AcDbLayout *pLayout = pLayoutManager->findLayoutNamed (layoutName, true);
// if we got it ok
if (pLayout != NULL)
{
Acad::ErrorStatus es;
// get the plotsetttings class
AcDbPlotSettingsValidator *pPlotSettingsValidator = acdbHostApplicationServices()->plotSettingsValidator();
// if we got it ok
if (pPlotSettingsValidator != NULL)
{
// Refresh the layout lists in order to use it
pPlotSettingsValidator->refreshLists (pLayout);
// change the current layout plotter
es = pPlotSettingsValidator->setPlotCfgName (pLayout, szPrinterPath);
// set the window to plot as the extents of the drawing
es = pPlotSettingsValidator->setPlotWindowArea (pLayout,
curDocDB->extmin ().x,
curDocDB->extmin ().y,
curDocDB->extmax ().x,
curDocDB->extmax ().y);
// set the orgin
es = pPlotSettingsValidator->setPlotOrigin (pLayout,
curDocDB->extmin ().x,
curDocDB->extmin ().y);
// set to plot centred
es = pPlotSettingsValidator->setPlotCentered (pLayout, true);
// setup the plot type to window
es = pPlotSettingsValidator->setPlotType (pLayout, AcDbPlotSettings::kWindow);
// set the scale
es = pPlotSettingsValidator->setStdScaleType (pLayout, AcDbPlotSettings::StdScaleType::kScaleToFit);
// we have to close the layout here because the last parameter of
// findLayoutNamed is true, leave layout open
pLayout->close ();
}
}
// get the current document
IAcadDocumentPtr pDoc = pAcad->GetActiveDocument();
// create a plot object
IAcadPlotPtr pPlot = pDoc->GetPlot();
// lets plot
pPlot->PlotToFile("c:\\test.dwf", szPrinterPath);
}
页:
[1]