马上注册,结交更多好友,享用更多功能,让你轻松玩转社区。
您需要 登录 才可以下载或查看,没有账号?立即注册
×
Issue
I want to Window plot a drawing to DWF, I'm using COM to plot the DWF but how do I setup the Plot Settings so that it plots using a couple of Window coordinates?
Solution
In ObjectARX you need to use the AcDbPlotSettingsValidator class to setup the Plot. Here is some code which shows you what to do. Note this is using the Window coordinates as the extents of the drawing. This is purely for test purposes - if you want to plot the extents then use setPlotType (pLayout, AcDbPlotSettings::kExtents). There is also a Visual LISP example following the ObjectARX code.
#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);
}
Note: You do not necessarily need to use COM to plot. Instead you can use ObjectARX functions. A good sample ships with the ObjectARX 2009 SDK. ( ..\ObjectARX 2009\samples\editor\AsdkPlotAPI )
同功能VLISP代码见:http://bbs.xdcad.net/thread-707150-1-1.html |