1

Would someone be able to share the logistics on how to permanently programmatically reorder fields in a feature class with ArcObjects, VB.Net.

I want to be able to do this in the geodatabase not in the IOrderedLayerFields Interface of the Carto assembly.

4

Even with ArcObjects, the only way to permanently reorder fields in a table or feature class is to drop the table completely and re-create it. There is a very popular ArcGIS Idea to get this implemented, so vote for it if you want to see such a feature.

2

This is possible in python using FeatureClasstoFeatureClass with Fieldmappings. You can also rename fields at the same time.

So if you have a Featureclass with FIELD3,FIELD2,FIELD1 and you want the result to be FIELD1,F2,F3 then the following code should accomplish this.

arcpy.env.overwriteOutput = True

input_fpath = "c:\\gis\\Geodatabases\\temp.gdb\\in_fc"

output_dpath = "c:\\gis\\Geodatabases\\temp.gdb"
output_fname = "out_fc"

fms = arcpy.FieldMappings()

fm = arcpy.FieldMap()
fm.addInputField(input_fpath,"FIELD1")
fms.addFieldMap(fm)

fm = arcpy.FieldMap()
fm.addInputField(input_fpath,"FIELD2")
of = fm.outputField
of.name = "F2"
of.aliasName = "F2"
fm.outputField = of
fms.addFieldMap(fm)

fm = arcpy.FieldMap()
fm.addInputField(input_fpath,"FIELD3")
of = fm.outputField
of.name = "F3"
of.aliasName = "F3"
fm.outputField = of
fms.addFieldMap(fm)

arcpy.conversion.FeatureClassToFeatureClass(input_fpath,output_dpath,output_fname,"",fms)
1

I cannot help with ArcObjects code but your question seems to be just after the logic.

I recommend basing your logic on the Answer to How to re-order fields permanently using ArcGIS Make Query Table tool?

1

I know this is totally out of the scope of the question, but could be useful for those who want to reorder fields inside a table only once by hand. You can do the trick by importing the classes (or the whole geodatabase) into a personal geodatabase. Then open it with Access and reorder the fields (yeah, cool) and export it back to the original format.

Hope it helps

  • I like this out of the box solution. This worked really well for me. – Fezter Oct 27 '15 at 1:26

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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