ICalculatorUI calc = new CalculatorUI(); calc.Table = MyTable; calc.Field = "MyField"; calc.DoModal(ArcMap.Application.hWnd);
Solved! Go to Solution.
So for anyone interested, I am now using ICalculate to execute the expressions that were provided by the user. Of course this has several drawbacks, one of them being that if the users selects to use Python, it will fail. But there wasn't a better choice. At least I was able to figure out how to limit it to only updating the selected records (have to use ISelectionSet2.Update to get an update cursor).
I just hope that ESRI doesn't just decide to secretly make it go back to the way it was at some point in the future and then the expressions get processed twice...
Public Sub OpenCalculateTool() ' Hook into Toolbox and get the tool Dim pUID As New UID pUID = "esriGeoprocessingUI.ArcToolboxExtension" Dim pArcToolboxExtension As IArcToolboxExtension Set pArcToolboxExtension = Application.FindExtensionByCLSID(pUID) Dim pArcToolbox As IArcToolbox Set pArcToolbox = pArcToolboxExtension.ArcToolbox Dim pGPTool As IGPTool Set pGPTool = pArcToolbox.GetToolbyNameString("CalculateField") ' Create messages, required by Invoke method Dim msgs As IGPMessages Set msgs = New GPMessages ' Get existing parameter structure Dim pArray As IArray Set pArray = pGPTool.ParameterInfo ' Declare Parameter interfaces Dim pGPParameter As IGPParameter Dim pGPDataType As IGPDataType Dim pGPParameterEdit As IGPParameterEdit ' Set the parameters of the tool Set pGPParameter = pArray.Element(0) Set pGPParameterEdit = pGPParameter Set pGPDataType = pGPParameter.DataType Set pGPParameterEdit.Value = pGPDataType.CreateValue("a") ' Featurelayer name Set pGPParameter = pArray.Element(1) Set pGPParameterEdit = pGPParameter Set pGPDataType = pGPParameter.DataType Set pGPParameterEdit.Value = pGPDataType.CreateValue("xx") ' Field Set pGPParameter = pArray.Element(3) Set pGPParameterEdit = pGPParameter Set pGPDataType = pGPParameter.DataType Set pGPParameterEdit.Value = pGPDataType.CreateValue("VB") ' Open the tool Dim pGPToolCommandHelper As IGPToolCommandHelper2 Set pGPToolCommandHelper = New GPToolCommandHelper pGPToolCommandHelper.SetTool pGPTool pGPToolCommandHelper.InvokeModal 0, pArray, True, msgs End Sub
So for anyone interested, I am now using ICalculate to execute the expressions that were provided by the user. Of course this has several drawbacks, one of them being that if the users selects to use Python, it will fail. But there wasn't a better choice. At least I was able to figure out how to limit it to only updating the selected records (have to use ISelectionSet2.Update to get an update cursor).
I just hope that ESRI doesn't just decide to secretly make it go back to the way it was at some point in the future and then the expressions get processed twice...