Sunday, 10 July 2016

arcgis 10.0 - Add-in; Failure to get code to execute when toolbar button pressed


I had written several VBA routines for ArcGIS up through v9.3 and have since upgraded to 10. Since VBA will be a thing of the past in the next version, I downloaded and installed VB Express 2008 and successfully (I think) migrated the VBA to VB.Net 2008. I saved out each of the routines to their respective *.vb files and ran the Add-In wizard for a new project, adding each routine as a button added to a toolbar.


Everything compiles and I get my toolbar to show up in ArcMap, but when I press any of the buttons, they grey out and nothing executes. Similarly, the breakpoints I have inserted go hollow with a yellow triangle and when I hover over the breakpoint, it states that "The breakpoint will not currently be hit. No symbols have been loaded for this document."


I think that somehow I am missing the magic of how to tie the XML stuff (which I understand controls the toolbar and buttons) to the VB.Net code (which perform the actions). Is there any VB code that links the code back to the XML so it functions?


Any insight is greatly appreciated.


Thanks,


Dale Bridgford



P.S (added later) To provide a bit more background, I am enclosing a portion of the code. This is typical of what I have cludged together from various posts. All variations that I have tried are equally inoperative.


Again, any insight as to where I have gone astray would be greatly appreciated.


Thanks, Dale Bridgford


` Imports ESRI.ArcGIS.Geometry


Namespace ERMDTools


Public Class btnAddHyperlink
Inherits ESRI.ArcGIS.Desktop.AddIns.Button
Public Sub New()

End Sub


Protected Overrides Sub OnClick()
Dim pFeature As IFeature, pLayer As ILayer
Dim pMap As IMap
Dim pSRE As SpatialReferenceEnvironment
Dim pQF As IQueryFilter
Dim pMSR As ISpatialReference
Dim pGeoDataset As IGeoDataset
Dim pMxDoc As ESRI.ArcGIS.ArcMapUI.IMxDocument
pMxDoc = Nothing

pMxDoc = m_App.Document
pMap = pMxDoc.FocusMap
pMSR = pMap.SpatialReference `

Answer



I have solved my dilemma, more or less. I have found that the structure of the vb for the Add-In needed to be as follows:


[CODE]Imports ....

Public Class btnAddHyperlink Inherits ESRI.ArcGIS.Desktop.AddIns.Button


Public Sub New()


End Sub


Protected Overrides Sub OnClick()

Dim pFeature As IFeature, pLayer As ILayer

Dim pSRE As SpatialReferenceEnvironment
Dim pQF As IQueryFilter[/CODE]


and with that structure, the button would hit the code. Again, many thanks for everyone's assistance.


Dale


No comments:

Post a Comment

arcpy - Changing output name when exporting data driven pages to JPG?

Is there a way to save the output JPG, changing the output file name to the page name, instead of page number? I mean changing the script fo...