TheSwamp

Code Red => .NET => Topic started by: ken2023 on December 25, 2023, 09:16:33 AM

Title: use 'overkill' without opening Autocad Editor
Post by: ken2023 on December 25, 2023, 09:16:33 AM
I'm using AutoCAD .NET API, Can I 'overkill' some entities(Line, Arc, Circle, Poyline) by reading DWG File without opening Autocad Editor.

This is my idea:
Code - C#: [Select]
  1. using (Database db = new Database(false, true))
  2. {
  3.     db.ReadDwgFile(dwgFilePath, FileOpenMode.OpenForReadAndAllShare, false, null);
  4.     //overkill some entities from db
  5.     //....
  6.  
  7. }
  8.  
Title: Re: use 'overkill' without opening Autocad Editor
Post by: MickD on January 02, 2024, 02:48:56 AM
No, not using the 'overkill' command as it relies on the editor for selection.
You could try creating a selection set by iterating the drawing db (if you know what you're looking for) but I'm not sure you can 'Editor.Command()' with an in memory database as it's not related to a Document that has a pointer to the Editor.
I don't know if you can edit a Document in memory, someone might have more insight here.

Welcome to the Swamp!
Title: Re: use 'overkill' without opening Autocad Editor
Post by: ken2023 on January 02, 2024, 11:58:43 AM
No, not using the 'overkill' command as it relies on the editor for selection.
You could try creating a selection set by iterating the drawing db (if you know what you're looking for) but I'm not sure you can 'Editor.Command()' with an in memory database as it's not related to a Document that has a pointer to the Editor.
I don't know if you can edit a Document in memory, someone might have more insight here.

Welcome to the Swamp!

Very inspiring!

After some consideration, my approach is to first open dwg , then run the command, and finally close dwg.

Code: [Select]
...
doc = Application.DocumentManager.Open(dwgFilePath, false));
doc.SendStringToExecute("....", true, false, true);
...
doc.SendStringToExecute("close\n", true, false, true);
Title: Re: use 'overkill' without opening Autocad Editor
Post by: MickD on January 02, 2024, 06:35:27 PM
That'll work :)

You can also use the document's Editor like so

Code - C#: [Select]
  1. var ed = Application.DocumentManager.MdiActiveDocument.Editor;
  2. ed.Command("._-overkill", "P", "", "");
  3.  
Title: Re: use 'overkill' without opening Autocad Editor
Post by: MarioR on January 05, 2024, 11:48:52 AM
Hello,

another possibility is to use the accoreconsole.exe
With this exe you can load a DWG, change it with the help of commands, also overkill and save it again.

It is also possible to load .net dlls and then use the commands they contain.

The advantage is that no user interface is loaded.

I use it to create dwg's from data or to plot many dwg's into pdf's. The speed advantage is between 30-50%.

regards Mario