Select to view content in your preferred language

Adding multiple layers within single operation

269
8
02-11-2025 12:13 AM
UlrichEgger
Occasional Contributor

Dear developers,

using the ArcGIS Pro SDK, we have developped a tool that loads simulation results (stored in 2 Feature Classes) to the map, adding a whole tree of layers.

For explanation: We have one feature class with water levels and one feature class containing velocities. For each output timestep of the simulation, we have one column containing the values. In addition, there is one column for maximum values. The tool adds a new GroupLayer to the map. Then, FeatureLayers for max. waterlevel and velocity are added. For each output timestep a GroupLayer is added into the above GroupLayer. Then into this new GroupLayer, FeatureLayers with waterlevel and velocity of the current timestep are added.

We use LayerFactory.Instance.CreateLayer<GroupLayer> and LayerFactory.Instance.CreateLayer<FeatureLayer>

Using these methods, I always need a parent container. So I start with the map as the parent container.

In addition, the symbology of the FeatureLayers is adapted.

Doing so, each single action is shown in the Undo Stack.

UlrichEgger_0-1739261343679.png

But from the user's perspective, this should be only one single action / operation.

How can I encapsulate these actions into one single operation ?

If it was about making multiple edits to tables and Feature Classes, I would use an EditOperation. But it seems like this is only meant for edits of database entities.

I am looking forward for your suggestions.

Best regards,

Ulrich Egger

 

 

 

 

 

0 Kudos
8 Replies
UmaHarano
Esri Regular Contributor

Hi @UlrichEgger 

Here are a couple of suggestions, might not give you exactly what you want, but there are some performance improvements possible:

1. We recently added functionality to add multiple layers at once.  Some information for this is here:

Loading multiple layers 

 

2. You can also create your own "operation" and add it to the Undo\Redo stack.  I am attaching a small project that illustrates this.  Note: The entries on the Undo stack are deconstructed for each task in the operation, but you do get a convenient custom operation name that you can click on.

UmaHarano_0-1739315810471.png

 

 

UlrichEgger
Occasional Contributor

Reply to suggestion 1:

The new method with BulkLayerCreationParams sounds very promising.

Can it also add multiple GroupLayers ?

In my case, we rather have a layer tree rather than just one GroupLayer to be filled.

 

0 Kudos
UlrichEgger
Occasional Contributor

UlrichEgger_1-1739348606648.png

Reply to suggestion 2:

It seems like the new Operation "2D-Ergebnis anzeigen" that should encapsulate the others only comes on top of the others.

 

0 Kudos
UmaHarano
Esri Regular Contributor

Hi!

BulkCreation doesn't support group layers unfortunately.

Regarding 2 - The operation should come at the top like you have in your screenshot. I had a QueudTask in the Do method that reversed the order. Attaching the fixed sample.

 

 

UlrichEgger
Occasional Contributor

Hi,

right, the QueuedTask.Run in the Do Method was not awaited.

I did not use the Do method but only implemented and used the DoAsync Method, using a QueuedTask.Run inside, like this:

UlrichEgger_0-1739433434747.png

(The Load2DResult method is async because the is some geoprocessing done inside among others.

That is why the DoAsync method is a bit complicated with all the awaits.)

But I am searching for a way to avoid all the other entries in the undo stack.

As I have seen from the screenshot above, the entry "New group layer" occurs although LayerFactory.Instance.CreateGroupLayer is done during the Do method of the MyAddLayersOperation.

So have I understood right, die Operation serves to have an additional entry on the undo stack, I can click on and it can provide methods to Undo and Redo the action.

 

 

 

0 Kudos
UmaHarano
Esri Regular Contributor

Exactly!

Unfortunately, there is no way to avoid having all the other entries right now.

0 Kudos
UlrichEgger
Occasional Contributor

Thank you, UmaHarano,

your answers have helped me a lot to understand the problem better and to find a better solution as soon as we use the 3.4 SDK.

But currently, it seems there is no way to have all the operations (adding the layers, setting renderers) in one operation in the undo stack. So it might be misleading for others, if I klick on "Accept as Solution" on one of yours answers.

Shall I close this issue ?

0 Kudos
UmaHarano
Esri Regular Contributor

That sounds good! Please go ahead and close the issue.

0 Kudos