找回密码
 立即注册

QQ登录

只需一步,快速开始

搜索
热搜: 活动 交友 discuz
查看: 154|回复: 0

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

[复制链接]

1

主题

0

回帖

43

积分

管理员

积分
43
发表于 2024-3-14 20:10:35 | 显示全部楼层 |阅读模式
  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. }
复制代码
您需要登录后才可以回帖 登录 | 立即注册

本版积分规则

Archiver|手机版|小黑屋|膜结构网

GMT+8, 2025-1-11 00:49 , Processed in 0.118904 second(s), 22 queries .

Powered by Discuz! X3.5

© 2001-2024 Discuz! Team.

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