This document is archived and information here might be outdated. Recommended version. |
Provides access to the categories of SnapAgents.
ISnapAgentCategory provides a mechanism to organize and group SnapAgents. Custom SnapAgents are listed in the lower half of the Editor's Snapping dialog. Implement this interface if you want to place your snap agent into a particular category.
Name | Description | |
---|---|---|
Category | The Snap Agent category. |
Classes | Description |
---|---|
CenterlinesSnap (esriArcScan) | Snap agent that snaps to the centerlines of a raster. |
CornerSnap (esriArcScan) | Snap agent that snaps to the corners of a raster. |
EndsSnap (esriArcScan) | Snap agent that snaps to the ends of a raster. |
IntersectionSnap (esriArcScan) | Snap agent that snaps to the intersections of a raster. |
SolidSnap (esriArcScan) | Snap agent that snaps to the solids of a raster. |
FeatureSnap agents do not implement this interface. You should check the type of SnapAgent before attempting to access this interface.
The following example queries each snap agent that is turned on and prints its category name into the immediate window.
public void PrintSnapAgentCategories()
{
//get editor extension
UID editorUID = new UIDClass();
editorUID.Value = "esriEditor.Editor";
IEditor editor = m_application.FindExtensionByCLSID(editorUID) as IEditor;
//get snappingWIndow
UID snapWindowUID = new UIDClass();
snapWindowUID.Value = "esriEditor.SnappingWindow";
ISnappingWindow snapWindow = editor.FindExtension(snapWindowUID) as ISnappingWindow;
ISnapEnvironment snapEnvironment = editor as ISnapEnvironment;
//The editor's snapping logic uses bitwise combination of HitPartTypes.
//0 = PartNone, 1= partVertex, 4 = partBoundary, 16 = partEndpoint
//So 5 would bevtest partVertex and partBoundary and 21 would be all of
//the ones above
//Loop through the snap environment
for(int i = 0; i < snapEnvironment.SnapAgentCount; i++)
{
ISnapAgent snapAgent = snapEnvironment.get_SnapAgent(i);
if (!(snapAgent is IFeatureSnapAgent))
{
ISnapAgentCategory snapAgentCategory = snapAgent as ISnapAgentCategory;
System.Windows.Forms.MessageBox.Show("SnapAgent Name " + snapAgentCategory.Category);
}
}
}