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

eNoInputFiler Error

6 REPLIES 6
Reply
Message 1 of 7
NLeininger
1135 Views, 6 Replies

eNoInputFiler Error

After running the following code block, the drawing becomes unusable, as every time I run ReadDwgFile after a successful run I get "ENoInputFiler."

 

 

foreach (ObjectId attributeObjId in anotherBlkTableRecord)
                                        {
                                            AttributeDefinition attributeDefinition = (trans.GetObject(attributeObjId, OpenMode.ForRead).GetType() == typeof(AttributeDefinition) ?
                                                (AttributeDefinition)trans.GetObject(attributeObjId, OpenMode.ForRead) : null);
                                            if (attributeDefinition != null)
                                            {
                                                if (string.Compare(attributeDefinition.Prompt, attributePrompt, true) == 0)
                                                {
                                                    return GetAttributeValueStep2(activeDb, workingBlock, attributeDefinition.Tag);
                                                }
                                            }
                                        }

 

Am I doing something wrong?

6 REPLIES 6
Message 2 of 7
_gile
in reply to: NLeininger

Hi,

 

Look at the 'as' operator.

foreach (ObjectId attributeObjId in anotherBlkTableRecord)
{
    AttributeDefinition attributeDefinition = 
	    trans.GetObject(attributeObjId, OpenMode.ForRead) as AttributeDefinition;
    if (attributeDefinition != null)
    {
        if (attributeDefinition.Prompt == attributePrompt)
        {
            return GetAttributeValueStep2(activeDb, workingBlock, attributeDefinition.Tag);
        }
    }
}

 Or, more efficient, check the underlying type of the ObjectId

RXClass attDefClass = RXClass.GetClass(typeof(AttributeDefinition));
foreach (ObjectId attributeObjId in anotherBlkTableRecord)
{
	if (attributeObjId.ObjectClass == attDefClass)
	{
        AttributeDefinition attributeDefinition = 
	        (AttributeDefinition)trans.GetObject(attributeObjId, OpenMode.ForRead);
        if (attributeDefinition.Prompt == attributePrompt)
        {
            return GetAttributeValueStep2(activeDb, workingBlock, attributeDefinition.Tag);
        }
    }
}

 



Gilles Chanteau
Programmation AutoCAD LISP/.NET
GileCAD
GitHub

Message 3 of 7
NLeininger
in reply to: _gile

I've re-written the code as you suggested.  I still get the error when trying to read a drawing, though.

 

using (Autodesk.AutoCAD.DatabaseServices.Database acDb = new Autodesk.AutoCAD.DatabaseServices.Database(false, false))
                    {
                        acDb.ReadDwgFile(fileToProcess, FileShare.ReadWrite, false, string.Empty);


....

}

 

The bolded line is throwing the error.

Message 4 of 7
fenton.webb
in reply to: NLeininger

we need a buildable sample to look at with sample dwg - as far as I can tell, your code doesn't show anything wrong




Fenton Webb
AutoCAD Engineering
Autodesk

Message 5 of 7
NLeininger
in reply to: fenton.webb

I'm trying to attach a zip file with the program and sample drawing, but it keeps telling the file is corrupted.

Message 6 of 7
Balaji_Ram
in reply to: NLeininger

I had a similar problem in attaching files to another post.

Please try again and if does not work, you can share it using dropbox or mail it to me.

 

 

 

 

 

 

 



Balaji
Developer Technical Services
Autodesk Developer Network

Message 7 of 7
Balaji_Ram
in reply to: NLeininger

Hi Neil,

 

Thanks for mailing the sample project to reproduce the behavior.

 

Iam posting the code snippet that I sent in my reply to you for future reference.

 

To resolve it, you need to lock the document or create the database without associating with the current document.

 

Document doc = Application.DocumentManager.MdiActiveDocument;
using (DocumentLock docLock = doc.LockDocument())
{
using (Autodesk.AutoCAD.DatabaseServices.Database acDb = new Autodesk.AutoCAD.DatabaseServices.Database(false, false))
{
acDb.ReadDwgFile(fileToProcess, FileShare.ReadWrite, false, string.Empty);
//...
}
}

Or create the database without associating it with the active document as :

using (Autodesk.AutoCAD.DatabaseServices.Database acDb = new Autodesk.AutoCAD.DatabaseServices.Database(false, true))
{
acDb.ReadDwgFile(fileToProcess, FileShare.ReadWrite, false, string.Empty);
//...
}

 

 

 



Balaji
Developer Technical Services
Autodesk Developer Network

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