Thursday 20 October 2016

c# - How to control which Fields are exported in ArcObjects? (via Field Mapping)


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#?




No comments:

Post a Comment

arcpy - Changing output name when exporting data driven pages to JPG?

Is there a way to save the output JPG, changing the output file name to the page name, instead of page number? I mean changing the script fo...