Can I change a parameter from Required to Derived in ModelBuilder?

4541
9
07-21-2015 11:05 AM
AlexisGreen
New Contributor II

I built a model in which an output feature class is generated from the Merge tool.  ModelBuilder automatically sets this output parameter to a Required Input parameter that shows up when the user runs the tool from the tool dialog box.  This is supposed to be an Output parameter, so should not require the user to supply it via the tool dialog. Is there any way to tell ModelBuilder to make it a Derived instead of Required parameter?

0 Kudos
9 Replies
ChrisDonohue__GISP
MVP Alum

This seems odd.  Can you post an image of the model so we can see what processes are going on that may be causing this?

Chris Donohue, GISP

0 Kudos
AlexisGreen
New Contributor II

Model.png

The parameter I'm referring to is a feature class called "Type".  Even though it's the output of the Merge tool, ModelBuilder sets it as a Required parameter, so it shows up in the Model tool dialog as if the user needs to supply it as input. I'd prefer there only be one input in the tool dialog which is the "Potential Use" parameter.  Interestingly, when I mark the "Type" parameter as "Managed", ModelBuilder changes the parameter from Required to Derived.  This makes it not appear in the model tool dialog, but this is not ideal because it then won't let me change the name of the feature class, so when I mark it to Add to Display, it shows up in the ArcMap TOC with an odd sounding system-generated name rather than a user-friendly name that I would prefer.  Maybe there is no way to make the parameter Derived and still be able to control its name?  I plan to make this tool into a geoprocessing service in a web application, and would like for the user experience to be as easy as possible to use and understand.

0 Kudos
ChrisDonohue__GISP
MVP Alum

Hmmm, not sure why this is happening.  I made a simple model (ArcGIS 10.2.1) with just Merge (Data Management) and am not encountering the issue with the Parameter when run as a tool (see images below).  It did not result in a required parameter for the output.  I set parameters for the inputs to see if that would trigger it, but still no required output parameter.

So, my guess would be there either is a bug or I missed something important in your process.

One way I would suggest moving forward is to try to make just a Merge tool like I did as a test to see if that is the culprit.  If it is not, then start adding some of the other processes you have to it until the issue crops up again.

merge1.jpgmerge2.jpg

merge3.jpg

Chris Donohue, GISP

0 Kudos
AlexisGreen
New Contributor II

Chris, thanks for testing on your end.  I may not have been entirely clear in my explanation of the problem.  Looks like you did not flag the output of your Merge tool as a parameter, so it's not surprising that it doesn't show up in the model tool dialog when running the model as a tool.  I on the other hand intentionally specified the output of my Merge tool to be a parameter and also marked to "Add To Display", because I wanted to add the feature class to the ArcMap TOC, and I'm unaware of any other way to make data layers from models display in the TOC other than by making them parameters.

To clarify, what I'm questioning is why the feature class that is output from the Merge tool is considered by ModelBuilder to be an Input, Required parameter rather than an Output, Derived parameter.  I'd prefer the parameter to not show up in the model tool dialog.  The only way I can see to make it not show up there is to make the parameter "Managed", which disables my ability to name the FC something more user friendly.  Perhaps this behavior is by design and there is no way to have the model both 1) not display the parameter in the tool dialog and 2) still allow me to name it what I want? 

0 Kudos
ChrisDonohue__GISP
MVP Alum

Here's an older thread that offers some explanations that may be of help.  I'm not sure, but there may be a way to adapt their Python solution as workaround to resolve the issue.

Seth Sobel posted:

You may be able to get around this in 10.0 by using arcpy.mapping in a Calculate Value tool code block to add the layer to the current data frame.

Also, there is a toolbox posted by

Feature Class Not Added to Display / Table of Contents When a Variable Name is Used

Chris Donohue, GISP

0 Kudos
AlexisGreen
New Contributor II

Thanks, Chris.  I wound up figuring out a different workaround using Python.  If I run the Merge tool from a Python script instead of as a tool added to the model, I can specify in the Script tool properties that the parameter is a Derived Output parameter (not a Required Input parameter), and when doing so, these characteristics of the parameter are retained when adding the script to the model.  For some reason, there appears to be no similar way to change these same characteristics of parameters in the Model properties, but rather only in the Script tool properties.  Again thanks for looking into it, but I think I'm good to go now with my workaround, as things are finally working successfully.

0 Kudos
ChrisDonohue__GISP
MVP Alum

Glad you found a solution.  It's an interesting challenge.

For others reading this, here's a link that describes the limitations of displaying data from Modelbuilder:

Note:  Add To Display has no effect outside ModelBuilder. When running a model tool from its dialog box or the Python window, the Add To Display setting will not be honored. To add model data variables to the display when running the model from its dialog box or the Python window, make the data variable a model parameter, then 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.

Displaying Model Data

ArcGIS Help (10.2, 10.2.1, and 10.2.2)

Chris Donohue, GISP

ChrisDonohue__GISP
MVP Alum

Some more detail:

AddLayer (arcpy.mapping)

ArcGIS Help (10.2, 10.2.1, and 10.2.2)

Chris Donohue, GISP

0 Kudos
FreddieGibson
Occasional Contributor III

This is a limitation of ModelBuilder. Once you mark a parameter as a model parameter it can only derive its type from the current type of the parameter. This means if the parameter you flag is derived the model will treat it as derived. If you want to manipulate this in ModelBuilder you would need to present your data using a tool that provides derived output (i.e. the output is predetermined and cannot be modified by user input). A quick way to do this is to use the Calculate Value tool in ModelBuilder. I typically either use this approach or create a script tool to intercept and present the ModelBuilder outputs. Unlike ModelBuilder, a script tool will allow me to explicitly set the type of the parameter.