Jump to content

Recommended Posts

Posted

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

Posted

Proctor,

Is that the complete code? You should have no problem saving if that is the only code.

Posted

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

Posted

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

Posted

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

  • 3 years later...
Posted

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.

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.

Guest
Unfortunately, your content contains terms that we do not allow. Please edit your content to remove the highlighted words below.
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...