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.

In ArcMap 10.x, if you use the Export Data command on a layer that has hidden/disabled fields, those fields will not be present in the created feature class/table. My question is simple: how do you duplicate this functionality using ArcObjects and C#? The IField interface seems to have no property or method for defining this aspect of table data. Can it be done?

I am seeking to do this so I can extract a subset of fields from a table and keep it for later use (as opposed to having to deal with all the unnecessary data bloat present in many standardized data releases).

UPDATE: I am currently attempting to use the IFieldInfo option suggested in the comments below, but I find myself unable to perform the conversion from an IFeatureClass to an IFeatureLayer that seems necessary to access ITableFields. Am I missing something? I am doing this in a WinForms app, so there is no parent ArcMap instance open to obtain layer information from. I wish to only work with feature classes and tables, if possible.

UPDATE 2: It would seem that, because this winforms is detached from any instance of ArcMap, I cannot make use of IFeatureLayer to turn fields on and off before exporting. Does anyone know how to properly create a field map object in C#?

share|improve this question
    
Regarding update 2, did you try creating a featurelayer, assigning the featureclass to IFeaturelayer.Featureclass, then set the visibility via ITableFields, then do the export ? –  Kirk Kuykendall Nov 11 '11 at 20:11
    
No, I haven't. Worth a shot, but for now, that method is no longer my preferred one. –  Nathanus Nov 11 '11 at 21:13
add comment

1 Answer 1

I've not written this all the way out but think I see a path. You can check the IFieldInfo2.Visible. Once you have determined what fields are visible then you could do the export. For example you could create a QueryFilter and set its SubFields property and then use IExportOperation passing in the QueryFilter.

share|improve this answer
    
IFieldInfo2.... Genius! I will try that now. It will take me about 30 years (or maybe a few hours) to implement this so I will get back to you tomorrow. –  Nathanus Nov 8 '11 at 23:18
    
Ho hum, how would you get to the IFieldInfo2 interface when starting with a feature class? It seems to want an ITable. –  Nathanus Nov 9 '11 at 19:44
    
All right, it seems that I can get IFieldInfo from ITableFields, but the latter interface only cooperates with feature layers, not feature classes. I know how to go from class to layer, but can you go backwards? –  Nathanus Nov 9 '11 at 21:58
    
"Hidden" fields are a concept that applies only to feature layers and table views, not feature classes or standalone tables. I think you will need to revisit how you are determining which fields to keep since you aren't using layers. –  blah238 Nov 9 '11 at 23:10
    
Hm, I suppose a Merge Field Map will do the trick. –  Nathanus Nov 9 '11 at 23:41
add comment

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.