明经CAD社区

 找回密码
 注册

QQ登录

只需一步,快速开始

搜索
查看: 1123|回复: 1

打印问题 获得打印机列表后CAD崩溃

[复制链接]
发表于 2018-7-28 15:49 | 显示全部楼层 |阅读模式
本帖最后由 sixhit@163.com 于 2018-7-28 15:59 编辑

运行网上找到的这段代码void fSetPlotMedia(),想通过这段代码获得打印机和相应纸张。运行后,能够正常选择打印机和纸张,但是之后就引起CAD 致命错误。有高手能指点一下问题出在哪儿吗?


void fSetPlotMedia()
{
        AcApLayoutManager *pLayMan = NULL;
        pLayMan = (AcApLayoutManager *)
                acdbHostApplicationServices()->layoutManager();
        //get the active layout
        AcDbLayout *pLayout = pLayMan->findLayoutNamed(
                pLayMan->findActiveLayout(TRUE),TRUE);

        //get the PlotSettingsValidator
        AcDbPlotSettingsValidator *pPSV =NULL;
        pPSV = acdbHostApplicationServices()->plotSettingsValidator();
        //refresh the Plot Config list
        pPSV->refreshLists(pLayout);

        //get all the Plot Configurations
        AcArray<const ACHAR *> mDeviceList;
        pPSV->plotDeviceList(mDeviceList);

        acutPrintf(_T("\nPlot Configuration List :"));
        int nLength = mDeviceList.length();

        for(int nCtr = 0;nCtr<nLength ;nCtr++)
        {
                acutPrintf(_T("\n %i) - %s"),(nCtr + 1), mDeviceList.at(nCtr));
        }

        //get the user input for listing the Media Names
        int nSel;
        int mRes =  RTNONE;

        while(RTNORM != mRes)
        {
                acedInitGet((RSG_NONULL + RSG_NONEG + RSG_NOZERO),NULL);
                mRes = acedGetInt(_T("\nSelect the Plot Configuration number: "),
                        &nSel);
                if (nSel > nLength)
                {
                        acutPrintf(_T("\nEnter a number between 1 to %i"),nLength);
                        mRes = RTNONE;
                }
        }

        //select the selected Plot configuration
        pPSV->setPlotCfgName(pLayout,mDeviceList.at(--nSel));
        //list all the paper sizes in the given Plot configuration
        AcArray<const ACHAR *> mMediaList;
        const ACHAR *pLocaleName;
        pPSV->canonicalMediaNameList(pLayout,mMediaList);

        acutPrintf(_T("\nMedia list for Plot Configuration - %s:"),
                mDeviceList.at(nSel));

        nLength = mMediaList.length();
        int nCtr ;
        for(nCtr = 0;nCtr<nLength ;nCtr++)
        {
                //get the localename
                pPSV->getLocaleMediaName(pLayout,mMediaList.at(nCtr),pLocaleName);
                acutPrintf(_T("\n %i)\n   Name:  %s \n   Locale Name: %s "),
                        (nCtr + 1),mMediaList.at(nCtr),pLocaleName);
        }
        mRes =  RTNONE;
        while(RTNORM != mRes)
        {
                acedInitGet((RSG_NONULL + RSG_NONEG + RSG_NOZERO),NULL);
                mRes = acedGetInt(
                        _T("\nSelect the Media by entering the number: "),
                        &nSel);

                if (nSel > nLength)
                {
                        acutPrintf(_T("\nEnter a number between 1 to %i"),nLength);
                        mRes = RTNONE;
                }
        }
        //set selected Media for the layout
        pPSV->setCanonicalMediaName(pLayout,mMediaList.at(--nSel));
        pLayout->close();
}


上传的截图顺序反了,只好把代码重新粘上来。见谅。

本帖子中包含更多资源

您需要 登录 才可以下载或查看,没有账号?注册

x
发表于 2018-8-1 16:32 | 显示全部楼层
看不懂 哈哈哈哈IIII
您需要登录后才可以回帖 登录 | 注册

本版积分规则

小黑屋|手机版|CAD论坛|CAD教程|CAD下载|联系我们|关于明经|明经通道 ( 粤ICP备05003914号 )  
©2000-2023 明经通道 版权所有 本站代码,在未取得本站及作者授权的情况下,不得用于商业用途

GMT+8, 2024-4-19 18:26 , Processed in 0.467045 second(s), 24 queries , Gzip On.

Powered by Discuz! X3.4

Copyright © 2001-2021, Tencent Cloud.

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