create-feature-from-a-modified-inspector

137
3
04-20-2020 05:18 PM
JimmyBowden
Occasional Contributor

https://github.com/Esri/arcgis-pro-sdk/wiki/ProSnippets-Editing#create-feature-from-a-modified-inspector

I copied this code and ran it against a versioned feature class in enterprise sde (Oracle 12.1). It fails with "Edit operation failed." as the edit operation error message.  I'm trying to take the selected feature make a copy and update some attributes is this the best way? Should I try some other method?

 ArcGIS.Desktop.Framework.Threading.Tasks.QueuedTask.Run(() =>
{
var insp = new ArcGIS.Desktop.Editing.Attributes.Inspector();
var layer = ArcGIS.Desktop.Mapping.MapView.Active.Map.FindLayers("WATERLINE").FirstOrDefault() as BasicFeatureLayer;
insp.Load(layer, 364323);
// modify attributes if necessary
// insp["Field1"] = newValue;
insp["STATUS"] = 9;
//Create new feature from an existing inspector (copying the feature)
var createOp = new ArcGIS.Desktop.Editing.EditOperation();
createOp.Name = "Create from insp";
createOp.Create(insp.MapMember, insp.ToDictionary(a => a.FieldName, a => a.CurrentValue));
createOp.Execute();
});
0 Kudos
3 Replies
SeanJones
Esri Regular Contributor

Jimmy,

The other syntax to try is the create method with a mapmember and inspector:

EditOperation.Create(ArcGIS.Desktop.Mapping.MapMember, ArcGIS.Desktop.Editing.Attributes.Inspector, System.Action<long>)

Can you create a feature in the layer through the UI with that status value? Just checking if there's a constraint.

0 Kudos
Wolf
by Esri Regular Contributor
Esri Regular Contributor

I tried your snippet on a SQLServer data and it worked as expected.  You can try to look at the error by adding this:

createOp.Create(insp.MapMember, insp.ToDictionary(a => a.FieldName, a => a.CurrentValue));
var createResult = createOp.Execute();
if (createResult != true || createOp.IsSucceeded != true)
MessageBox.Show ($@"Create failed: {createOp.ErrorMessage}");‍‍‍‍
0 Kudos
JimmyBowden
Occasional Contributor

Thanks for the prompt responses.  I spend more time today trying to find out what’s happening.

  • I can create features in the UI with no issues
  • I copied some features to a file gdb and the code works.  
  • I have been able to use the EditOperation.Duplicate and EditOperation.Update successfully on the same the enterprise sde feature class
  • The error message reported is “Edit Operation failed”

It’s just when I use EditOperation.Create against enterprise sde classic versioning that it fails.  There are attribute rules I will disable them and try this tomorrow.    Any other suggestions would be helpful?

0 Kudos