I'm currently attempting to export a selected set of data from a feature class in a database to another database as a new feature class. I understand everything perfectly right up to the IExportOperation.ExportFeatureClass
bits. The last argument calls for an IFeatureClassName
object. This appears (to me) to not be a path or a file name, but an object that maintains all of that data. I have been looking at some other questions that discuss or mention the method to export a feature class, but I cannot wrap my head around it properly.
What is an IFeatureClassName
, and how does one create it for a file that does not exist yet (the Geodatabase does exist)?
Answer
If you have an instance to a class that implements IFeatureClass, you have a connected object (well, there are cases when this is not true, but let's just stick with the simple cases). An IFeatureClassName inherits from IName, and thus it is a Name Object. From the documentation of Name Objects:
A Name object is a persistable software object that identifies and locates a geodatabase object such as a dataset or a workspace or a map object such as a layer.
A Name object supports an Open method that allows the client to get an instance of the actual object (for example, the dataset or workspace) given the name object. A name object thus acts as a moniker that supports binding to the named object.
The geodatabase supports methods on workspaces that hand out name objects that can be used by browsing clients to display the names of datasets in the workspace and to instantiate any specific dataset.
Name objects may also carry properties that describe the object being named. A browsing client to display additional information about the object being named can use these properties. A Name object may also support methods to access metadata for or methods to change permissions on the actual object. In these cases, a name object can be used as a lightweight surrogate of the actual object until such time as further properties of the object are needed or additional methods on the object need to be called.
Name objects are cocreatable and can also be used to specify datasets that are yet to be created, for example the output dataset to be created by a geoprocessing operation. There are several kinds of name objects, for example workspace, table, feature class, feature dataset, raster and relationship class name objects. Name objects may be persisted (serialized) using the IPersistStream interface. Name objects are the mechanism used to save references to the datasets corresponding to the layers in a map, when the map is saved as a map document.
In other words, you can think of Name objects as a "prototype" of an object. It is disconnected, and allows you get a handle to a "real" Object or to even define one so that you can create it.
This page of the ArcObjects documentation has an example of how to create an IFeatureClassName
No comments:
Post a Comment