.NET
cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 

Document "xxx.dwg" has a command in progress.

7 REPLIES 7
Reply
Message 1 of 8
Anonymous
1285 Views, 7 Replies

Document "xxx.dwg" has a command in progress.

I have a .NET app that shows a modeless dialog which is a customized print application.
It works fine except when I try to use the "qsave" command on the drawing after plotting or previewing it.
I get a message at the command line:
Document "xxx.dwg" has a command in progress.

Other commands such as Line, Copy, Move etc. work fine. Even the "Save" command works.

I've searched and read every post I could find on this subject including some in Russian (which may have lost something in the translation to English).

Is there some way to tell the Document that it doesn't have a command in progress?
7 REPLIES 7
Message 2 of 8
Anonymous
in reply to: Anonymous

Does your app lock the document during its execution? If so, how does it unlock it?
Message 3 of 8
Anonymous
in reply to: Anonymous

Yes I lock the document (variable named ThisDrawing) with ThisDrawing.LockDocument()

Then at the end of the function I use this:
ThisDrawing.LockDocument(DocumentLockMode.NotLocked, string.Empty, string.Empty, false);
Message 4 of 8
Anonymous
in reply to: Anonymous

Document ThisDrawing = Autodesk.AutoCAD.ApplicationServices.Application.DocumentManager.MdiActiveDocument;
DocumentLock dLock = ThisDrawing.LockDocument();
// modify the database here
dLock.Dispose();
Message 5 of 8
Anonymous
in reply to: Anonymous

Which of the two do you use? The first one is wrong. The second should work and allow you to execute commands after its completion.
Message 6 of 8
Anonymous
in reply to: Anonymous

What -two- do you mean?
The first part is to create the lock and the last is to dispose of the lock.
Message 7 of 8
Anonymous
in reply to: Anonymous

You have answered twice to my question.
The first answer:

"Yes I lock the document (variable named ThisDrawing) with ThisDrawing.LockDocument()

Then at the end of the function I use this:
ThisDrawing.LockDocument(DocumentLockMode.NotLocked, string.Empty, string.Empty, false);"

describes a wrong method.

The second answer:

" Re: Document "xxx.dwg" has a command in progress.
Document ThisDrawing = Autodesk.AutoCAD.ApplicationServices.Application.DocumentManager.MdiActiveDocum ent;
DocumentLock dLock = ThisDrawing.LockDocument();
// modify the database here
dLock.Dispose();"

is correct.

In general, you should lock the document any way you want, but to unlock it, you just dispose the object you got when you locked the doc. I don't know what "NotLocked" is for, but it sure does not unlock the document.
This locks the doc (as you already know):
DocumentLock dLock = ThisDrawing.LockDocument(DocumentLockMode....., ...., ...., ....);
then you do your work...
...
and lastly you unlock the doc to allow for other commands to manipulate it:
dLock.Dispose();
Message 8 of 8
Anonymous
in reply to: Anonymous

Ah, I understand what you were asking now.
Yes, I was mistaken in thinking that .LockDocument(anything here) could UNLock a document.

Can't find what you're looking for? Ask the community or share your knowledge.

Post to forums  

Autodesk DevCon in Munich May 28-29th


Autodesk Design & Make Report

”Boost