Hi,
I am trying to open some AutoCAD file from a Location. After that in the newly opened file added a circle as required. Finally, Close the drawing file with save the newly drawing files.
Actually an error message shown that "Drawing is busy (COMException was caught)".
I have search so many link where discussed about the same. Whereas I am confuse which one the concrete solution for this type of coding.
Here is my Code please help!!
[CommandMethod("OPSV",CommandFlags.Session)] public static void OpenSaveDwgFiles() { Document doc = Autodesk.AutoCAD.ApplicationServices.Application.DocumentManager.MdiActiveDocument; Database db = doc.Database; try { var path = @"C:\TestBack\"; string dwgFlpath = string.Empty; DirectoryInfo d = new DirectoryInfo(path); FileInfo[] Files = d.GetFiles("*.dwg"); //string str = ""; foreach (FileInfo file in Files) { DocumentCollection docMgr = Autodesk.AutoCAD.ApplicationServices.Application.DocumentManager; var fileName = Path.GetFileName(file.FullName); dwgFlpath = path+fileName; DocumentCollectionExtension.Open(docMgr, dwgFlpath,false); using (DocumentLock LckDoc = doc.LockDocument()) { 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(); } } //doc.CloseAndDiscard(); doc.CloseAndSave(dwgFlpath.Substring(0,dwgFlpath.Length-4)); } } catch (System.Exception ex) { Autodesk.AutoCAD.ApplicationServices.Application.DocumentManager.MdiActiveDocument.Editor.WriteMessage(ex.ToString()); } }
Thanks
Solved! Go to Solution.
Solved by _gile. Go to Solution.
Dear Experts,
We dont know why even after so many years they are not giving record c sharp macro , record other(vbs or scr ) macros as .cs files or .vbs files
Note
the Activity recorder is dumb concept now. People are habituated to create scripts on their mobiles and on social networking. They expect these (record csharp macros) as most fundamental requirement as command line. Word, Excel , powerpoint has made users too much greedy for these features (Please understand)
Hello there
Can preview be included in this code?
How can we add these codes?
Thanks.
Document doc = Autodesk.AutoCAD.ApplicationServices.Core.Application.DocumentManager.MdiActiveDocument;
Database db = Application.DocumentManager.MdiActiveDocument.Database;
db.ThumbnailBitmap = doc.CapturePreviewImage(320, 240);
Hi Sir
I want to change the input (Link) that's the input from the user.
What's the class or Method for this?
Thank you!
@khugt60 wrote:
Hi Sir
I want to change the input (Link) that's the input from the user.
What's the class or Method for this?
Thank you!
For example, Editor.GetString()
Відповідь корисна? Клікніть на "ВПОДОБАЙКУ" цім повідомленням! | Do you find the posts helpful? "LIKE" these posts!
Находите сообщения полезными? Поставьте "НРАВИТСЯ" этим сообщениям!
На ваше запитання відповіли? Натисніть кнопку "ПРИЙНЯТИ РІШЕННЯ" | Have your question been answered successfully? Click "ACCEPT SOLUTION" button.
На ваш вопрос успешно ответили? Нажмите кнопку "УТВЕРДИТЬ РЕШЕНИЕ"
Alexander Rivilis / Александр Ривилис / Олександр Рівіліс
Programmer & Teacher & Helper / Программист - Учитель - Помощник / Програміст - вчитель - помічник
Facebook | Twitter | LinkedIn
Also read this article: https://www.keanw.com/2009/08/allowing-a-user-to-select-from-multiple-file-formats-inside-autocad-us...
Відповідь корисна? Клікніть на "ВПОДОБАЙКУ" цім повідомленням! | Do you find the posts helpful? "LIKE" these posts!
Находите сообщения полезными? Поставьте "НРАВИТСЯ" этим сообщениям!
На ваше запитання відповіли? Натисніть кнопку "ПРИЙНЯТИ РІШЕННЯ" | Have your question been answered successfully? Click "ACCEPT SOLUTION" button.
На ваш вопрос успешно ответили? Нажмите кнопку "УТВЕРДИТЬ РЕШЕНИЕ"
Alexander Rivilis / Александр Ривилис / Олександр Рівіліс
Programmer & Teacher & Helper / Программист - Учитель - Помощник / Програміст - вчитель - помічник
Facebook | Twitter | LinkedIn
Can't find what you're looking for? Ask the community or share your knowledge.