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#?
-
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– Kirk Kuykendall2011年11月11日 20:11:27 +00:00Commented Nov 11, 2011 at 20:11
-
No, I haven't. Worth a shot, but for now, that method is no longer my preferred one.Nathanus– Nathanus2011年11月11日 21:13:53 +00:00Commented Nov 11, 2011 at 21:13
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.
-
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– Nathanus2011年11月08日 23:18:37 +00:00Commented Nov 8, 2011 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– Nathanus2011年11月09日 19:44:44 +00:00Commented Nov 9, 2011 at 19:44
-
All right, it seems that I can get
IFieldInfo
fromITableFields
, 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– Nathanus2011年11月09日 21:58:53 +00:00Commented Nov 9, 2011 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– blah2382011年11月09日 23:10:15 +00:00Commented Nov 9, 2011 at 23:10
-
Hm, I suppose a Merge Field Map will do the trick.Nathanus– Nathanus2011年11月09日 23:41:43 +00:00Commented Nov 9, 2011 at 23:41