Author Topic: use 'overkill' without opening Autocad Editor  (Read 1569 times)

0 Members and 1 Guest are viewing this topic.

ken2023

  • Mosquito
  • Posts: 7
use 'overkill' without opening Autocad Editor
« 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.  

MickD

  • King Gator
  • Posts: 3636
  • (x-in)->[process]->(y-out) ... simples!
Re: use 'overkill' without opening Autocad Editor
« Reply #1 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!
"Programming is really just the mundane aspect of expressing a solution to a problem."
- John Carmack

"Short cuts make long delays,' argued Pippin.
- J.R.R. Tolkien

ken2023

  • Mosquito
  • Posts: 7
Re: use 'overkill' without opening Autocad Editor
« Reply #2 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);

MickD

  • King Gator
  • Posts: 3636
  • (x-in)->[process]->(y-out) ... simples!
Re: use 'overkill' without opening Autocad Editor
« Reply #3 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.  
"Programming is really just the mundane aspect of expressing a solution to a problem."
- John Carmack

"Short cuts make long delays,' argued Pippin.
- J.R.R. Tolkien

MarioR

  • Newt
  • Posts: 64
Re: use 'overkill' without opening Autocad Editor
« Reply #4 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