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.
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
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:
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.
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.
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.
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:
(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.
Exactly!
Unfortunately, there is no way to avoid having all the other entries right now.
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 ?
That sounds good! Please go ahead and close the issue.