Select to view content in your preferred language

create-feature-from-a-modified-inspector

938
4
04-20-2020 05:18 PM
JimmyBowden
Frequent Contributor

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

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
4 Replies
by Anonymous User
Not applicable

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
Frequent 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
JimmyBowden
Frequent Contributor

I'm now seeing the same behavior using ArcGIS Pro 2.8.3 and connecting to Utility Network branched versioned services from ArcGIS enterprise 10.9.  

0 Kudos