Take the 2-minute tour ×
Geographic Information Systems Stack Exchange is a question and answer site for cartographers, geographers and GIS professionals. It's 100% free, no registration required.

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.

share|improve this question
1  
I think it's the same as with geoprocessing, you need to drop and re-create the table/feature class completely. Is that acceptable? –  blah238 Jan 25 '13 at 19:51
    
I was hoping for a more "elegant" solution. –  Jakub Jan 25 '13 at 19:58
    
I don't think there is one, but people have certainly asked for this before: ideas.arcgis.com/ideaView?id=0873000000087wg –  blah238 Jan 25 '13 at 20:41
1  
    
They gave us "rename field" in 10.1 but not reordering. Maybe in 10.2 and $12,000 in maintenance fees later. I can manage the "drop and re-create" solution. I guess we can close this post. –  Jakub Jan 25 '13 at 21:27

3 Answers 3

up vote 1 down vote accepted

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.

share|improve this answer

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?

share|improve this answer

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)
share|improve this answer

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

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