By Daniel Du
In Map 3D map clean tool, it marks the errors it finds.Here is an example to demonstrate how to use do it with API:
[CommandMethod("clean")]
public void DrawingCleanUp()
{
string sGroupKeyword = "GROUP";
string sErrorKeyword = "ERROR";
string sYes = "YES";
string sNo = "NO";
int iGrpErrCnt = 0;
Editor ed = Application.DocumentManager.MdiActiveDocument.Editor;
Autodesk.Gis.Map.Topology.Variable cadAction =
new Autodesk.Gis.Map.Topology.Variable();
cadAction.LoadProfile(@"C:\MapCleanDemo\myClean.dpf");
PromptKeywordOptions pkoCleanupType =
new PromptKeywordOptions("Cleanup Type:");
pkoCleanupType.Keywords.Add(
sGroupKeyword, sGroupKeyword, sGroupKeyword, true, true);
pkoCleanupType.Keywords.Add(
sErrorKeyword, sErrorKeyword, sErrorKeyword, true, true);
pkoCleanupType.AllowNone = true;
PromptKeywordOptions pkoFixError = new PromptKeywordOptions("Fix?");
pkoFixError.Keywords.Add(sYes, sYes, sYes, true, true);
pkoFixError.Keywords.Add(sNo, sNo, sNo, true, true);
pkoFixError.AllowNone = true;
PromptResult pres = ed.GetKeywords(pkoCleanupType);
if (pres.Status != PromptStatus.Cancel)
{
using (Autodesk.Gis.Map.Topology.TopologyClean cadCleanobj
= new Autodesk.Gis.Map.Topology.TopologyClean())
{
cadCleanobj.Init(cadAction, null);
cadCleanobj.Start();
cadCleanobj.GroupNext();
if (pres.StringResult.ToUpper().Equals(sErrorKeyword))
{
while (!cadCleanobj.Completed)
{
iGrpErrCnt = cadCleanobj.GroupErrorCount;
ed.WriteMessage("\nGroup Error Count: " + iGrpErrCnt);
ed.WriteMessage("\n* Iterating over Errors.");
for (int i = 0; i < iGrpErrCnt; i++)
{
cadCleanobj.ErrorCur(i);
ed.WriteMessage("\n* Current Error (X: "
+ Math.Round(cadCleanobj.ErrorPoint.X, 2)
+ " Y: " + Math.Round(cadCleanobj.ErrorPoint.Y, 2) + ")");
cadCleanobj.ErrorDraw();
if (ed.GetKeywords(pkoFixError).StringResult.ToUpper().Equals(sYes))
cadCleanobj.ErrorFix();
else
cadCleanobj.ErrorMark();
}
cadCleanobj.GroupNext();
}
}
else if (pres.StringResult.ToUpper().Equals(sGroupKeyword))
{
ed.WriteMessage("\nGroup Cleanup");
ed.WriteMessage("\n* Iterating over Groups.");
while (!cadCleanobj.Completed)
{
iGrpErrCnt = cadCleanobj.GroupErrorCount;
ed.WriteMessage("\nGroup Error Count: " + iGrpErrCnt);
cadCleanobj.GroupDraw();
if (ed.GetKeywords(pkoFixError).StringResult.ToUpper().Equals(sYes))
cadCleanobj.GroupFix();
else
cadCleanobj.GroupMark();
cadCleanobj.GroupNext();
}
}
else
ed.WriteMessage("\n" + pres.StringResult + " is not a valid option.");
cadCleanobj.End();
}
}
}