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

Please verify: DocumentCollection.Open(dwgfileName) does not work when a modal dialog box is loaded.

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

Please verify: DocumentCollection.Open(dwgfileName) does not work when a modal dialog box is loaded.

Since there is no document on this, can someone confirm this?

In Acad VBA, you can open/close drawings when a UserFrom is shown as modal
dialog, however, with .NET API, following call will cause "eNoDocument"
exception:

Autodesk.AutoCAD.ApplicationServices.Application.DocumentManager.Open("[Path]\Drawing1.dwg");

I tried it in a button's Click event handler, in the Dialog box's Load event
handler, or even hide the dialog box first.

I did a few project using Palette or modeless dialog box, where I open
drawings when needed, without issue. I am a bit surprised when in my current
project the first time I want to open a drawing with a button on a modal
dialog box, as I often did in VBA before, and got the "eNoDocument"
exception.

I have the workaround for my project, just a bit surprised and want to make
sure this is true.
7 REPLIES 7
Message 2 of 8
Anonymous
in reply to: Anonymous

You are right!
Message 3 of 8
Anonymous
in reply to: Anonymous

It has less to do with the modality of the dialog and
more to do with the execution context (Document or
Application).

The DocumentCollection's IsApplicationContext property
must be true to open or close drawings.

The reason it works in VBA with a modal dialog is
because the VBA code that calls the modal dialog is
(usually) running in the application context and that
means that all of the event handlers in the dialog are
also running in that same context (unless the dialog
was started from VBA code that was in turn started
from LISP using a call to vla-runmacro)


--
http://www.caddzone.com

AcadXTabs: MDI Document Tabs for AutoCAD 2004/2005/2006/2007
http://www.acadxtabs.com

"Norman Yuan" wrote in message news:5463695@discussion.autodesk.com...
Since there is no document on this, can someone confirm this?

In Acad VBA, you can open/close drawings when a UserFrom is shown as modal
dialog, however, with .NET API, following call will cause "eNoDocument"
exception:

Autodesk.AutoCAD.ApplicationServices.Application.DocumentManager.Open("[Path]\Drawing1.dwg");

I tried it in a button's Click event handler, in the Dialog box's Load event
handler, or even hide the dialog box first.

I did a few project using Palette or modeless dialog box, where I open
drawings when needed, without issue. I am a bit surprised when in my current
project the first time I want to open a drawing with a button on a modal
dialog box, as I often did in VBA before, and got the "eNoDocument"
exception.

I have the workaround for my project, just a bit surprised and want to make
sure this is true.
Message 4 of 8
Anonymous
in reply to: Anonymous

Tony! I try execute this code from ExecuteInApplicationContextCallback but without success. 😞
It is intersting that Autodesk.AutoCAD.ApplicationServices.Application.DocumentManager.IsApplicationContext in this context is true.
More over - tihis code: http://www.theswamp.org/index.php?topic=12291.msg152069#msg152069 also is not working in modal dialog (even from ExecuteInApplicationContextCallback context) Message was edited by: Alexander Rivilis
Message 5 of 8
Anonymous
in reply to: Anonymous

Hi Alex. Try calling acedSyncFileOpen() from the
callback and after it returns, activate the document
from which you called ExecuteInApplicationContext.

--
http://www.caddzone.com

AcadXTabs: MDI Document Tabs for AutoCAD 2004/2005/2006/2007
http://www.acadxtabs.com

wrote in message news:5464855@discussion.autodesk.com...
Tony! I try execute this code from ExecuteInApplicationContextCallback but without success. 😞
Message 6 of 8
Anonymous
in reply to: Anonymous

Tony! In MDI acedSyncFileOpen() is dummy function. It do not open new document. In SDI it open dwg-file in current (single) document from modal dialog. I've tested it in AutoCAD 2006.
Message 7 of 8
Anonymous
in reply to: Anonymous

Alex - Oops.

My mistake... the function is appContextOpenDocument()

--
http://www.caddzone.com

AcadXTabs: MDI Document Tabs for AutoCAD 2004/2005/2006/2007
http://www.acadxtabs.com

wrote in message news:5467693@discussion.autodesk.com...
Tony! In MDI acedSyncFileOpen() is dummy function. It do not open new document. In SDI it open dwg-file in current (single) document from modal dialog. I've tested it in AutoCAD 2006.
Message 8 of 8
Anonymous
in reply to: Anonymous

No. This function do not help also:
[code]
Autodesk.AutoCAD.Runtime.Exception: eDocumentSwitchDisabled
[/code]
If I enable activation (DocumentActivationEnabled = true) , then:

[code]
Autodesk.AutoCAD.Runtime.Exception: eInvalidInput
[/code]
:(

Message was edited by: Alexander Rivilis

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