ArcGIS Snapping environment

714
4
Jump to solution
09-25-2012 02:18 AM
prasadprasad
New Contributor
Hi All

Anybody knows is there any way to check or uncheck the vertex or edge or End checkboxe's for a particular layer in ArcGIS snapping environment program-metrically (.NET)

Please find the attached image for more info

Rega
prasad
0 Kudos
1 Solution

Accepted Solutions
by Anonymous User
Not applicable
Be careful when using .ClearSnapAgents as it will delete them all which might not be what you want.
The other way to get the featuresnapagent for a layer is to loop through all agents (ISnapEnvironment.SnapAgentCount) then find the one you want by name.

Dont forget to refresh the snapping window after you have changed the snapagent properties.

//refresh snap window UID extUid = new UIDClass(); extUid.Value = "esriEditor.SnappingWindow"; ISnappingWindow snapWindow = _editor.FindExtension(extUid) as ISnappingWindow; snapWindow.RefreshContents();

View solution in original post

0 Kudos
4 Replies
NeilClemmons
Regular Contributor III
Use IFeatureSnapAgent2.HitType.
0 Kudos
prasadprasad
New Contributor
Use IFeatureSnapAgent2.HitType.


Hi Neil
Thank you very much for your reply
I am using following code as i am using ArcGIS 9.1 instead of using IFeatureSnapAgent2 i am using IFeatureSnapAgent but i doesn't check the vertex  checkbox

Please highlight if i am doing anything wrong

Try
            ' Dim pID As New ESRI.ArcGIS.esriSystem.UID
            Dim pApp As IApplication
            Dim pEditor As IEditor
            Dim pSnapEnv As ISnapEnvironment
            Dim pFeatSnap As IFeatureSnapAgent
            Dim pEditLayers As IEditLayers

            'pID = "esriEditor.Editor"
            pApp = m_App
            pEditor = m_App.FindExtensionByName("ESRI Object Editor")
            pEditLayers = pEditor 'QI
            pSnapEnv = pEditor 'QI
            Dim pCount As Integer = pSnapEnv.SnapAgentCount
            Dim p_WorkSpace As IWorkspace = pEditor.EditWorkspace

            Dim pFeatWorkspace As IFeatureWorkspace = p_WorkSpace
            Dim pFeaturecass As IFeatureClass = pFeatWorkspace.OpenFeatureClass("TestFC")
            pSnapEnv.ClearSnapAgents() 'clear all existing snap agents
            pFeatSnap = New FeatureSnap 'create a new feature snap agent
            pFeatSnap.FeatureClass = pFeaturecass
            'pFeatSnap.HitType = ESRI.ArcGIS.Geometry.esriGeometryHitPartType.esriGeometryPartEndpoint
            pFeatSnap.HitType = ESRI.ArcGIS.Geometry.esriGeometryHitPartType.esriGeometryPartVertex
          
            pSnapEnv.AddSnapAgent(pFeatSnap)

       
        Catch ex As Exception
    
        End Try
0 Kudos
by Anonymous User
Not applicable
Be careful when using .ClearSnapAgents as it will delete them all which might not be what you want.
The other way to get the featuresnapagent for a layer is to loop through all agents (ISnapEnvironment.SnapAgentCount) then find the one you want by name.

Dont forget to refresh the snapping window after you have changed the snapagent properties.

//refresh snap window UID extUid = new UIDClass(); extUid.Value = "esriEditor.SnappingWindow"; ISnappingWindow snapWindow = _editor.FindExtension(extUid) as ISnappingWindow; snapWindow.RefreshContents();
0 Kudos
prasadprasad
New Contributor
Be careful when using .ClearSnapAgents as it will delete them all which might not be what you want.
The other way to get the featuresnapagent for a layer is to loop through all agents (ISnapEnvironment.SnapAgentCount) then find the one you want by name.

Dont forget to refresh the snapping window after you have changed the snapagent properties.

//refresh snap window
UID extUid = new UIDClass();
extUid.Value = "esriEditor.SnappingWindow";
ISnappingWindow snapWindow = _editor.FindExtension(extUid) as ISnappingWindow;
snapWindow.RefreshContents();



Yes It worked thank you
0 Kudos