Select to view content in your preferred language

Create a feature in a layer with subtypes

172
2
Jump to solution
a month ago
ModyBuchbinder
Esri Regular Contributor

Hello all

I need t create a feature in a featureclass that has subtypes in Enterprise geodatabase with some other attributes.

Some of the attributes will be taken from the subtype default values and other will be taken from a value list.

As far as I understand, the way to create a feature with default subtype values is to use edit template (it looks like define subtype create edit template for each subtype automatically).

The only way I found to use it is to do editOperation.create(EditTemplate).

I have an option to add the geometry to the create method but no other attributes (if I am using template).

I need something like editOperation.Create(editTemplate, geometry, attribute dictionary)

The only way I found is to take the new record and use Inspector to update values.

Am I missing something?

 

0 Kudos
1 Solution

Accepted Solutions
NarelleChedzey
Esri Contributor

Hi Mody, 

Use the Inspector from the Template object to provide temporary override values for field values prior to calling the EditOperation.Create method. 

Here is an example

// perform the creation
var op = new EditOperation();
op.Name = "Create feature";
// use template default field values
op.Create(template, geometry);

// to modify default template properties
var insp = template.Inspector;
insp["City"] = "Perth";

// create with the modified fields and a different geometry
op.Create(template, geometry2);

// reset the template fields back to original defaults
insp.Cancel();

// execute the operation
bool result = op.Execute();

View solution in original post

0 Kudos
2 Replies
NarelleChedzey
Esri Contributor

Hi Mody, 

Use the Inspector from the Template object to provide temporary override values for field values prior to calling the EditOperation.Create method. 

Here is an example

// perform the creation
var op = new EditOperation();
op.Name = "Create feature";
// use template default field values
op.Create(template, geometry);

// to modify default template properties
var insp = template.Inspector;
insp["City"] = "Perth";

// create with the modified fields and a different geometry
op.Create(template, geometry2);

// reset the template fields back to original defaults
insp.Cancel();

// execute the operation
bool result = op.Execute();
0 Kudos
ModyBuchbinder
Esri Regular Contributor

Hi Narelle

The solution works, I was not aware of the Inspector property of the editing template.

The only detail that you forgot is that you must ActivateDefaultToolAsync on the editing template or else the Inspector of the edit template is null.

Found it here: https://community.esri.com/t5/arcgis-pro-sdk-questions/inspector-for-editing-template-returns-null/t... 

I think there should be a few words about this on the Inspector property docs.

Many thanks

0 Kudos