天气与日历 切换到窄版

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

ARX如何得到当前CAD打印设备列表及其他打印设置内容

[复制链接]

该用户从未签到

主题

0

回帖

2912

积分

管理员

积分
2912
发表于 2024-6-22 09:46:18 | 显示全部楼层 |阅读模式
#include "dblayout.h"
#include "acaplmgr.h"
#include "dbplotsetval.h"
#include "dbplotsettings.h"

/*
To query the all the available plot configurations you should use plotDeviceList()
method of AcDbPlotSettingsValidator class.
And to get the list of available media names for a given plot configuration,
use canonicalMediaNameList() method AcDbPlotSettingsValidator class.
But note the media names may not be same as listed in the Plot dialog.
So to get the media name as listed in the drop down list,
supply the media name to the function getLocaleMediaName().

The sample code below lists the available plot configurations and asks the user to select one.
After user enters his choice, all the available media are listed and user can select one to set it current.
Please use ObjectARX Wizard to create an ARX project and call the function () from a user defined function.
Make sure that you are *not* registering the command using ACRX_CMD_SESSION.

*/
// This is command 'MPLOTS'
void mplotzzmplots()
{
    AcApLayoutManager *pLayMan = NULL;
    pLayMan = (AcApLayoutManager *) acdbHostApplicationServices()->layoutManager();
   
    //get the active layout
    AcDbLayout *pLayout = pLayMan->findLayoutNamed(pLayMan->findActiveLayout(TRUE),TRUE);
   
    AcDbPlotSettings* pPlotSetting = (AcDbPlotSettings*)pLayout;
    char* mediaName;
    pPlotSetting->getCanonicalMediaName(mediaName);
    acutPrintf("\nMedia Name:%s", mediaName);
   
    char* styleSheetName;
    pPlotSetting->getCurrentStyleSheet(styleSheetName);
    acutPrintf("\nStyleSheet Name:%s", styleSheetName);

    char* plotCfgname;
    pPlotSetting->getPlotCfgName(plotCfgname);          // Output pointer to name of configured system or PC3 plot device
    acutPrintf("\nPlotCfg Name:%s", plotCfgname);
   
    //get the PlotSettingsValidator
    AcDbPlotSettingsValidator *pPSV =NULL;
    pPSV = acdbHostApplicationServices()->plotSettingsValidator();
    //refresh the Plot Config list
    pPSV->refreshLists(pLayout);
   
    //get all the Plot Configurations
    AcArray< const char * > mDeviceList;
    pPSV->plotDeviceList(mDeviceList);
   
    acutPrintf("\nPlot Configuration List :");
    int nLength = mDeviceList.length();
   
    char* localeName;
    pPSV->getLocaleMediaName(pLayout, 0, localeName);
    acutPrintf("\nCur Midia Name:%s", localeName);
   
    pPlotSetting->close();
    pLayout->close();

    return;
    for(int nCtr = 0;nCtr < nLength; nCtr++)
    {
        acutPrintf("\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("\nSelect the Plot Configuration number to list the Media names: ", &nSel);
        if (nSel > nLength)
        {
            acutPrintf("\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 char * > mMediaList;
    const char *pLocaleName;
    pPSV->canonicalMediaNameList(pLayout,mMediaList);
   
    acutPrintf("\nMedia list for Plot Configuration - %s:",mDeviceList.at(nSel));
   
    nLength = mMediaList.length();
    for(nCtr = 0;nCtr < nLength; nCtr++)
    {
        //get the localename
        pPSV->getLocaleMediaName(pLayout,mMediaList.at(nCtr),pLocaleName);
        acutPrintf("\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("\nSelect the Media by entering the number: ", &nSel);
        if (nSel > nLength)
        {
            acutPrintf("\nEnter a number between 1 to %i",nLength);
            mRes = RTNONE;
        }
    }
    //set selected Media for the layout
    pPSV->setCanonicalMediaName(pLayout,mMediaList.at(--nSel));
    pLayout->close();
}

 

 

 

 

ARX如何得到当前CAD打印设备列表及其他打印设置内容
您需要登录后才可以回帖 登录 | 立即注册

本版积分规则

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

GMT+8, 2024-11-1 10:30 , Processed in 0.126659 second(s), 26 queries .

Powered by Discuz! X3.5

© 2001-2024 Discuz! Team.

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