This works - thank you. But, it is far slower than close without saving changes, especially if there are thousands of objects.
In 64 bit MAP 3D 2011
I am trying to figure out how to code "closeandiscard" but cannot get past the "drawing busy" error. I have already cloned the queried objects to the dwg file I want to save and detached the drawing set. Now I want the user to be left with a blank "drawing1".
From my reading it looks as if I need to give the active document a name before I can discard it? It's confusing.
Commandflags.session was the answer. This leaves the user with a blank Drawing2 (or higher).
<CommandMethod("q4", CommandFlags.Session)> _ Sub q_4() Dim templatepath As String = "map2diso.dwt" Dim acdocmgr As acapp.DocumentCollection = acapp.Application.DocumentManager Dim acdoc As acapp.Document = acdocmgr.MdiActiveDocument 'query 'save 'detach acdoc.CloseAndDiscard() acdoc = acdocmgr.Add(templatepath) acdocmgr.MdiActiveDocument = acdoc End Sub