//-----------------------------------------------------------------------------
//----- acrxEntryPoint.cpp
//-----------------------------------------------------------------------------
#include "StdAfx.h"
#include "acplmisc.h"
#pragma comment (lib ,"AcPublish_crx.lib")
#include "resource.h"
//-----------------------------------------------------------------------------
#define szRDS _RXST("")
//-----------------------------------------------------------------------------
//----- ObjectARX EntryPoint
class CPublishMultiPagePDFApp : public AcRxArxApp {
public:
CPublishMultiPagePDFApp() : AcRxArxApp() {}
virtual AcRx::AppRetCode On_kInitAppMsg(void *pkt) {
AcRx::AppRetCode retCode = AcRxArxApp::On_kInitAppMsg(pkt);
return (retCode);
}
virtual AcRx::AppRetCode On_kUnloadAppMsg(void *pkt) {
AcRx::AppRetCode retCode = AcRxArxApp::On_kUnloadAppMsg(pkt);
return (retCode);
}
virtual void RegisterServerComponents() { }
static void MyGroupMyPublish() {
plot(acdbCurDwg());
}
static void plot(AcDbDatabase *pDb)
{
CString pdfPath = "C:\\temp\\pdf\\myPDF.pdf";
CString deviceName = L"DWG To PDF.pc3";
Acad::ErrorStatus es = Acad::eOk;
const TCHAR *docName;
es = pDb->getFilename(docName);
AcDbLayoutManager *layoutManager =
acdbHostApplicationServices()->layoutManager();
AcDbDictionary *layoutDict = NULL;
es = pDb->getLayoutDictionary(layoutDict, AcDb::OpenMode::kForRead);
// Начнём собирать данные в DSD
AcPlDSDEntries dsdEntries;
AcDbDictionaryIterator *layoutIterator = layoutDict->newIterator();
// Если мы собираемся печатать только листы пространства листа
AcDbObjectId msId = acdbSymUtil()->blockModelSpaceId(pDb);
for (; layoutIterator && !layoutIterator->done(); layoutIterator->next())
{
AcDbObjectPointer<AcDbLayout> layout(
layoutIterator->objectId(), AcDb::OpenMode::kForRead);
// Пропускаем Пространство Модели
if (layout->getBlockTableRecordId() == msId)
continue;
const ACHAR *layoutName;
layout->getLayoutName(layoutName);
AcPlDSDEntry dsdEntry;
dsdEntry.setLayout(layoutName);
dsdEntry.setDwgName(docName);
dsdEntry.setTitle(layoutName);
dsdEntries.append(dsdEntry);
}
delete layoutIterator;
layoutDict->close();
AcPlDSDData dsdData;
dsdData.setDSDEntries(dsdEntries);
dsdData.setProjectPath(L"c:\\temp\\pdf\\");
dsdData.setLogFilePath(L"c:\\temp\\pdf\\logdwf.log");
dsdData.setSheetType(AcPlDSDEntry::SheetType::kMultiPDF);
dsdData.setNoOfCopies(1);
dsdData.setDestinationName(pdfPath);
dsdData.setPromptForDwfName(false);
dsdData.setSheetSetName(L"PublisherSet");
dsdData.writeDSD(L"c:\\temp\\pdf\\PublisherSet.dsd");
AcPlPlotConfig *plotConfig = NULL;
acplPlotConfigManager->setCurrentConfig(plotConfig, deviceName);
// Мы должны это загрузить для работы acplPublishExecute
acedArxLoad(L"AcPublish.arx");
resbuf bp_old = { 0,0 }, bp_0 = { 0,0 };
acedGetVar(L"BACKGROUNDPLOT", &bp_old);
bp_0 = bp_old; bp_0.resval.rint = 0;
acedSetVar(L"BACKGROUNDPLOT", &bp_0);
acplPublishExecute(dsdData, plotConfig, true);
acedSetVar(L"BACKGROUNDPLOT", &bp_old);
}
};
//-----------------------------------------------------------------------------
IMPLEMENT_ARX_ENTRYPOINT(CPublishMultiPagePDFApp)
ACED_ARXCOMMAND_ENTRY_AUTO(CPublishMultiPagePDFApp, MyGroup, MyPublish, MyPublish, ACRX_CMD_MODAL, NULL)