Add Features to FC without it being a Feature Layer in the Map

2600
4
08-21-2015 04:56 AM
Highlighted
Occasional Contributor

Hi,

I want to be able to add features to a Feature Class but not have to add that Feature Class to the map. Currently the snippets I see require that.

Any advice on how to do it?

Thanks,

Adam

0 Kudos
4 Replies
Highlighted
Esri Contributor

Adam,

here is the code to do it. The caveat here is that this approach is not recommended for versioned data.

QueuedTask.Run(() =>
    {
        string gdbPath = CoreModule.CurrentProject.DefaultGeodatabasePath;
        Geodatabase gdb = new Geodatabase(gdbPath);

        var featureClass = gdb.OpenDataset<FeatureClass>("Sample");

        var featureBuffer = featureClass.CreateRowBuffer();

        var newFeature = featureClass.CreateRow(featureBuffer) as Feature;
        newFeature.SetShape(pointGeometry);

        newFeature.Store();
    });

0 Kudos
Highlighted
Occasional Contributor

Hi Thomas,

Thanks for that. We did try something like that but we got some Not on this thread errors.

That's probably us as we added it to an existing synchronous codebase. What we'll do in future is have a test project that does simple things in the async world. Once that is working so we know what we are doing is Ok; we can then try and get it to run synched.

Thanks

Adam

0 Kudos
Highlighted
New Contributor II

Hi Adam,

We do have snippets for creating a feature from given an sde file path. You can find it here https://github.com/ArcGIS/arcgis-pro-sdk/wiki/ProSnippets-Geodatabase#creating-a-feature.

It is recommended that edits have to be performed within the EditOperation. This allows for editing versioned/non-versioned data with undo/redo/discard/abort capabilities wherever required. Please see https://github.com/ArcGIS/arcgis-pro-sdk/wiki/ProConcepts-Editing#performing-edits  for more details.

Thanks,

Sree

0 Kudos
Highlighted
Occasional Contributor

Hi Sree,

Thanks. Your links did not work but they did give me the clue to find them myself.

It would be nice if the snippets were more prominent on the web site.

https://github.com/Esri/arcgis-pro-sdk/wiki/ProSnippets-Geodatabase

Thanks

Adam

0 Kudos