0
gp.Execute(new MakeTableView()
                    {
                        in_table = $@"Database Connections\[email protected]\TESTGIS.SOME_POLY",
                        out_view = "SOME_POLY",
                        where_clause = "STATUS = 'INCLUDED'",
                        workspace = defaultSDEWorkspace
                    }, null);

Please consider the code above. I can run it perfectly and get my results in a temp view. However, there is another option - field_info which require an object type and I have tried to fit different types of instance into this parameter but it still fail...

The type I have tried: ESRI.ArcGIS.Carto.FieldInfoSetClass, ESRI.ArcGIS.Carto.FieldInfoClass

I don't see any standard doc about this method and option... Anyone can save me out? Provided a sample code snippet that I have attempted

                    var fieldInfoSet = new FieldInfoSetClass();
                    fieldInfoSet.Add("Drawing_number", new FieldInfoClass()
                    {
                        Alias = "DN",
                        Visible = true,
                        ValueAsRatio = false
                    });

                    var tableView = gp.Execute(new MakeTableView()
                    {
                        in_table = $@"Database Connections\[email protected]\TIS2GIS.XANTHUS_DATASET\TIS2GIS.XANTHUS_POLY",
                        out_view = "XATNHUS_POLY2",
                        where_clause = "Drawing_number = 'INCLUDED'",
                        workspace = defaultSDEWorkspace,
                        field_info = fieldInfoSet
                    }, null);

Also, I cannot get any useful information from exception message/error code.

  • H_RESULT: -2147467259
  • Message: Error HRESULT E_FAIL has been returned from a call to a COM component.

1 Answer 1

1

I agree this is not well documented. I tried the FieldInfoSet, ValueTable but eventually hit upon the GPFieldInfo object.

I worked out it was that by looking at the python snippet you get from running the Make Table View geoprocessing tool in ArcMap

If had returned:

arcpy.MakeTableView_management(in_table="C:/Scratch/mst.shp", out_view="myNewTable", where_clause='"FID" > 10', workspace="", field_info="FID FID VISIBLE NONE;Shape Shape VISIBLE NONE;EA_CODE_20 EA_CODE_20 VISIBLE NONE;SpanLength SpanLength VISIBLE NONE")

The semi-colon spaced out list set off alarm bells and eventually the only ArcObject class that would accept those values I saw was the IGPFieldInfo interface.

Here is some VBA code to show you it working.

Public Sub CreateTable()
    Dim pgp As IGeoProcessor
    Set pgp = New GeoProcessor
    pgp.AddOutputsToMap = True
    
    Dim pgpFI As IGPFieldInfo
    Set pgpFI = New GPFieldInfo
    With pgpFI
        .AddField 1, "FID", "FID", True, esriGPFieldInfoSplitRuleNone
        .AddField 1, "SHAPE", "shape", True, esriGPFieldInfoSplitRuleNone
        .AddField 1, "EA_CODE_20", "EA_CODE_20", False, esriGPFieldInfoSplitRuleNone
        .AddField 1, "SpanLength", "zippy", True, esriGPFieldInfoSplitRuleNone
    End With
    
    Dim pVA As IVariantArray
    Set pVA = New VarArray
    With pVA
        .Add "C:\Scratch\mst.shp"
        .Add "myNewTable2"
        .Add """" + "FID" + """" + " > 10"
        .Add ""
        .Add pgpFI
    End With
    Dim pGR As IGeoProcessorResult
    Set pGR = pgp.Execute("MakeTableView_management", pVA, Nothing)
    
End Sub

WARNING:

1] The Index value seems to be ignored, I have just put ones in but even if you put 0 to 3 or 1 to 4, same result...

2] I deliberately set the new name to be "zippy" but this is ignored, seems to be a bug?

1
  • 1
    Instant LIKE AND ACCEPT. THANK YOU
    – mannok
    Commented Jun 26, 2020 at 16:17

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.