Search
 
SCRIPT & CODE EXAMPLE
 

CSHARP

open and close autocad api

        [CommandMethod("OPSV")]
        public static void OpenSaveDwgFiles()
        {
            try
            {
                var path = @"C:TestBack";
                DirectoryInfo d = new DirectoryInfo(path);
                FileInfo[] Files = d.GetFiles("*.dwg");
                foreach (FileInfo file in Files)
                {
                    var fileName = Path.GetFileName(file.FullName);
                    string dwgFlpath = path + fileName;
                    using (Database db = new Database(false, true))
                    {
                        db.ReadDwgFile(dwgFlpath, FileOpenMode.OpenForReadAndAllShare, false, null);
                        using (Transaction tr = db.TransactionManager.StartTransaction())
                        {
                            BlockTable bt = tr.GetObject(db.BlockTableId, OpenMode.ForRead) as BlockTable;
                            BlockTableRecord btr = tr.GetObject(bt[BlockTableRecord.ModelSpace], OpenMode.ForWrite) as BlockTableRecord;
                            using (Circle crcl = new Circle())
                            {
                                crcl.Center = new Point3d(1, 1, 0);
                                crcl.Radius = 2;
                                btr.AppendEntity(crcl);
                                tr.AddNewlyCreatedDBObject(crcl, true);
                            }
                            tr.Commit();
                        }
                        db.SaveAs(dwgFlpath, DwgVersion.Current);
                    }
                }
                Application.ShowAlertDialog("All files processed");
            }
            catch (System.Exception ex)
            {
                Application.DocumentManager.MdiActiveDocument.Editor.WriteMessage(ex.ToString());
            }
        }
Comment

PREVIOUS NEXT
Code Example
Csharp :: asp.net issue 
Csharp :: convert string csv line to list long c# 
Csharp :: ASP.NET Web Forms TextBox 
Csharp :: .Net Entity Framework Reseed SQL Server Table ID Column 
Csharp :: edit pdf itextsharip 
Csharp :: Cannot convert type child to type parent c# 
Csharp :: telerik mvc grid unbound column 
Csharp :: c# wtssendmessage 
Csharp :: C# Move Camera Over Terrain Using Touch Input In Unity 3D - Append To Camera 
Csharp :: c# download image from url 
Csharp :: C# if...else Statement 
Csharp :: Unity search all chidren of parent object 
Csharp :: ascii art american flag 
Csharp :: c# generate random key with specified length 
Csharp :: c# class where T : enum C# 7.03 
Csharp :: stack iterator c# 
Csharp :: 7485438 
Csharp :: slider script unity 
Csharp :: Library dll unless netloaded by AutoCAD 
Csharp :: id dublication exception c# .net core 
Csharp :: Propertychanged is not firing up when text is change 
Csharp :: c# for loop Statement 
Csharp :: lexicographically sorted 
Csharp :: wpf create rectangle c# 
Csharp :: Align String with Spaces [C#] 
Csharp :: subarray c# 
Csharp :: C# create delegate type at runtime 
Csharp :: unity custom editor hide values in dropdown list 
Csharp :: c# file watcher specific file 
Csharp :: Permutation and Combination in C# 
ADD CONTENT
Topic
Content
Source link
Name
2+6 =