1

I want to add an existing feature class to an existing feature dataset. Both the feature class and the dataset have the same coordinate system, I searched over the net but only assistance I found was to create a new feature class in a feature dataset (I tried that and it worked). According my understanding I tried using IDatasetContainer but it's not working. Here is the code:

IFeatureDataset featureDataset1 = featureWorkspace.OpenFeatureDataset("featureDataset1");
IDataset datasetFcTenActors = fc_tenActors as IDataset; // fc_tenActors is my feature class to add
IDatasetContainer container = featureDataset1 as IDatasetContainer;
container.AddDataset(datasetFcTenActors);
Hornbydd
44.9k5 gold badges42 silver badges84 bronze badges
asked Jan 30, 2014 at 13:28
5
  • @DevdattaTengshe : thanks but I am able to do the same using arcmaps by simply copying the feature class and pasting into the feature dataset. Also there is already a line feature class present in the feature dataset which I created but not copy. Commented Jan 30, 2014 at 15:55
  • It doesn't change when I drag and drop but changes when I copy paste. I want to code the drag and drop into feature dataset. Commented Jan 30, 2014 at 16:08
  • ok.. Got it. I was misunderstanding your question. Commented Jan 30, 2014 at 16:10
  • What do you mean when you say that the code does not work? Commented Jan 30, 2014 at 16:13
  • @DevdattaTengshe : I tried the above code and gave COM exception "Exception from HRESULT: 0x8004022D" on the line - container.AddDataset(datasetFcTenActors); Commented Jan 30, 2014 at 16:55

2 Answers 2

1

Maybe the IFeatureDataConverter2.ConvertFeatureClass Method does what you need:

http://resources.arcgis.com/en/help/arcobjects-net/componenthelp/index.html#/d/0025000002w5000000.htm

It takes a source Featureclass Name and an Output featuredataset Name as Parameter.

answered Jan 30, 2014 at 15:32
0

The IDatasetContainer interface lets you move datasets between FeatureDatasets and Workspaces—both objects implement the interface. However, It should be used to move datasets between Feature Datasets within a single workspace, but not between workspaces. If you situation doesn't meet this precondition, follow Chris suggestion (IFeatureDataConverter2). Note that when moving feature classes into a feature dataset, the spatial reference of the source feature class must match the spatial reference of the target feature dataset.

answered Feb 10, 2015 at 9:33

Your Answer

Draft saved
Draft discarded

Sign up or log in

Sign up using Google
Sign up using Email and Password

Post as a guest

Required, but never shown

Post as a guest

Required, but never shown

By clicking "Post Your Answer", you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.