I'm trying to create snapping agent, I'm using the standrd code from ESRI ArcObject Library, this code woks perfectly on VB6/ArcGIS 9.3, but not on VB.net (3.5 SDK) and ArcGIS 10.
The property "SnapAgentCount" is empty :
pSnapEnv.SnapAgentCount = 0=========================
Public Sub SetBufferSnapClass() On Error Resume Next Dim pApp As IApplication, pMap As IMap, pFeatLayer As IFeatureLayer Dim pEditor As IEditor Dim pSnapAgent As ISnapAgent Dim pSnapEnv As ISnapEnvironment Dim pEditLayers As IEditLayers Dim pMySnapAgent As BufferSnapPrj.BufferSnap 'use VB6 sample 'Dim pMySnapAgent As BufferSnapVBNet.BufferSnap 'use VB.Net sample 'Dim pMySnapAgent As BufferSnapCS.BufferSnap 'use C# sample Dim pUID As New UID Dim Count As Integer, Count2 As Integer pUID = "esriEditor.Editor" Set pApp = Application Set pEditor = pApp.FindExtensionByCLSID(pUID) Set pEditLayers = pEditor Set pSnapEnv = pEditor Set pMap = pEditor.Map 'Find custom snap agent and set is featureclass property For Count2 = 0 To pMap.LayerCount - 1 If UCase(pMap.Layer(Count2).Name) = "POLES" Then For Count = 0 To pSnapEnv.SnapAgentCount - 1 Set pSnapAgent = pSnapEnv.SnapAgent(Count) If pSnapAgent.Name = "Buffer Snap" Then Set pMySnapAgent = pSnapAgent Set pFeatLayer = pMap.Layer(Count2) Set pMySnapAgent.FeatureClass = pFeatLayer.FeatureClass End If Next Count Exit For End If Next Count2End SubBut, when I add the Standard Edition ToolBar, and under options, I activate "use classic snapping" It works !
Is this the only way to do it ? Beacuase I don't want to use the standard Edition ToolBar.
Thank you in advance.
أكثر...
The property "SnapAgentCount" is empty :
pSnapEnv.SnapAgentCount = 0=========================
Public Sub SetBufferSnapClass() On Error Resume Next Dim pApp As IApplication, pMap As IMap, pFeatLayer As IFeatureLayer Dim pEditor As IEditor Dim pSnapAgent As ISnapAgent Dim pSnapEnv As ISnapEnvironment Dim pEditLayers As IEditLayers Dim pMySnapAgent As BufferSnapPrj.BufferSnap 'use VB6 sample 'Dim pMySnapAgent As BufferSnapVBNet.BufferSnap 'use VB.Net sample 'Dim pMySnapAgent As BufferSnapCS.BufferSnap 'use C# sample Dim pUID As New UID Dim Count As Integer, Count2 As Integer pUID = "esriEditor.Editor" Set pApp = Application Set pEditor = pApp.FindExtensionByCLSID(pUID) Set pEditLayers = pEditor Set pSnapEnv = pEditor Set pMap = pEditor.Map 'Find custom snap agent and set is featureclass property For Count2 = 0 To pMap.LayerCount - 1 If UCase(pMap.Layer(Count2).Name) = "POLES" Then For Count = 0 To pSnapEnv.SnapAgentCount - 1 Set pSnapAgent = pSnapEnv.SnapAgent(Count) If pSnapAgent.Name = "Buffer Snap" Then Set pMySnapAgent = pSnapAgent Set pFeatLayer = pMap.Layer(Count2) Set pMySnapAgent.FeatureClass = pFeatLayer.FeatureClass End If Next Count Exit For End If Next Count2End SubBut, when I add the Standard Edition ToolBar, and under options, I activate "use classic snapping" It works !
Is this the only way to do it ? Beacuase I don't want to use the standard Edition ToolBar.
Thank you in advance.
أكثر...