Append_management Tool FieldMapping Problem C#

987
1
03-21-2012 05:32 PM
JohnNelson3
New Contributor III
I have two File GeoDatabases with the identical structures and I am trying to get the Append_management tool to populate the fields when using the ???No_Test??? parameter. It works when I use the ???Test??? parameter. The ???No_Test??? parameter adds the features but none of the attributes. So am thinking that I need to map the fields. How do you map the matching fields for input into the Append_management tool?


//strings ->  input, output (complete path to the geodatabase featureclass in different geodatabase)
//The featureclass have identical structures
                           
IGeoProcessor gp = new GeoProcessor();
IVariantArray parameters = new VarArrayClass();
IFeatureClass iFC;
IFeatureWorkspace iFWS;
FeatureClassUtils iFCU = new FeatureClassUtils();

iFWS = (IFeatureWorkspace)iFCU.FileGdbWorkspaceFromPath(txtGeodatabase.Text);
iFC = iFWS.OpenFeatureClass(chkFeatureclasses.Items.ToString());


//From ESRi SAMPLE
IGPUtilities gputilities = new GPUtilitiesClass();
IGPFieldMapping fieldmapping = new GPFieldMappingClass();
IDETable outTableA = (IDETable) gputilities.MakeDataElement(input,null,null);
IDETable inputTableA = (IDETable)gputilities.MakeDataElement(output, null, null);
IArray inputtables = new ArrayClass();
inputtables.Add(outTableA);
//inputtables.Add(inputTableA);
fieldmapping.Initialize(inputtables, null);
//End Sample Code

                                                
parameters.Add(iFC);
parameters.Add(output);
parameters.Add("NO_TEST");
//parameters.Add("TEST"); //worked populates values
parameters.Add(fieldmapping); // also tried parameters.Add("fieldmapping")
//parameters.Add(""); appends feature but doesn't populate fields (All fields have same structure)
parameters.Add("");
gp.Execute("Append_management", parameters, null);
parameters.RemoveAll();
0 Kudos
1 Reply
GregRieck
Occasional Contributor III

I realize this is old but I found this link first with no further information.

I found this link with a C# example.

Geoprocessing field mapping 

0 Kudos