Message 1 of 13
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report
Hello,
I've been given the task of clearing Xref's from 200+ drawings and plotting them. I am stuck with getting(/finding) the Xref's in the drawings and i have no idea to solve this. Is there anyone that can help with this problem? Help would be greatly appreciated!
This is the code i've pieced together. I believe this only returns the drawing itself as an Xref, the actual Xref's remain unseen.
public void ZkSearchXref()
{
var doc = Autodesk.AutoCAD.ApplicationServices.Application.DocumentManager.MdiActiveDocument;
var db = doc.Database;
var editor = doc.Editor;
BlockTable blckTbl;
BlockTableRecord blckTblRcrd;
using (Transaction tr = db.TransactionManager.StartTransaction())
{
try
{
blckTbl = tr.GetObject(db.BlockTableId, OpenMode.ForRead) as BlockTable;
blckTblRcrd = tr.GetObject(blckTbl.ObjectId, OpenMode.ForRead) as BlockTableRecord;
//db.ResolveXrefs(false,true);
XrefGraph XrGraph = db.GetHostDwgXrefGraph(false);
GraphNode root = XrGraph.RootNode;
GraphNodeCollection gnC = XrGraph.GetOutgoing();
editor.WriteMessage("\n" + gnC.Count);
//XrefGraphNode child = root.Out(0);
//GraphNode child = root.Out(0);
//editor.WriteMessage(child.ToString());
editor.WriteMessage(root.NumOut.ToString());
editor.WriteMessage("\n"+XrGraph.NumNodes.ToString());
editor.WriteMessage(XrGraph.Node(0).ToString());
for (int i = 0; i < XrGraph.NumNodes; i++)
{
XrefGraphNode xrNode = XrGraph.GetXrefNode(i);
editor.WriteMessage("\n" + xrNode.NumIn);
editor.WriteMessage("\n" + xrNode.NumOut);
//XrefGraphNode xgn = xrNode.GetXrefNode(xrefName);
for (int j=0;j<xrNode.NumIn;j++)
{
}
editor.WriteMessage("\n"+"testing");
tr.Commit();
}
}
catch (Autodesk.AutoCAD.Runtime.Exception Ex)
{
Application.ShowAlertDialog("\n" + Ex.Message);
tr.Abort();
}
} //End TR
} //End ZkSearchXref
Solved! Go to Solution.