Python を使用した高度なフィールド演算を ArcObjects から実行する方法

''' <summary>
''' Pythonを使用した高度なフィールド演算をArcObjectsから実行する方法
''' </summary>
''' <param name="Table"></param>
''' <param name="Field"></param>
''' <param name="Expression"></param>
''' <param name="CodeBlock"></param>
''' <returns></returns>
''' <remarks></remarks>
Private Function CalculateField(ByVal Table As Object, ByVal Field As String, ByExpression As String, ByVal CodeBlock As String) As IGeoProcessorResult2
    ''例
    'Table = "C:\Temp\GDB.gdb\Table"
    'Table = pFeatureClass
    'Field = "TheField"
    'Expression = "calEnvelopeXMax(!Shape!)"
    'CodeBlock = _
    '    "def calEnvelopeXMax(Shape):" & vbNewLine & _
    '    "  return Shape.extent.XMax"

    Dim pGP As IGeoProcessor = New GeoProcessor
    Dim pVariantArray As IVariantArray = New VarArray
    pVariantArray.Add(Table)                            'in_table
    pVariantArray.Add(Field)                            'field
    pVariantArray.Add(Expression)                       'expression
    pVariantArray.Add("PYTHON_9.3")                     'expression_type
    pVariantArray.Add(CodeBlock)                        'code_block

    Dim pGeoprocessorResult As IGeoProcessorResult2 = Nothing
    Try
        pGeoprocessorResult = pGP.Execute("CalculateField_Management", pVariantA, Nothing)
        Return pGeoprocessorResult
    Catch ex As Exception
        Return pGeoprocessorResult
    End Try

End Function