Message 1 of 2
Proxy Error
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report
Hello to all. I'm writing a snippet to bind all external references in a dwg file. Sometimes I get these two error messages, "eNotAllowedForThisProxy", "eNotClonedPrimaryProxy". Is there anyone could tell me why this is happening? In my code I've already tested if the external reference's state(not missing and can be resolved). Below is my binding code.
private void BindLoadedXref(Document acDoc, Database acDb, ObjectIdCollection xrefCollection, string errLogPath)
{
using (DocumentLock acLock = acDoc.LockDocument())
{
using (Transaction acTrans = acDoc.TransactionManager.StartTransaction())
{
// Get rootNode of Xref(The current drawing is always the root node).
using (XrefGraph rootNode = acDb.GetHostDwgXrefGraph(false))
{
if (rootNode != null)
{
// Get sub xref node number of the root node.
int subNodeNum = rootNode.NumNodes;
for (int i = 0; i < subNodeNum; i++)
{
// Get the sub node
XrefGraphNode xNode = rootNode.GetXrefNode(i) as XrefGraphNode;
if (xNode == null)
continue;
// Get the current drawing name without extension.
string fileNameCore = acDb.Filename.Substring(acDb.Filename.LastIndexOf("\\") + 1);
fileNameCore = fileNameCore.Substring(0, fileNameCore.Length - 4);
// If it's no the current drawing, put the objectId in xrefCollection.
if (!xNode.Name.Equals(fileNameCore))
{
if (xNode.XrefStatus == XrefStatus.Resolved)
{
xrefCollection.Add(xNode.BlockTableRecordId);
}
}
}
}
}
if (xrefCollection.Count > 0)
{
try
{
// Detach the unreferenced external reference.
acDb.BindXrefs(xrefCollection, false);
}
catch (System.Exception ex)
{
WriteLog(errLogPath, acDb.Filename, ex.Message);
acTrans.Abort();
return;
}
}
acTrans.Commit();
}
}
}
Please give some hint. Thanks a lot.