private void button1_Click(object sender, EventArgs e)
 {
     this.listBox1.Items.Clear();
     acadWnd.OpenFileDialog dlg = new Autodesk.AutoCAD.Windows.OpenFileDialog("选择图纸", null, "dwg;dxf", null, Autodesk.AutoCAD.Windows.OpenFileDialog.OpenFileDialogFlags.AllowMultiple);
     if (dlg.ShowDialog() == DialogResult.OK)
     {
         this.listBox1.Items.AddRange(dlg.GetFilenames().Where(c => MyUtility.FileInUse(c) == false).ToArray());
     }
 }
        public static void BatchConvert()
        {
            Editor ed = Autodesk.AutoCAD.ApplicationServices.Application.DocumentManager.MdiActiveDocument.Editor;

            ed.WriteMessage("Please Select Files to Convert\n");

            Autodesk.AutoCAD.Windows.OpenFileDialog ofd = new Autodesk.AutoCAD.Windows.OpenFileDialog(
                "Select AutoCAD files", "", "dwg", "",
                Autodesk.AutoCAD.Windows.OpenFileDialog.OpenFileDialogFlags.AllowMultiple);

            List <string> inputs = new List <string>();

            while (true)
            {
                ed.WriteMessage("Please Select Files to Convert. Select Cancel to Start Converting.\n");
                System.Windows.Forms.DialogResult result = ofd.ShowDialog();
                if (result == System.Windows.Forms.DialogResult.OK)
                {
                    string[] names = ofd.GetFilenames();
                    ed.WriteMessage(string.Join("\n", names.ToArray()) + "\n");

                    inputs.AddRange(names);
                }
                else
                {
                    break;
                }
            }

            // AC1015   AutoCAD 2000, AutoCAD 2000i, AutoCAD 2002
            // AC1018   AutoCAD 2004, AutoCAD 2005, AutoCAD 2006
            // AC1021   AutoCAD 2007, AutoCAD 2008, AutoCAD 2009
            // AC1024   AutoCAD 2010, AutoCAD 2011, AutoCAD 2012
            // AC1027   AutoCAD 2013
            inputs = inputs.Distinct().ToList();
            foreach (var input in inputs)
            {
                string output = "";
                if (!ConvertVersion(input, DwgVersion.AC1021, out output)) // target: AutoCAD 2007
                {
                    ed.WriteMessage("Fail: " + input + "\n");
                }
                else
                {
                    ed.WriteMessage("Output: " + output + "\n");
                }
            }
        }
Beispiel #3
0
        getFile(string title, string nameDefault, string extension, string nameDialog, bool selectMultiple = false)
        {
            List <string> files = new List <string>();

            acWindows.OpenFileDialog.OpenFileDialogFlags flags;
            //if (selectMultiple)
            //{
            //    flags = acWindows.OpenFileDialog.OpenFileDialogFlags.AllowMultiple;
            //}
            //else
            //{
            //    flags = acWindows.OpenFileDialog.OpenFileDialogFlags.DefaultIsFolder;
            //}

            flags = acWindows.OpenFileDialog.OpenFileDialogFlags.AllowMultiple |
                    acWindows.OpenFileDialog.OpenFileDialogFlags.DefaultIsFolder |
                    acWindows.OpenFileDialog.OpenFileDialogFlags.ForceDefaultFolder;

            string[] target;
            acWindows.OpenFileDialog ofd = new acWindows.OpenFileDialog(title,
                                                                        nameDefault,
                                                                        extension,
                                                                        nameDialog,
                                                                        flags);
            DialogResult dr = ofd.ShowDialog();

            if (dr == DialogResult.OK)
            {
                target = ofd.GetFilenames();
                foreach (string file in target)
                {
                    files.Add(file);
                }
                return(files);
            }
            else
            {
                return(null);
            }
        }
Beispiel #4
0
        public void NetLoad()
        {
#if NET20
            OpenFileDialog dlg =
                new OpenFileDialog(
                    "选择.Net程序集",
                    "",
                    "dll",
                    "NetLoadX",
                    OpenFileDialog.OpenFileDialogFlags.AllowMultiple);

            var res = dlg.ShowDialog();
            if (res == System.Windows.Forms.DialogResult.OK)
            {
                foreach (var name in dlg.GetFilenames())
                {
                    Loader loader = new Loader();
                    loader.Add(name.Replace("\\", "/"));
                }
            }
#elif NET45
            Autodesk.AutoCAD.Windows.OpenFileDialog dlg =
                new Autodesk.AutoCAD.Windows.OpenFileDialog(
                    "选择.Net程序集",
                    "",
                    "dll",
                    "NetLoadX",
                    Autodesk.AutoCAD.Windows.OpenFileDialog.OpenFileDialogFlags.AllowMultiple);

            var res = dlg.ShowDialog();
            if (res == System.Windows.Forms.DialogResult.OK)
            {
                foreach (var name in dlg.GetFilenames())
                {
                    Loader loader = new Loader();
                    loader.Add(name.Replace("\\", "/"));
                }
            }
#endif
        }
        private void click_AddDrawings(object sender, EventArgs e)
        {
            Autodesk.AutoCAD.Windows.OpenFileDialog ofd = new Autodesk.AutoCAD.Windows.OpenFileDialog("Select drawings:", null, "dwg", "AutoCADDrawings", Autodesk.AutoCAD.Windows.OpenFileDialog.OpenFileDialogFlags.AllowMultiple | Autodesk.AutoCAD.Windows.OpenFileDialog.OpenFileDialogFlags.DoNotTransferRemoteFiles);
            System.Windows.Forms.DialogResult       dr  = ofd.ShowDialog();

            if (dr != System.Windows.Forms.DialogResult.OK)
            {
                ed.WriteMessage("Invalid selection.");
                this.Close();
                return;
            }
            else
            {
                btn_Next.Enabled = true;
                dwgFiles         = ofd.GetFilenames();
                foreach (string file in dwgFiles)
                {
                    lv_Files.Items.Add(file);
                }
                lv_Files.AutoResizeColumns(ColumnHeaderAutoResizeStyle.ColumnContent);
            }
        }