天气与日历 切换到窄版

 找回密码
 立即注册
中国膜结构网
十大进口膜材评选 十大国产膜材评选 十大膜结构设计评选 十大膜结构公司评选
查看: 130|回复: 0

arx 打印

[复制链接]

该用户从未签到

主题

0

回帖

2912

积分

管理员

积分
2912
发表于 2024-6-22 09:46:18 | 显示全部楼层 |阅读模式
[code]CDwgDatabaseUtil::PlotToFile(TEXT("D:\\TEST1.pdf"), TEXT("DWG To PDF.pc3"), TEXT("A1+"), TEXT("PEACE-A3.ctb"), AcGePoint3d(1000, 100, 0), AcGePoint3d(2000, 800, 0), 100);
CDwgDatabaseUtil::PlotToFile(TEXT("D:\\TEST2.pdf"), TEXT("DWG To PDF.pc3"), TEXT("A1+"), TEXT("PEACE-A3.ctb"), AcGePoint3d(1000, 100, 0), AcGePoint3d(2000, 800, 0), 100);
CDwgDatabaseUtil::PlotToFile(TEXT("D:\\TEST3.pdf"), TEXT("DWG To PDF.pc3"), TEXT("A1+"), TEXT("PEACE-A3.ctb"), AcGePoint3d(1000, 100, 0), AcGePoint3d(2000, 800, 0), 100);
CDwgDatabaseUtil::PlotToFile(TEXT("D:\\TEST4.pdf"), TEXT("DWG To PDF.pc3"), TEXT("A1+"), TEXT("PEACE-A3.ctb"), AcGePoint3d(1000, 100, 0), AcGePoint3d(2000, 800, 0), 100);
CDwgDatabaseUtil::PlotToFile(TEXT("D:\\TEST5.pdf"), TEXT("DWG To PDF.pc3"), TEXT("A1+"), TEXT("PEACE-A3.ctb"), AcGePoint3d(1000, 100, 0), AcGePoint3d(2000, 800, 0), 100);
CDwgDatabaseUtil::PlotToFile(TEXT("D:\\TEST6.pdf"), TEXT("DWG To PDF.pc3"), TEXT("A1+"), TEXT("PEACE-A3.ctb"), AcGePoint3d(1000, 100, 0), AcGePoint3d(2000, 800, 0), 100);


bool CDwgDatabaseUtil::PlotToFile(CString strFileName,                //目标文件名
                                CString strDeviceName,                        //绘图仪名字
                                CString strMediaName,                //图纸大小
                                CString strSheetStyle,                //打印样式
                                AcGePoint3d ptMin,                        //范围左下角点
                                AcGePoint3d ptMax,                        //范围右上角点
                                double dbScale                                //打印比例
                                )
{
        Acad::ErrorStatus es;
       
        AcPlPlotEngine *PlotEngine;
        if (Acad::eOk != AcPlPlotFactory::createPublishEngine(PlotEngine)) return false;

        //创建进度条
        AcPlPlotProgressDialog *pProgress = acplCreatePlotProgressDialog(acedGetAcadFrame()->m_hWnd, false, 1);
        if (pProgress)
        {
                pProgress->setPlotMsgString(AcPlPlotProgressDialog::kDialogTitle, TEXT("打印进度 - ") + strFileName);
                pProgress->setPlotMsgString(AcPlPlotProgressDialog::kCancelJobBtnMsg, TEXT("取消打印"));
                pProgress->setPlotMsgString(AcPlPlotProgressDialog::kCancelSheetBtnMsg, TEXT("取消作业"));
                pProgress->setPlotMsgString(AcPlPlotProgressDialog::kSheetSetProgressCaption, TEXT("打印进度"));
                pProgress->setPlotMsgString(AcPlPlotProgressDialog::kSheetProgressCaption, TEXT("打印进度"));

                pProgress->setPlotProgressRange(0,100);
                pProgress->onBeginPlot();
                pProgress->setIsVisible(true);
        }

        // get a pointer to the layout manager
        AcApLayoutManager *pLayoutManager = (AcApLayoutManager *)acdbHostApplicationServices()->layoutManager();
        AcDbObjectId idBTR = pLayoutManager->getActiveLayoutBTRId();
        AcDbBlockTableRecord *pBTR = NULL;

        es = acdbOpenObject(pBTR, idBTR, AcDb::kForRead);
        // We want to instantiate our custom AcDbPlotSettings object, and inherit the
        // properties from the active layout.
        AcDbObjectId idLayout = pBTR->getLayoutId();
        AcDbLayout *pLayout = NULL;
        es = acdbOpenObject(pLayout, idLayout, AcDb::kForRead);
        AcDbPlotSettings *pPlotSettings = new AcDbPlotSettings(pLayout->modelType());
        es = pPlotSettings->copyFrom(pLayout);
        pLayout->close();
        pBTR->close();

        AcDbPlotSettingsValidator *pPlotSettingsValidator = acdbHostApplicationServices()->plotSettingsValidator();
        if (pPlotSettingsValidator == NULL) return false;
        //设置打印的详细参数
        pPlotSettingsValidator->refreshLists (pPlotSettings);        // Refresh the layout lists in order to use it
        es = pPlotSettingsValidator->setPlotCfgName(pPlotSettings, strDeviceName);        //设置绘图仪
        es = pPlotSettingsValidator->setPlotWindowArea(pPlotSettings, ptMin.x, ptMin.y, ptMax.x, ptMax.y); //设置打印范围
        es = pPlotSettingsValidator->setPlotOrigin(pPlotSettings, ptMin.x, ptMin.y);        //设置origin
        es = pPlotSettingsValidator->setPlotCentered(pPlotSettings, true);        //是否居中打印
        es = pPlotSettingsValidator->setPlotType(pPlotSettings, AcDbPlotSettings::kExtents);        //打印类型
        es = pPlotSettingsValidator->setStdScale(pPlotSettings, dbScale);        //比例
        //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

        es = PlotEngine->beginPlot(pProgress, NULL);

        AcPlPlotInfo plotInfo;
        plotInfo.setLayout(idLayout);
        plotInfo.setOverrideSettings(pPlotSettings);

        AcPlPlotConfig *pPlotConfig = NULL;
        es = acplPlotConfigManagerPtr()->setCurrentConfig(pPlotConfig, strDeviceName);
        pPlotConfig->setPlotToFile(true);
        pPlotConfig->refreshMediaNameList();
        plotInfo.setDeviceOverride(pPlotConfig);

        //开始打印
        AcPlPlotInfoValidator plotInfoValidator;
        AcPlPlotPageInfo pageInfo;
        plotInfoValidator.setMediaMatchingPolicy(AcPlPlotInfoValidator::kMatchEnabled);
        plotInfoValidator.validate(plotInfo);
        es = PlotEngine->beginDocument(plotInfo, acDocManager->curDocument()->fileName(), NULL, 1, true, strFileName);
        es = PlotEngine->beginPage(pageInfo, plotInfo, true);
        es = PlotEngine->beginGenerateGraphics();
        PlotEngine->endGenerateGraphics();
        PlotEngine->endPage();
        PlotEngine->endDocument();
        PlotEngine->endPlot();

        PlotEngine->destroy();
        PlotEngine = NULL;
        pProgress->destroy();
        pProgress = NULL;
        delete pPlotSettings;
        pPlotSettings = NULL;

        return true;
}[/code]

 

 

 

 

arx  打印
您需要登录后才可以回帖 登录 | 立即注册

本版积分规则

QQ|Archiver|中国膜结构网|中国膜结构协会|进口膜材|国产膜材|ETFE|PVDF|PTFE|设计|施工|安装|车棚|看台|污水池|中国膜结构网_中国空间膜结构协会

GMT+8, 2024-11-1 11:40 , Processed in 0.131238 second(s), 26 queries .

Powered by Discuz! X3.5

© 2001-2024 Discuz! Team.

快速回复 返回顶部 返回列表