ModelBuilder and displaying results in ToC

280
10
12-28-2020 11:04 PM
Labels (1)
MarkFawkes
Occasional Contributor

Hi I am trying to develop a number of small tools to speed up/automate some basic and not so basic workflows for the ArcGIS users in my group, mainly using ModelBuilder to develop the tools. Users range from 'think I know a lot' to 'very basic/new user' so have to design the tool and usage to enable the most basic user to run a tool. The tools are going to be grouped in a number of toolboxes with the intent to run them from atoolbox. A number of the tools create datasets that I want to have displayed in the ToC after the tool is run.

I know that to achieve this with running a tool from a toolbox I need to make the dataset a parameter in ModelBuilder. However this then makes that parameter visible to (and AFAIK changeable by) the user, and I would prefer it be not visible, or at least setup so that the user cannot change the parameter. Probably not a big issue with most of the users I work with but I would like to make things foolproof (until the new improved fool comes along).

Is there a way that I can make the visible parameter/dataset not changeable for the user, or an alternative way to get the dataset added to the ToC without making it a parameter or visible when the tool is run. Perhaps a python script I could add to the tool to be able to add a specified dataset to the ToC without having to set the set the dataset as a parameter.

I am somewhat comfortable with playing around with Python, but do not have a great knowledge of Python to be able to figure this out from scratch (just enough knowledge to get me into trouble).   🙂

An approach to this issue may of interest to other Desktop (and Pro) users out there.

10 Replies
DanPatterson
MVP Notable Contributor

From...

Geoprocessing options—ArcGIS Pro | Documentation

In ArcGIS Pro, you have geoprocessing environment parameters which can be accessed to overwrite existing data sets and to automatically display results of geoprocessing operations without making them parameters.

Are you sure the equivalent doesn't exist in ArcMap?


... sort of retired...
MarkFawkes
Occasional Contributor

Hi Dan

I cannot find anything similar to what you describe in Desktop, and I don't have Pro installed to see where this might reside. I do have a walkaround that seems as though I may be able to integrate into my model(s) - python script using arcpy.insertLayer in ArcPy.mapping. I had the specific model in question working but just wanted a cleaner dialog to the users (which was just a prompt to change the folder that the 2 output layers are saved to if the user wants the outputs in a specific work/projet related folder rather than some common default location).

The model WAS working yesterday - it draws data from layers in the ToC of the mxd I run it from, but for some reason this morning decided that one of these layers did not exist but other layers were OK - all saved to C: drive location in fgdb. Just Arc being temperental!! Thanks for the suggestion - Pro seems to be the way to go, but I work for a State Govt department with users of many (usually very basic) experience levels and insinuating Pro into our working is a difficult thing to do (not that I have any say on the matter).

0 Kudos
NeelKumar
New Contributor III

See: Using geoprocessing options to control tool execution—Help | ArcGIS for Desktop


This will make it so your model results are added to your Table of Contents when the tool is run. 

 

MarkFawkes
Occasional Contributor

Hi NeelKumar

Your solution works if the tool is run from within ModelBuilder (i.e. while editing tool) but this does not work if running the tool from Catalog through the tool dialog window (which is how I want the tool to be run). AFAIK in Desktop the only way (other than a convoluted workaround) is to also declare the variable/output as a parameter which then makes it visible in the dialog screen for the tool which I was trying to avoid. Dan Patterson indicated that Pro can be configured to push a layer to the ToC without having to make it a parameter. AS posted in my reply to Dan, I do have a walaround using insertLayer in arcpy.mapping which would seem to be domething to get what I want - just need to delve a bit more into ArcPy to get this working. Tnakns for your suggestion.

0 Kudos
NeelKumar
New Contributor III

 In order to get the ModelBuilder Toolbox results added to the TOC automatically you need to do 2 things:

1. Make the output a parameter (which may not work for you since doing this will make it editable)

Model.PNG

2. Enable the Add results of geoprocessing operations to the display option from the Standard toolbar: Geoprocessing > Geoprocessing Options > Add results of geoprocessing operations to the display

GP_Options.PNG

If users check this box, this setting should persist between ArcGIS Sessions, at least it does for me.

Now when users run the Model through a Toolbox in ArcMap, the results will be added to the TOC.

This can be done in Python too, like you mentioned, but this may be a good workaround for now.

0 Kudos
curtvprice
MVP Esteemed Contributor

If you are running a model as a tool, in the model properties set the output dataset model parameter to Derived  (not Input or Output). Then the parameter will not show up in the tool dialog but it still will be added to the map when the model is run as a tool. (Add to Display only works when running the model in Edit mode, which I don't think is what you are doing here.)  This advice applies to both ArcMap and Pro.

Update: @NeelKumar is correct, my mistake, this parameter choice only applies to script tools.

NeelKumar
New Contributor III

Good catch with the 'Add to Display' not working outside of edit mode. Will revise my answer. 

MarkFawkes
Occasional Contributor

Hi curtvprice

I cannot seem to find this configuration anywhere within Desktop. May be in Pro but I do not have Pro installed to be able to check. If it is available in Dektop, can you point me towards it. Thanks for your reply. ##- Please type your reply above this line

NeelKumar
New Contributor III

I don't think you can change this parameter to Derived in the Model Properties. This works for script tools or python toolboxes but not ModelBuilder tools. At least in my case in ArcGIS Desktop 1081.

ModelProp.PNG

But if you edit your Model > Select Managed in your Output Parameter > then Save the Model:

ModelProp_Managed.PNG

This will change it to Derived in the Model Properties:

Derived.PNG