- [FONT=courier new]
- #import "acad.tlb" no_namespacevoid
- fTest()
- {
- // Use ActiveX interface to get the application object
- IAcadApplicationPtr pAcad = acedGetAcadWinApp()->GetIDispatch(TRUE);
- //get the path to plotter configuration
- _bstr_t szPrinterPath;
- szPrinterPath = pAcad->Preferences->GetFiles()->GetPrinterConfigPath() + _bstr_t("\\DWF ePlot (optimized for plotting).pc3");
- // get the current database
- AcDbDatabase *curDocDB = acdbHostApplicationServices()->workingDatabase();
- // get a pointer to the layout manager
- AcApLayoutManager *pLayoutManager = (AcApLayoutManager *)acdbHostApplicationServices()->layoutManager();
- const char *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);
- }
- [/FONT]
|