Ok, so as usual Autodesk has little to no documentation on the subject so I'm trying to glean from my seniors here. I'm attempting to write a bit of code that will perform a WBlock operation on a List of xrefs in a file. When I try to go through the WBlock process though Autocad raises an error stating there's an invalid key. I have no idea how to handle this particular exception and autodesk has no documentation on it. Anyone have any ideas?
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?
}
}
}