コード例 #1
0
ファイル: Test1.cs プロジェクト: caobinh92/Autocad
        public static string[] GetPlotDeviceAndCanonicalMediaName()
        {
            Document acDoc   = Application.DocumentManager.MdiActiveDocument;
            Editor   acDocEd = acDoc.Editor;
            PlotSettingsValidator acPlSetVdr  = PlotSettingsValidator.Current;
            StringCollection      acPlDevColl = acPlSetVdr.GetPlotDeviceList();

            for (int i = 0; i < acPlDevColl.Count; i++)
            {
                acDocEd.WriteMessage("\nNumber of device: {0}  -  Device name: {1}", i, acPlDevColl[i]);
            }
            int    n       = GetIntPrompt(acDoc, "Pick number of device to plot", 1, acPlDevColl.Count);
            string acPlDev = acPlDevColl[n];
            string acCanMed;

            Application.ShowAlertDialog("Plot device was chosen: " + acPlDev);
            using (PlotSettings acPlSet = new PlotSettings(true))
            {
                acPlSetVdr.SetPlotConfigurationName(acPlSet, acPlDev, null);
                acPlSetVdr.RefreshLists(acPlSet);
                StringCollection acCanMedColl = acPlSetVdr.GetCanonicalMediaNameList(acPlSet);
                for (int i = 0; i < acCanMedColl.Count; i++)
                {
                    acDocEd.WriteMessage("\nNumber of Canonical media name: {0}  -  Canonical media name: {1}", i, acCanMedColl[i]);
                }
                n        = GetIntPrompt(acDoc, "Pick number of Canonical media name", 1, acCanMedColl.Count);
                acCanMed = acCanMedColl[n];
                Application.ShowAlertDialog("Canonical media name: " + acCanMed);
            }

            return(new string[2] {
                acPlDev, acCanMed
            });
        }
コード例 #2
0
        public void QueryPlotters()
        {
            Document doc = Application.DocumentManager.MdiActiveDocument;
            Database db  = doc.Database;
            Editor   ed  = doc.Editor;

            LayoutManager         layMgr   = LayoutManager.Current;
            PlotSettingsValidator plSetVdr = PlotSettingsValidator.Current;

            db.TileMode = false;        //goto Paperspace if not already
            ed.SwitchToPaperSpace();    //turn PVP off

            using (Transaction tr = db.TransactionManager.StartTransaction())
            {
                Layout theLayout = (Layout)tr.GetObject(layMgr.GetLayoutId(layMgr.CurrentLayout), OpenMode.ForRead);

                PlotSettings np = new PlotSettings(theLayout.ModelType);
                np.CopyFrom(theLayout);

                //string devName = "DWG To PDF.pc3";
                StringCollection devNames = plSetVdr.GetPlotDeviceList();
                ed.WriteMessage("\n{0} Plotters", devNames.Count);

                int i = 0;
                foreach (string devName in devNames)
                {
                    ed.WriteMessage("\n{0}: {1}", i, devName);
                    i++;
                }
            }
        }
コード例 #3
0
ファイル: PageSetup.cs プロジェクト: 15831944/TX-DMS
        bool FillDeviceCombo()
        {
            StringCollection devices = m_plotSettingVal.GetPlotDeviceList();

            comboBoxDevices.Items.Clear();

            foreach (String strDevice in devices)
            {
                comboBoxDevices.Items.Add(strDevice);
            }
            return(true);
        }
コード例 #4
0
ファイル: SubClass.cs プロジェクト: caobinh92/Autocad
        public string[] GetPlotDevice(Document acDoc)
        {
            Database acCurDb = acDoc.Database;
            PlotSettingsValidator acPlSetVdr = PlotSettingsValidator.Current;
            StringCollection      acPlDevCol = acPlSetVdr.GetPlotDeviceList();

            string[] acStrPlDevCol = new string[acPlDevCol.Count];
            for (int k = 0; k < acPlDevCol.Count; k++)
            {
                acStrPlDevCol[k] = acPlDevCol[k];
            }
            return(acStrPlDevCol);
        }
コード例 #5
0
        /// <summary>
        /// Refreshing list of plotter
        /// </summary>
        public static void RefreshPloter(ComboBox cboPlotter)
        {
            // Update devices name
            PlotSettingsValidator psv = PlotSettingsValidator.Current;
            PlotSettings          ps  = new PlotSettings(true);

            psv.RefreshLists(ps);

            // Store current device's name
            string curPlotter = cboPlotter.Text;

            //Append plotter/printer to combobox
            StringCollection devList = psv.GetPlotDeviceList();

            cboPlotter.Items.Clear();
            for (int i = 0; i < devList.Count; i++)
            {
                if (devList[i] == "None")
                {
                    continue;
                }
                cboPlotter.Items.Add(devList[i]);
            }
            if (devList.Contains(curPlotter))
            {
                cboPlotter.Text = curPlotter;
            }
            else
            {
                //Setting default plotter/printer
                if (devList.Contains("PDF reDirect v2_A3.pc3"))
                {
                    cboPlotter.SelectedIndex =
                        cboPlotter.Items.IndexOf("PDF reDirect v2_A3.pc3");
                }
                else if (devList.Contains("PDF reDirect v2"))
                {
                    cboPlotter.SelectedIndex =
                        cboPlotter.Items.IndexOf("PDF reDirect v2");
                }
                else if (devList.Contains("DWG To PDF.pc3"))
                {
                    cboPlotter.SelectedIndex =
                        cboPlotter.Items.IndexOf("DWG To PDF.pc3");
                }
                else
                {
                    cboPlotter.SelectedIndex = 0;
                }
            }
        }
コード例 #6
0
        public void Test()
        {
            PlotSettingsValidator psv = PlotSettingsValidator.Current;
            var Text   = new List <string>();
            var editor = Acad.DocumentManager.MdiActiveDocument.Editor;

            System.Collections.Specialized.StringCollection vs = psv.GetPlotDeviceList();
            foreach (var st in vs)
            {
                editor.WriteMessage(st.ToString() + Environment.NewLine);
                Text.Add(st.ToString());
            }
            using (PlotSettings ps = new PlotSettings(false))
            {
                foreach (var st in vs)
                {
                    editor.WriteMessage("Текущий/Selected: " + st.ToString() + Environment.NewLine);
                    Text.Add("Текущий/Selected: " + st.ToString());
                    if (st.ToString() == "AutoCAD PDF (High Quality Print).pc3")
                    {
                        PlotConfig config = PlotConfigManager.SetCurrentConfig(st.ToString());
                        PlotInfo   info   = new PlotInfo();
                        psv.SetPlotConfigurationName(ps, st.ToString(), null);
                        psv.RefreshLists(ps);
                        System.Collections.Specialized.StringCollection mediaName = psv.GetCanonicalMediaNameList(ps);
                        foreach (var media in mediaName)
                        {
                            editor.WriteMessage("Формат/Media name " + media.ToString() + Environment.NewLine);
                            Text.Add("Формат/Media name " + media.ToString());
                            MediaBounds bounds = config.GetMediaBounds(media.ToString());
                            editor.WriteMessage(Math.Round(bounds.PageSize.X).ToString() + Environment.NewLine);
                            editor.WriteMessage(Math.Round(bounds.PageSize.Y).ToString() + Environment.NewLine);
                            editor.WriteMessage(Math.Round(bounds.LowerLeftPrintableArea.X).ToString() + Environment.NewLine);
                            editor.WriteMessage(Math.Round(bounds.UpperRightPrintableArea.Y).ToString() + Environment.NewLine);
                            editor.WriteMessage(Math.Round(bounds.UpperRightPrintableArea.X).ToString() + Environment.NewLine);
                            editor.WriteMessage(Math.Round(bounds.LowerLeftPrintableArea.Y).ToString() + Environment.NewLine);
                            Text.Add(Math.Round(bounds.PageSize.X).ToString());
                            Text.Add(Math.Round(bounds.PageSize.Y).ToString());
                            Text.Add(Math.Round(bounds.LowerLeftPrintableArea.X).ToString());
                            Text.Add(Math.Round(bounds.UpperRightPrintableArea.Y).ToString());
                            Text.Add(Math.Round(bounds.UpperRightPrintableArea.X).ToString());
                            Text.Add(Math.Round(bounds.LowerLeftPrintableArea.Y).ToString());
                        }
                    }
                }
            }
            System.IO.File.WriteAllLines("C:\\users\\dyn1\\desktop\\info.txt", Text);
        }
コード例 #7
0
ファイル: PlotTools.cs プロジェクト: coordinate/MyLearnning
        /// <summary>
        /// 将打印设备及标准图纸尺寸清单存储到XML文件
        /// </summary>
        /// <param name="fileName">XML文件名</param>
        public static void DeviceMeidaToXML(string fileName)
        {
            XElement xroot = new XElement("Root");//创建一个XML根元素
            //获取当前打印设备列表
            PlotSettingsValidator psv     = PlotSettingsValidator.Current;
            StringCollection      devices = psv.GetPlotDeviceList();
            //创建打印设置对象,以获取设备拥有的图纸尺寸
            PlotSettings ps = new PlotSettings(true);

            foreach (string device in devices)//遍历打印设备
            {
                //创建一个名为Device的新元素
                XElement xDevice = new XElement("Device");
                //在Device元素下添加表示设备名称的属性
                xDevice.Add(new XAttribute("Name", device));
                //更新打印设备、图纸尺寸,以反映当前系统状态。
                psv.SetPlotConfigurationName(ps, device, null);
                psv.RefreshLists(ps);
                //获取打印设备的所有可用标准图纸尺寸的名称
                StringCollection medias = psv.GetCanonicalMediaNameList(ps);
                foreach (string media in medias)
                {
                    //如果为用户自定义图纸尺寸,则结束本次循环
                    if (media == "UserDefinedMetric")
                    {
                        continue;
                    }
                    //创建一个名为Media的新元素
                    XElement xMedia = new XElement("Media");
                    //在Media元素下添加表示图纸尺寸的属性
                    xMedia.Add(new XAttribute("Name", media));
                    xDevice.Add(xMedia); //添加Media元素到Device元素中
                }
                xroot.Add(xDevice);      //添加Device元素到根元素中
            }
            xroot.Save(fileName);        //保存XML文件
        }