无法处理Autocad中的异常Errorstatus.EInvalidKey

时间:2013-09-24 21:31:02

标签: .net c#-4.0 autocad autocad-plugin

好的,像往常一样,Autodesk几乎没有关于这个主题的文档,所以我试图从我的老年人那里收集。我正在尝试编写一些代码,这些代码将对文件中的外部参照列表执行WBlock操作。当我尝试通过WBlock进程时,虽然Autocad引发了一个错误,指出存在无效密钥。我不知道如何处理这个特殊的异常,并且autodesk没有关于它的文档。有人有什么想法吗?

            foreach (BlockTableRecord x in xlist)
            {
                ......

                //if the Xref doesn't already exist...
                if (!File.Exists(Path.Combine(FilePath, NewXrefs, XrName)))
                {
                    try
                    {
                        //write the file out to a base location with its same name
                        Database xdata = x.GetXrefDatabase(true);
                        Database NewXref = Adbase.Wblock(x.ObjectId);
                        NewXrPath = Path.Combine(FilePath, NewXrefs, XrName);
                        NewXref.SaveAs(NewXrPath, DwgVersion.AC1021);
                    }

                    catch (Autodesk.AutoCAD.Runtime.Exception aex)
                    {
                        if (aex.ErrorStatus == ErrorStatus.InvalidKey)
                        {
                            //what do I do here?? or how do I prevent this exception?
                        }
                    }
                }

0 个答案:

没有答案