<?xml version="1.0" encoding="UTF-8"?>
<rss xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" xmlns:taxo="http://purl.org/rss/1.0/modules/taxonomy/" version="2.0">
  <channel>
    <title>topic Re: General error executing calculator in ArcObjects SDK Questions</title>
    <link>https://community.esri.com/t5/arcobjects-sdk-questions/general-error-executing-calculator/m-p/298488#M7755</link>
    <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;SPAN&gt;This is not VBA this is from a VB.Net application I put together in 9.3.1.&amp;nbsp; I am trying to upgrade to 10.&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;Again thanks for your help,&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;James&lt;/SPAN&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
    <pubDate>Wed, 03 Nov 2010 11:07:43 GMT</pubDate>
    <dc:creator>JamesWhisenhunt</dc:creator>
    <dc:date>2010-11-03T11:07:43Z</dc:date>
    <item>
      <title>General error executing calculator</title>
      <link>https://community.esri.com/t5/arcobjects-sdk-questions/general-error-executing-calculator/m-p/298486#M7753</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;SPAN&gt;Hello all,&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;I am trying to update the area field on a shapefile; however, I am getting the following error:&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;"Error HRESULT_FAIL has returned from a call to a COM component"&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;This was originally written in 9.3.1 and worked without problems.&amp;nbsp; Any ideas why I am having problems in ArcMap 10?&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;As always thanks for all help,&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;James&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;Private Sub UpdateArea(ByVal pFlayer As IFeatureLayer)&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;[INDENT]&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;Try&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;[INDENT]Dim pfClass As IFeatureClass&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;pfClass = pFlayer.FeatureClass&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;Dim pCalc As ICalculator&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;pCalc = New Calculator&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;Dim pCursor As ICursor&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;pCursor = pfClass.Update(Nothing, True)&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;With pCalc&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;[INDENT].Cursor = pCursor&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;.PreExpression = "Dim dblArea as double" &amp;amp; vbNewLine &amp;amp; _&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;[INDENT][INDENT][INDENT]"Dim pArea As IArea" &amp;amp; vbNewLine &amp;amp; _&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;"Set pArea = [Shape]" &amp;amp; vbNewLine &amp;amp; _&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;"dblArea = pArea.Area"[/INDENT][/INDENT][/INDENT]&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;.Expression = "dblArea"&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;.Field = "Area"[/INDENT]&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;End With&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;pCalc.Calculate()&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;pCursor = Nothing&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;[/INDENT]&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;Catch ex As Exception&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;[INDENT]MsgBox(ex.Message.ToString)[/INDENT]&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;End Try&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;[/INDENT]&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; End Sub&lt;/SPAN&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Wed, 03 Nov 2010 00:19:03 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcobjects-sdk-questions/general-error-executing-calculator/m-p/298486#M7753</guid>
      <dc:creator>JamesWhisenhunt</dc:creator>
      <dc:date>2010-11-03T00:19:03Z</dc:date>
    </item>
    <item>
      <title>Re: General error executing calculator</title>
      <link>https://community.esri.com/t5/arcobjects-sdk-questions/general-error-executing-calculator/m-p/298487#M7754</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;SPAN&gt;ArcGIS 10 does not support VBA.&amp;nbsp; It supports VB Script, which cannot be used to do geometry based calculations.&amp;nbsp; Your only option with the field calculator is to rewrite the calculation in Python.&amp;nbsp; I am not that good with Python, so I will leave it to others to help you.&lt;/SPAN&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Wed, 03 Nov 2010 01:21:42 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcobjects-sdk-questions/general-error-executing-calculator/m-p/298487#M7754</guid>
      <dc:creator>RichardFairhurst</dc:creator>
      <dc:date>2010-11-03T01:21:42Z</dc:date>
    </item>
    <item>
      <title>Re: General error executing calculator</title>
      <link>https://community.esri.com/t5/arcobjects-sdk-questions/general-error-executing-calculator/m-p/298488#M7755</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;SPAN&gt;This is not VBA this is from a VB.Net application I put together in 9.3.1.&amp;nbsp; I am trying to upgrade to 10.&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;Again thanks for your help,&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;James&lt;/SPAN&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Wed, 03 Nov 2010 11:07:43 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcobjects-sdk-questions/general-error-executing-calculator/m-p/298488#M7755</guid>
      <dc:creator>JamesWhisenhunt</dc:creator>
      <dc:date>2010-11-03T11:07:43Z</dc:date>
    </item>
    <item>
      <title>Re: General error executing calculator</title>
      <link>https://community.esri.com/t5/arcobjects-sdk-questions/general-error-executing-calculator/m-p/298489#M7756</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;SPAN&gt;The PreExpression is VBA.&amp;nbsp; So even if this is vb.net, you are asking the calculator to do VBA.&amp;nbsp; Same as if you put the expression in the calculate in the table view.&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;If it was me I would ditch the calculator and just loop through your update cursor, get the area by casting the feature shape to IArea and set the area field manually.&amp;nbsp; That way I don't have to mix and match programming languages.&amp;nbsp; Depending on the number of rows, performance might be a consideration though.&lt;/SPAN&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Wed, 03 Nov 2010 20:45:48 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcobjects-sdk-questions/general-error-executing-calculator/m-p/298489#M7756</guid>
      <dc:creator>AlexanderGray</dc:creator>
      <dc:date>2010-11-03T20:45:48Z</dc:date>
    </item>
    <item>
      <title>Re: General error executing calculator</title>
      <link>https://community.esri.com/t5/arcobjects-sdk-questions/general-error-executing-calculator/m-p/298490#M7757</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;SPAN&gt;Thank you,&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;I did originally write this in VBA to test.&amp;nbsp; I then moved it to VB.Net.&amp;nbsp; The reason I am trying to use the calculator is I have about 40,000 polygons I have to loop through.&amp;nbsp; I have several calculations and I thought performance would be a problem.&amp;nbsp; I could probably do them in one pass.&amp;nbsp; I will try a loop to see how fast it is.&amp;nbsp; &lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;Again thank you for the help.&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;James&lt;/SPAN&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Thu, 04 Nov 2010 01:09:33 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcobjects-sdk-questions/general-error-executing-calculator/m-p/298490#M7757</guid>
      <dc:creator>JamesWhisenhunt</dc:creator>
      <dc:date>2010-11-04T01:09:33Z</dc:date>
    </item>
    <item>
      <title>error using Calculator with Python within ArcObjects</title>
      <link>https://community.esri.com/t5/arcobjects-sdk-questions/general-error-executing-calculator/m-p/298491#M7758</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;SPAN&gt;Hello all,&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;can somebody please help me get going with Python Expressions/PreExpressions in the ICalculator from &lt;/SPAN&gt;&lt;STRONG&gt;within&lt;/STRONG&gt;&lt;SPAN&gt; my .net-code. I can successfully run Python and VBScript from the Calculator in the Desktop User Interface. I can also successfully run the simple&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;VBScript Expression &lt;/SPAN&gt;&lt;PRE class="lia-code-sample line-numbers language-none"&gt;Dim pCalc As GeoDatabaseUI.ICalculator = New GeoDatabaseUI.Calculator()
pCalc.Expression = "[FID] * 2"&lt;/PRE&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;from within my code using the Calculator. However, if I try the&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;Python-Expression &lt;/SPAN&gt;&lt;PRE class="lia-code-sample line-numbers language-none"&gt;Dim pCalc As GeoDatabaseUI.ICalculator = New GeoDatabaseUI.Calculator()
pCalc.Expression = "!FID! * 2"&lt;/PRE&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;I get the "General error executing calculator" and an Exception "Error HRESULT E_FAIL has been returned from a call to a COM component". However, as I said, this Python-Expression runs fine in the Calculator User Interface.&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;My suspicion is that maybe the parser doesn't notice that it is receiving a Python-Expression. Do I have to - and if yes, where - programmatically switch the parser of the ICalculator to Python? What am I missing?&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;Florian.&lt;/SPAN&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Sat, 11 Dec 2021 14:20:01 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcobjects-sdk-questions/general-error-executing-calculator/m-p/298491#M7758</guid>
      <dc:creator>F_Pfaefflin</dc:creator>
      <dc:date>2021-12-11T14:20:01Z</dc:date>
    </item>
    <item>
      <title>Re: General error executing calculator</title>
      <link>https://community.esri.com/t5/arcobjects-sdk-questions/general-error-executing-calculator/m-p/298492#M7759</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;SPAN&gt;I agree with Florian, if you look at the&lt;/SPAN&gt;&lt;A href="http://resources.arcgis.com/en/help/arcobjects-net/componenthelp/index.html#/ICalculator_Interface/00290000000v000000/"&gt; ICalculator interface&lt;/A&gt;&lt;SPAN&gt; it does not say that the expression should be Python or even VB, so what is it ESRI?&lt;/SPAN&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Wed, 15 Aug 2012 11:02:09 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcobjects-sdk-questions/general-error-executing-calculator/m-p/298492#M7759</guid>
      <dc:creator>DuncanHornby</dc:creator>
      <dc:date>2012-08-15T11:02:09Z</dc:date>
    </item>
    <item>
      <title>Re: General error executing calculator</title>
      <link>https://community.esri.com/t5/arcobjects-sdk-questions/general-error-executing-calculator/m-p/298493#M7760</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;SPAN&gt;There is a bug (NIM061356) on using Python with ICalculator: 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.&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;Their suggested workaround is as follows:&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;BLOCKQUOTE class="jive-quote"&gt;&lt;BR /&gt;Below is a workaround that compensates for the lack of being able to specify the parser in ICalculator.&amp;nbsp; It takes advantage of IGeoProcessor and the CalculateField_management geoprocessing tool.&amp;nbsp; The parser or expression_type argument of that tool can be used to specify Python as the parser.&lt;BR /&gt;&lt;BR /&gt;'(To test the below VBA code, create a UIButton in VBA and add the code inside the Click event handler of your new UIButton.&amp;nbsp; 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.&amp;nbsp; Change the first parameter as needed to reflect the correct location of your input table.)&lt;BR /&gt;&lt;BR /&gt;&lt;PRE class="lia-code-sample line-numbers language-none"&gt;
Private Sub UIButtonControl1_Click()

&amp;nbsp; 'Create the Geoprocessor
&amp;nbsp; Dim pGp As IGeoProcessor
&amp;nbsp; Set pGp = New GeoProcessor

&amp;nbsp; 'Set Overwriteoutput to True
&amp;nbsp; pGp.OverwriteOutput = True

&amp;nbsp; 'Add the custom toolbox containing the model tool
&amp;nbsp; 'pGp.AddToolbox "C:\CustomTools\custom.tbx"

&amp;nbsp; 'Create the Parameter array
&amp;nbsp; Dim pParamArray As IVariantArray
&amp;nbsp; Set pParamArray = New VarArray

'Populate array of parameters

&amp;nbsp; 'First Parameter:&amp;nbsp; in_table (e.g. File GDB feature class)
&amp;nbsp; pParamArray.Add "C:\Incidents\845875\Converted_GDB931\downgradedFGDB.gdb\Main_931"

&amp;nbsp; 'Second Parameter:&amp;nbsp; field on which to calculate
&amp;nbsp; pParamArray.Add "LastField"

&amp;nbsp; 'Third Parameter:&amp;nbsp; expression
&amp;nbsp; pParamArray.Add "math.log1p(!SumOfConcentrations!)"

&amp;nbsp; 'Fourth Parameter:&amp;nbsp; expression_type (Optional)&amp;nbsp; !!!&amp;nbsp; !!!&amp;nbsp; !!!&amp;nbsp; !!!&amp;nbsp; !!!
&amp;nbsp; pParamArray.Add "PYTHON_9.3"

&amp;nbsp; Dim pResult As IGeoProcessorResult

&amp;nbsp; 'Execute the Model tool
&amp;nbsp; Set pResult = pGp.Execute("CalculateField_management", pParamArray, Nothing)

&amp;nbsp; 'Get the returned tool messages
&amp;nbsp; ReturnMessages pResult

End Sub

Public Sub ReturnMessages(ByVal messages As IGeoProcessorResult)
&amp;nbsp; Dim i As Long
&amp;nbsp; Dim message As String

&amp;nbsp; For i = 0 To messages.MessageCount - 1
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; message = messages.GetMessage(i)
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; Debug.Print message
&amp;nbsp; Next

End Sub
&lt;/PRE&gt;&lt;BR /&gt;&lt;/BLOCKQUOTE&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Sat, 11 Dec 2021 14:20:04 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcobjects-sdk-questions/general-error-executing-calculator/m-p/298493#M7760</guid>
      <dc:creator>KenBuja</dc:creator>
      <dc:date>2021-12-11T14:20:04Z</dc:date>
    </item>
    <item>
      <title>Re: General error executing calculator</title>
      <link>https://community.esri.com/t5/arcobjects-sdk-questions/general-error-executing-calculator/m-p/298494#M7761</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;SPAN&gt;Thank you for this information!&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;With the bug number &lt;/SPAN&gt;&lt;A href="http://support.esri.com/en/bugs/nimbus/TklNMDYxMzU2"&gt;NIM061356&lt;/A&gt;&lt;SPAN&gt; I also found the other thread covering the issue &lt;/SPAN&gt;&lt;A href="http://forums.arcgis.com/threads/11589-Use-Python-expression-in-field-calculator"&gt;11589-Use-Python-expression-in-field-calculator&lt;/A&gt;&lt;SPAN&gt; I can only agree that (as it is not getting fixed due to low priority) it would be very nice of ESRI to put some information on this bug at least in the online help.&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;Florian.&lt;/SPAN&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Thu, 16 Aug 2012 06:15:43 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcobjects-sdk-questions/general-error-executing-calculator/m-p/298494#M7761</guid>
      <dc:creator>F_Pfaefflin</dc:creator>
      <dc:date>2012-08-16T06:15:43Z</dc:date>
    </item>
    <item>
      <title>Re: General error executing calculator</title>
      <link>https://community.esri.com/t5/arcobjects-sdk-questions/general-error-executing-calculator/m-p/298495#M7762</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;SPAN&gt;If you have support with Esri, I would suggest calling them and adding your name onto the bug. If more people let them know this is a problem, they may give it a higher priority.&lt;/SPAN&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Thu, 16 Aug 2012 12:51:30 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcobjects-sdk-questions/general-error-executing-calculator/m-p/298495#M7762</guid>
      <dc:creator>KenBuja</dc:creator>
      <dc:date>2012-08-16T12:51:30Z</dc:date>
    </item>
    <item>
      <title>Re: General error executing calculator</title>
      <link>https://community.esri.com/t5/arcobjects-sdk-questions/general-error-executing-calculator/m-p/298496#M7763</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;SPAN&gt;Through (re-)reporting the Bug to my local support, the severity of &lt;/SPAN&gt;&lt;A href="http://support.esri.com/en/bugs/nimbus/TklNMDYxMzU2"&gt;NIM-061356&lt;/A&gt;&lt;SPAN&gt; at least moved to "High". One problem seems to have been that the bug report implies that the issue affects only VBA (which is deprecated). But in fact it affects all ArcObjects .NET developments.&amp;nbsp; Let's hope for a quick fix ...&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;Florian.&lt;/SPAN&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Fri, 24 Aug 2012 06:28:45 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcobjects-sdk-questions/general-error-executing-calculator/m-p/298496#M7763</guid>
      <dc:creator>F_Pfaefflin</dc:creator>
      <dc:date>2012-08-24T06:28:45Z</dc:date>
    </item>
  </channel>
</rss>

