找回密码
 立即注册

QQ登录

只需一步,快速开始

扫一扫,访问微社区

查看: 1734|回复: 2

[每日一码] 如何得到当前CAD打印设备列表及其他打印设置内容

[复制链接]

已领礼包: 13个

财富等级: 恭喜发财

发表于 2016-9-22 10:15:00 | 显示全部楼层 |阅读模式

马上注册,结交更多好友,享用更多功能,让你轻松玩转社区。

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

×
  1. #include "dblayout.h"
  2. #include "acaplmgr.h"
  3. #include "dbplotsetval.h"
  4. #include "dbplotsettings.h"


  5. // This is command 'MPLOTS'
  6. void mplotzzmplots()
  7. {
  8.     AcApLayoutManager *pLayMan = NULL;
  9.     pLayMan = (AcApLayoutManager *) acdbHostApplicationServices()->layoutManager();

  10.     //get the active layout
  11.     AcDbLayout *pLayout = pLayMan->findLayoutNamed(pLayMan->findActiveLayout(TRUE),TRUE);

  12.     AcDbPlotSettings* pPlotSetting = (AcDbPlotSettings*)pLayout;
  13.     char* mediaName;
  14.     pPlotSetting->getCanonicalMediaName(mediaName);
  15.     acutPrintf(" Media Name:%s", mediaName);

  16.     char* styleSheetName;
  17.     pPlotSetting->getCurrentStyleSheet(styleSheetName);
  18.     acutPrintf(" StyleSheet Name:%s", styleSheetName);

  19.     char* plotCfgname;
  20.     pPlotSetting->getPlotCfgName(plotCfgname);          // Output pointer to name of configured system or PC3 plot device
  21.     acutPrintf(" PlotCfg Name:%s", plotCfgname);

  22.     //get the PlotSettingsValidator
  23.     AcDbPlotSettingsValidator *pPSV =NULL;
  24.     pPSV = acdbHostApplicationServices()->plotSettingsValidator();
  25.     //refresh the Plot Config list
  26.     pPSV->refreshLists(pLayout);

  27.     //get all the Plot Configurations
  28.     AcArray< const char * > mDeviceList;
  29.     pPSV->plotDeviceList(mDeviceList);

  30.     acutPrintf(" Plot Configuration List :");
  31.     int nLength = mDeviceList.length();

  32.     char* localeName;
  33.     pPSV->getLocaleMediaName(pLayout, 0, localeName);
  34.     acutPrintf(" Cur Midia Name:%s", localeName);

  35.     pPlotSetting->close();
  36.     pLayout->close();

  37.     return;
  38.     for(int nCtr = 0;nCtr < nLength; nCtr++)
  39.     {
  40.             acutPrintf("  %i) - %s",(nCtr + 1), mDeviceList.at(nCtr));
  41.     }

  42.     //get the user input for listing the Media Names
  43.     int nSel;
  44.     int mRes =  RTNONE;

  45.     while(RTNORM != mRes)
  46.     {
  47.             acedInitGet((RSG_NONULL + RSG_NONEG + RSG_NOZERO),NULL);
  48.             mRes = acedGetInt(" Select the Plot Configuration number to list the Media names: ", &nSel);
  49.             if (nSel > nLength)
  50.             {
  51.                     acutPrintf(" Enter a number between 1 to %i",nLength);
  52.                     mRes = RTNONE;
  53.             }
  54.     }

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

  61.     acutPrintf(" Media list for Plot Configuration - %s:",mDeviceList.at(nSel));

  62.     nLength = mMediaList.length();
  63.     for(nCtr = 0;nCtr < nLength; nCtr++)
  64.     {
  65.             //get the localename
  66.             pPSV->getLocaleMediaName(pLayout,mMediaList.at(nCtr),pLocaleName);
  67.             acutPrintf("  %i)    Name:  %s     Locale Name: %s ",(nCtr + 1),mMediaList.at(nCtr),pLocaleName);
  68.     }
  69.     mRes =  RTNONE;
  70.     while(RTNORM != mRes)
  71.     {
  72.             acedInitGet((RSG_NONULL + RSG_NONEG + RSG_NOZERO),NULL);
  73.             mRes = acedGetInt(" Select the Media by entering the number: ", &nSel);
  74.             if (nSel > nLength)
  75.             {
  76.                     acutPrintf(" Enter a number between 1 to %i",nLength);
  77.                     mRes = RTNONE;
  78.             }
  79.     }
  80.     //set selected Media for the layout
  81.     pPSV->setCanonicalMediaName(pLayout,mMediaList.at(--nSel));
  82.     pLayout->close();
  83. }


论坛插件加载方法
发帖求助前要善用【论坛搜索】功能,那里可能会有你要找的答案;
如果你在论坛求助问题,并且已经从坛友或者管理的回复中解决了问题,请把帖子标题加上【已解决】;
如何回报帮助你解决问题的坛友,一个好办法就是给对方加【D豆】,加分不会扣除自己的积分,做一个热心并受欢迎的人!

已领礼包: 1个

财富等级: 恭喜发财

发表于 2016-11-28 17:44:42 | 显示全部楼层
确实是难得好帖啊,顶先
论坛插件加载方法
发帖求助前要善用【论坛搜索】功能,那里可能会有你要找的答案;
如果你在论坛求助问题,并且已经从坛友或者管理的回复中解决了问题,请把帖子标题加上【已解决】;
如何回报帮助你解决问题的坛友,一个好办法就是给对方加【D豆】,加分不会扣除自己的积分,做一个热心并受欢迎的人!
回复 支持 反对

使用道具 举报

已领礼包: 1个

财富等级: 恭喜发财

发表于 2016-11-28 17:50:24 | 显示全部楼层
正需要,支持楼主大人了!
论坛插件加载方法
发帖求助前要善用【论坛搜索】功能,那里可能会有你要找的答案;
如果你在论坛求助问题,并且已经从坛友或者管理的回复中解决了问题,请把帖子标题加上【已解决】;
如何回报帮助你解决问题的坛友,一个好办法就是给对方加【D豆】,加分不会扣除自己的积分,做一个热心并受欢迎的人!
回复 支持 反对

使用道具 举报

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

本版积分规则

QQ|申请友链|Archiver|手机版|小黑屋|辽公网安备|晓东CAD家园 ( 辽ICP备15016793号 )

GMT+8, 2024-9-24 18:29 , Processed in 0.180895 second(s), 32 queries , Gzip On.

Powered by Discuz! X3.5

© 2001-2024 Discuz! Team.

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