ICalculator or ICalculatorUI2 do not offer a property where the parser (expression type) can be specified; VBScript is the default, so Python expressions error out.
上次发布: August 31, 2014ArcGIS for Desktop
漏洞 ID 编号
NIM061356
已提交
September 21, 2010
上次修改时间
June 5, 2024
适用范围
ArcGIS for Desktop
找到的版本
10.0
编程语言
VBA
操作系统
Windows OS
操作系统版本
7 64 Bit
状态
Will Not Be Addressed
开发团队已考虑过该问题或请求,并决定不会解决该问题。 问题的“其他信息”部分可能包含进一步说明。
附加信息
We apologize that we were unable to address this issue within the current product support cycle. If the issue continues to affect your work in a supported release, please contact Technical Support.
解决办法
Below is a workaround that compensates for the lack of being able to specify the parser in ICalculator. It takes advantage of IGeoProcessor and the CalculateField_management geoprocessing tool. The parser or expression_type argument of that tool can be used to specify Python as the parser.'(To test the below VBA code, create a UIButton in VBA and add the code inside the Click event handler of your new UIButton. The second procedure, ReturnMessages(), is called into action by the first procedure towards the very end, but may not be necessary if you do not want to read the messages of the geoprocessing results. Change the first parameter as needed to reflect the correct location of your input table.)Private Sub UIButtonControl1_Click() 'Create the Geoprocessor Dim pGp As IGeoProcessor Set pGp = New GeoProcessor 'Set Overwriteoutput to True pGp.OverwriteOutput = True 'Add the custom toolbox containing the model tool 'pGp.AddToolbox "C:\CustomTools\custom.tbx" 'Create the Parameter array Dim pParamArray As IVariantArray Set pParamArray = New VarArray 'Populate array of parameters 'First Parameter: in_table (e.g. File GDB feature class) pParamArray.Add "C:\Incidents\845875\Converted_GDB931\downgradedFGDB.gdb\Main_931" 'Second Parameter: field on which to calculate pParamArray.Add "LastField" 'Third Parameter: expression pParamArray.Add "math.log1p(!SumOfConcentrations!)" 'Fourth Parameter: expression_type (Optional) !!! !!! !!! !!! !!! pParamArray.Add "PYTHON_9.3" Dim pResult As IGeoProcessorResult 'Execute the Model tool Set pResult = pGp.Execute("CalculateField_management", pParamArray, Nothing) 'Get the returned tool messages ReturnMessages pResultEnd SubPublic Sub ReturnMessages(ByVal messages As IGeoProcessorResult) Dim i As Long Dim message As String For i = 0 To messages.MessageCount - 1 message = messages.GetMessage(i) Debug.Print message NextEnd Sub