|
[code]// - AdskXrefGraph._XRG command
// Command to print Xref graph as a table
static void AdskXrefGraph_XRG(void)
{
Acad::ErrorStatus es = Acad::eOk;
AcDbXrefGraph graph;
AcDbXrefGraphNode *node;
TCHAR status[32];
TCHAR nested[12];
es = acedGetCurDwgXrefGraph(graph);
acutPrintf(_T("Number of nodes: %d\n\n"), graph.numNodes());
acutPrintf
(
_T("%3s%10s%15s%10s%12s\n"),
_T("#"),
_T("Name"),
_T("Status"),
_T("BTR ID"),
_T("Nested")
);
for (int i=0; i<graph.numNodes(); i++)
{
node = graph.xrefNode(i);
if (node != NULL)
{
switch(node->xrefStatus())
{
case AcDb::kXrfResolved :
_stprintf(status, _T("Resolved\0"));
break;
case AcDb::kXrfUnloaded :
_stprintf(status, _T("Unloaded\0"));
break;
case AcDb::kXrfUnreferenced :
_stprintf(status, _T("Unreferenced\0"));
break;
case AcDb::kXrfFileNotFound :
_stprintf(status, _T("File not found\0"));
break;
case AcDb::kXrfUnresolved :
_stprintf(status, _T("Unresolved\0"));
break;
default :
_stprintf
(
status,
_T("Unknown(%d)\0"),
node->xrefStatus()
);
}
if (node->btrId() == 0)
_stprintf(nested, _T("(root dwg)\0"));
else
_stprintf(
nested,
node->isNested() ? _T("Yes\0"):_T("No\0"));
acutPrintf(_T("%3d%10s%15s%10d%12s\n"), i, node->name(), status, node->btrId(), nested);
}
}
}
// - AdskXrefGraph._PXRG command (do not rename)
// Command that prints the Xref graph as a tree
static void AdskXrefGraph_PXRG(void)
{
AcDbXrefGraph graph;
acedGetCurDwgXrefGraph(graph);
if (graph.numNodes() <= 1)
return;
acutPrintf(_T("\n"));
printNode(graph.hostDwg(), graph.numNodes(), 0);
}
static void printNode(AcDbXrefGraphNode *node, int numNodes, int depth)
{
for (int i=1; i<= depth; i++)
acutPrintf(_T(" |"));
acutPrintf(_T("-> %s\n"), node->name());
if (node->numOut() > 0)
{
AcDbXrefGraphNode *nextNode;
for (int i=0; i<node->numOut(); i++)
{
nextNode = (AcDbXrefGraphNode *) node->out(i);
if (nextNode != NULL)
printNode(nextNode, numNodes, depth+1);
}
}
}[/code] |
|