Updating a Model Parameter Default Value after Model Run

7067
12
Jump to solution
05-06-2016 08:33 AM
StevenWorkman
New Contributor III

Hi everyone.

Is it possible to change the default value of a parameter if the user selects a different value before running the model?  For example, if the user wants to change the distance in a distance parameter (from 20 feet to 50 feet), then the next time the user runs the model 50 feet will be the default value.  Assume this user does not know how to alter the parameter defaults values in model builder itself. They just want to run the model.   Any help will be appreciated.

What I need to happen is after a user changes the parameter value in the model, when the model is run again, the new value is now the default value.

Parameter set up in Model

ss1.png

User runs opens the model and sees the default value of Rural or Urban Local Road Distance as 0:

ss2.png

User wants to change the value of Rural or Urban Local Road Distance to 20:

ss3.png

Model Runs....

Next time user opens the model the default value is now 20:

ss3.png

Thanks!

0 Kudos
1 Solution

Accepted Solutions
WesMiller
Regular Contributor III

The only way to change a default parameter is to edit the model and save.

View solution in original post

0 Kudos
12 Replies
DanPatterson_Retired
MVP Emeritus

a model parameter has a P beside the input, meaning that it needs to be input  no P, means a local parameter

see the diagram and anything you want to change needs a P

Creating model parameters—Help | ArcGIS for Desktop

StevenWorkman
New Contributor III

Thanks Dan.  I have all of my parameters set up in my model.  Maybe my question wasn't clear.  I've updated the original question to show what I meant.

0 Kudos
DanPatterson_Retired
MVP Emeritus

one of your parameters isn't connected to the model workflow.  Perhaps you need to do so, or reorder the parameters in the model.  Even though they may appear in logical order, the actual order depends on how things were added or edited during the workflow

0 Kudos
WesMiller
Regular Contributor III

The only way to change a default parameter is to edit the model and save.

0 Kudos
AbdullahAnter
Occasional Contributor III

Why do you want to set default value?

you can clear the default value in model parameter

Then, when you open the model as a tool inside arc toolbox you can input any value.

0 Kudos
curtvprice
MVP Esteemed Contributor

Model Builder tool parameter validation is set up when you edit and save the model. You cannot change it without editing (and hopefully validating) the model.

Script tools have much more flexible parameter validation. For example, you could have a python script tool write this information to a file in the users's %APPDATA% folder and then the tool's validation code could look for and read that file to set defaults for the next run. This is simply not possible with Model Builder unless you to "hard code" those changes -- you can't change defaults.

AbdullahAnter
Occasional Contributor III

parameter called parameter because you can change it,Curtis

0 Kudos
curtvprice
MVP Esteemed Contributor

You can change the parameter, but you cannot change its default without editing the model. Script validation is more flexible.

DanPatterson_Retired
MVP Emeritus

Curtis is right... modelbuilder is a fine tool in the formulative stages of a workflow.  On the upside, the image it produces is really nice.  On the downside, the more people play with/edit  a model the more discombobulated it becomes and parameters get out of order and errors begin (note... they can be reordered, but a novice user may not know this). 

Even if they manage to get it to work, disappointment often sets in when it doesn't work on another computer or with different inputs.  The trick?  Once you get it to work, spit it out into a script, turn the script in to a script tool so that your parameters can be overtly specified and check by the tool and your selection of inputs is controlled.  The tool and its associated script(s) are readily distributed and they can be extensively documented in their help (that expand help button).

I have blogged on options before, including how to move from modelbuilder to scripts and even more simply, how to turn the outputs of the Results window into scripts.  The basic toolbox tools are the way to go for the vast majority of workflows that I have seen on this site.