Select to view content in your preferred language

Field Mapping for Geoprocessor Tools in .NET

867
2
02-02-2011 07:12 AM
MeleKoneya
Frequent Contributor
I would like to be able to duplicate the Field Mapping that is generated when using the "NO_TEST" option in the schema type parameter for the Append Tool in ArcCatalog in .NET

I am using ESRI.ArcGIS.DataManagementTools.Append and would like to be able create the same type of field mapping that is used by the GUI so that the code makes it "best guess" at field mapping if the fields are in a different order within the input and output Feature Classes.

I see that there is a IGPFieldMapping Interface, but have not seen examples that are of use to my case.   

Let me know if you have done anything like this in .NET

Thanks,

Mele
0 Kudos
2 Replies
MeleKoneya
Frequent Contributor
Here is what I ended up doing.

private static IGPFieldMapping MapFields(string strinFC, string stroutFC)
        {
            IGPUtilities gputilities = new GPUtilitiesClass();
            IDETable inTableA = (IDETable)gputilities.MakeDataElement(strinFC, null, null);
            IDETable inTableB = (IDETable)gputilities.MakeDataElement(stroutFC, null, null);

            IArray inTables = new ArrayClass();
            inTables.Add(inTableA);
            inTables.Add(inTableB);

            IGPFieldMapping fieldmapping = new GPFieldMappingClass();
            fieldmapping.Initialize(inTables, null);

            IFields fields = fieldmapping.Fields;
            return fieldmapping;


        }

Here is another example from ESRI

Geoprocessing field mapping:
http://help.arcgis.com/en/sdk/10.0/arcobjects_net/conceptualhelp/index.html#/d/00010000042p000000.ht...
0 Kudos
NobbirAhmed
Esri Alum
If you want the default fieldmap (as you'd get in tool dialog) then just pass an empty string for fieldmap parameter. Let me know if that works.
0 Kudos