Programatically open georeferencing tab, read georeferencing tool data on completion

240
4
06-05-2020 11:14 AM
RoyJackson2
New Contributor III

I am developing a tool to assist GIS Techs in the process of georeferencing thousands of scanned maps.  

I need to:

1)  add the .tiff to the map with a button click (done)

2)  open the georeferencing toolbar automatically

The code below doesnt seem to do anything.   I cannot get any tab /ribbon to activate with this code.   Is there a different way of achieving this?    

FrameworkApplication.ActivateTab("esri_mapping_georeference_GeoreferenceTab");

3)  execute the command  "esri_mapping_georeferenceing_StartSessionButton"

The code below does not seem to run.   CanExecute is returning False.   But, when I try different commands such as esri_mapping_georeference_MoveButton, Command.Execute doesn't do anything.   

var commandId = @"esri_mapping_georeferenceing_StartSessionButton";
// get the ICommand interface from the ArcGIS Pro Button
// using command's plug-in wrapper
var iCommand = FrameworkApplication.GetPlugInWrapper(commandId) as ICommand;
if (iCommand != null)
{
// Let ArcGIS Pro do the work for us
if (iCommand.CanExecute(null)) iCommand.Execute(null);
}

How do I programatically execute built in commands in the georeferencing area?    I read a different post that says sometimes you may have to activate a parent item before the child is accessible.  If that is true, how do I determine what the parents are?

4)   After the  user does the georeferencing, I want to read the data from the georeferencing tool window (such as rotation, origin coordinates, scale).  Is this possible to hook into the built in tools to control them / read their data?

Thank you very much for any assistance.   I am trying lots of things and reading all I can find but I am missing something as I can't get anything to run.   New to Pro, familiar with ArcObjects and WPF.   

Relevant daml ids:

Name: Selected map has an active georeferencing edit session.
ID: esri_mapping_SceneGeoreferenceCondition


Name: Close Georeference
ID: esri_mapping_georeference_CloseSessionButton
Name: Elevate To Ground
ID: esri_mapping_georeference_ElevateToGroundButton
Name: Import
ID: esri_mapping_georeference_LoadControlPointsButton
Name: Move To Display
ID: esri_mapping_georeference_MoveToDisplayButton
Name: Reset
ID: esri_mapping_georeference_ResetButton
Name: Save As New
ID: esri_mapping_georeference_SaveAsButton
Name: Save
ID: esri_mapping_georeference_SaveButton
Name: Save To Workspace
ID: esri_mapping_georeference_SaveToWorkspaceButton
Name: Georeference
ID: esri_mapping_georeferenceing_StartSessionButton


Name: Move
ID: esri_mapping_georeference_MoveButton
Name: Rotate
ID: esri_mapping_georeference_RotateButton
Name: Scale
ID: esri_mapping_georeference_ScaleButton

4 Replies
RoyJackson2
New Contributor III

I made a discovery on item 3 regarding the inability to execute existing tools on the ribbons.  

With the DAML ids, using the DAML id generator and the SDK documentation, I had ids:

esri_mapping_georeferenceing_StartSessionButton

or

esri_mapping_georeference_MoveToDisplayButton

These do nothing when called.  

when I use the 3rd option for DAML ids, 

Use the "Show command IDs on ScreenTips" option in the "Customize the ribbon options" dialog within ArcGIS Pro to view the Ids on the tooltip of each command.
Magically I now see different DAML ids in pro, such as :
esri_datasourcesraster_georefStartButton
and 
esri_datasourcesraster_georefFitToDisplayButton
These do work, and I can call the existing tools.  
Does anyone have an explanation for what DAML ids go where, and how I would have ever figured out the correct DAML ids for my use case?   If I google these new DAML ids, there are zero results.  
On item #2, I can call the tools, but I cannot activate the tab.   The georeferencing tab is not listed in the DAML id registration files.  Neither of these commands work:
ProApp.ActivateTab("esri_datasourcesraster_imageryCoreTab");
ProApp.ActivateTab("esri_datasourcesraster_georefModalTab");
Thanks
0 Kudos
UmaHarano
Esri Regular Contributor

Hi Roy

Have you tried selecting your tiff layer on the TOC (contents pane) before trying to activate the Georeference tab?

You can activate a layer in the TOC programmatically using the SelectLayer method on the MapView.

Here is the API Reference topic on this method. There is a code snippet in this topic: SelectLayers

Pro is contextual, so the Georeference tab will only be displayed if the selected layer in the TOC is a raster layer.

Regarding DAML Ids for buttons and tools, I find that using the "Show command IDs on Screen Tips" option is the most convenient way.

Thanks

Uma

RoyJackson2
New Contributor III

Thank you Uma for the reply.   It turn out that the georeferencing tab was getting activated, but there was a setting that we had to change to make it appear:         

FrameworkApplication.IsRibbonMinimized = false;
The code didn't look like anything was happening until this changed.  
The main outstanding question on this topic is - When running tools that are built into pro, such as georeferencing tools - is it possibly to use the SDK to read what the tool is doing, and alter its behaviour during execution?       I see the samples showing how to call a custom tool, and even calling some commands right after the command is executed, but I don't see examples for digging into InformationOverlayViewModel Class as an example to read the data / trigger additional logic.  
Thank you again for the reply.  
0 Kudos
UmaHarano
Esri Regular Contributor

Hi Roy,The existing Pro tools cannot be modified - But using the Pro SDK and the public API, you can make your own tools though.

Thanks

Uma