- 积分
- 1296
- 明经币
- 个
- 注册时间
- 2006-7-5
- 在线时间
- 小时
- 威望
-
- 金钱
- 个
- 贡献
-
- 激情
-
|
工作过程:读待转JPG,把JPG文件读到CAD中,转换成PLT文件输出,然后关闭文档。然后再读待转JPG,新建CAD文档,执行转换任务,但在第二次新建CAD文档后,执行转PLT时“es = pEngine->endPlot();”出现错误:
下面是程序代码:
CPlot::CPlot(CString strPath)//初始化
{
m_strDevice = _T("DesignJet 750C Plus C4708B.pc3");
m_strPath = strPath;
m_pPSV= (AcDbPlotSettingsValidator*)acdbHostApplicationServices()->plotSettingsValidator();
// 取得当前layout
AcDbLayoutManager *pLayoutManager = acdbHostApplicationServices()->layoutManager();
AcDbObjectId btrId = pLayoutManager->getActiveLayoutBTRId();
AcDbBlockTableRecord *pBTR;
Acad::ErrorStatus es=acdbOpenObject(pBTR,btrId,AcDb::kForRead);
m_layoutId = pBTR->getLayoutId();
AcDbLayout *pLayout=NULL;
acdbOpenObject(pLayout,m_layoutId,AcDb::kForRead);
#pragma warning (disable: 4800)
m_pPlotSettings = new AcDbPlotSettings(pLayout->modelType());
#pragma warning (default: 4800)
m_pPlotSettings->copyFrom(pLayout);
pLayout->close();
pBTR->close();
m_pPlotSettings->close();
}
//开始转换
void CPlot::StartPlt()
{
Acad::ErrorStatus es;
es = m_pPSV->setPlotType(m_pPlotSettings, AcDbPlotSettings::kExtents);
//设置缩放比例
es = m_pPSV->setUseStandardScale(m_pPlotSettings, Adesk::kFalse);
es = m_pPSV->setCustomPrintScale(m_pPlotSettings, 1, 1);
es = m_pPSV->setPlotCentered(m_pPlotSettings, true);
es = m_pPSV->setPlotCfgName(m_pPlotSettings,m_strDevice);
m_pPSV->refreshLists(m_pPlotSettings);
AcPlPlotEngine* pEngine = NULL;
if(Acad::eOk == AcPlPlotFactory::createPublishEngine(pEngine))
{
es = pEngine->beginPlot(NULL);
AcPlPlotPageInfo pageInfo;
AcPlPlotInfo plotInfo;
// 设置布局
plotInfo.setLayout(m_layoutId);
// 重置参数
plotInfo.setOverrideSettings(m_pPlotSettings);
AcPlPlotInfoValidator validator;
validator.setMediaMatchingPolicy(AcPlPlotInfoValidator::kMatchEnabled);
es = validator.validate(plotInfo);
// 开始打印
const TCHAR *szDocName = acDocManager->curDocument()->fileName();
es = pEngine->beginDocument(plotInfo, szDocName, NULL, 1, true, m_strPath);
es = pEngine->beginPage(pageInfo, plotInfo, true);
es = pEngine->beginGenerateGraphics();
es = pEngine->endGenerateGraphics();
es = pEngine->endPage();
es = pEngine->endDocument();
es = pEngine->endPlot();//就是这一行报错
pEngine->destroy();
pEngine = NULL;
delete pEngine;
}
else
{
acedAlert(_T("打印DWF失败!"));
}
}
//下面是调用的方法
CPlot *plt=new CPlot(strPltFile);
plt->StartPlt();
plt->DestroyPlot();
delete plt;
plt=NULL;
|
本帖子中包含更多资源
您需要 登录 才可以下载或查看,没有账号?注册
x
|