Proctor Posted June 19, 2008 Posted June 19, 2008 Hello: I have an app I am creating in w/ autocad .net api and when i run it, I use the following script to open a drawing: [size=2]Autodesk.AutoCAD.ApplicationServices.Application.DocumentManager.Open(myFile.ToString(), [/size][size=2][color=#0000ff]False[/color][/size][size=2]) Autodesk.AutoCAD.ApplicationServices.Application.DocumentManager.MdiActiveDocument.LockDocument(DocumentLockMode.Write, [/size][size=2][color=#0000ff]Nothing[/color][/size][size=2], [/size][size=2][color=#0000ff]Nothing[/color][/size][size=2], [/size][size=2][color=#0000ff]True[/color][/size][size=2]) [/size][size=2][color=#008000]'if the drawing is saved so that paperspace was showing, this code makes sure that model space is the default setting for the user to see. [/color][/size][size=2]Autodesk.AutoCAD.ApplicationServices.Application.SetSystemVariable([/size][size=2][color=#800000]"TileMode"[/color][/size][size=2], 1) [/size] however, if I try to do a File->Save As, it gives me this message: Document "Document name.dwg" has a command in progress. Hit enter to cancel or retry. I tried hitting enter and cancel, but I still am unable to save my drawing. What am I doing wrong? Thanks, Proctor Quote
LCE Posted June 20, 2008 Posted June 20, 2008 Proctor, Is that the complete code? You should have no problem saving if that is the only code. Quote
ASMI Posted June 20, 2008 Posted June 20, 2008 Check CMDACTIVE system variable before saving. I it equal 0 no active commands, otherwise: 1 - Ordinary command is active 2 - Ordinary command and a transparent command are active 4 - Script is active 8 - Dialog box is active 16 - DDE is active 32 - AutoLISP is active (only visible to an ObjectARX-defined command) 64 - ObjectARX command is active Quote
borgunit Posted June 20, 2008 Posted June 20, 2008 We have encountered this before also, but not inside code. This may help. http://usa.autodesk.com/adsk/servlet/ps/item?siteID=123112&id=2884967&linkID=9240617 Quote
Proctor Posted June 20, 2008 Author Posted June 20, 2008 Hello: Thinking and looking at what you all have said, I decided to find the exact place in my code where it's have trouble...and I found it in my CreateBlock subroutine. The code had numerous start transaction..dispose transactions...in it so I decided to redo with the using statement and clean it up... but now, when I run it...it goes all the way through w/out bombing; however, I don't think the block is being created...because I'm getting another error msg shortly after as my program keeps running that the object was not created. Can you please take a look at my code above and tell me what I could be missing? Thanks again for all your ideas and helping me with this. Proctor Had to attach..because it was to long: CreateBlock_using statement.txt Quote
Proctor Posted June 23, 2008 Author Posted June 23, 2008 Hello: I just wanted to let you know that I finally got it to work. Remember I told you that the problem ended up being somewhere in the create block proc ...so changed out several start and commit transactions for one: Using docLock As DocumentLock = ed.Document.LockDocument() Using trans As Transaction = ed.Document.TransactionManager.StartTransaction() after, my code went through this procedure just fine...but was erroring out in my AddLayer proc...just a dominoe effect. I was getting an error stating that the document wasn't locked...so change out those start and commit transactions for the Using statements as well.... After, everything fell into place. I think the whole thing was from bad code and not understanding where to start and dispose then restart another transaction...which is why I like the Using statment...it's much cleaning and takes care of everything. Anyway, just wanted to let you know and thank you all again for your time and inputs. Proctor Quote
varse11 Posted July 7, 2011 Posted July 7, 2011 Trying checking other dwg files that may be open and see if there is a command active in that drawing. I just found that I had the same issue and one of the minimised drawings had a selection waiting for me to provide a copy and paste command. Worth a try. Quote
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.