0

好的,像往常一样,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?
                        }
                    }
                }
4

0 回答 0