eNoInputFiler Error executing Document.ReadDwg()

eNoInputFiler Error executing Document.ReadDwg()

Anonymous
Not applicable
928 Views
1 Reply
Message 1 of 2

eNoInputFiler Error executing Document.ReadDwg()

Anonymous
Not applicable
Hi,

I am getting a eNoInputFiler error executing Document.ReadDwg() when I am not executing the method as an AutoCAD command (i.e. not called from a method marked with a CommandMethod annotation). If I execute the code called from a method called as an AutoCAD command, it works fine.

I have tracked down what appears to be the cause: The command executes in document context (and Document.ReadDwg works) and the other call comes from application context (Application.DocumentManager.IsApplicationContext = True) and the function fails.

Any suggestions?

- Scott
0 Likes
929 Views
1 Reply
Reply (1)
Message 2 of 2

phliberato
Advocate
Advocate

You need to lock the document.

 

Document doc = Application.DocumentManager.MdiActiveDocument;

            using (doc.LockDocument())

            {

                using (Database db = new Database(false, false))

                {

                        db.ReadDwgFile(filePath, FileOpenMode.OpenForReadAndWriteNoShare, true, null);

0 Likes