1

Is that possible to make a model in which you can choose what certain model you are going to run? For example I have a list of models like:

  • Roads intersections detector level-1
  • Roads intersections detector level-2
  • Roads intersections detector level-3

And I want to create a model with a drop-down list with values which are names of that models I have in my toolbox. When value is selected the model launches certain submodel.

  • Yes. Have you tried creating three models that do something simple like copying a feature class to a different name for each (so you know which one ran), then added them to your model which you configure with a pick list? – PolyGeo Sep 8 '16 at 8:48
  • @PolyGeo some of my models have pick lists and work with a same layer of roads. But one of them, for instance, needs to be checked with layer of quarters, another by town or village. So due to convenience for other users I would like to make something like a choice of what kind of model they are going to run. – Pavel Pereverzev Sep 8 '16 at 8:58
  • Exactly, but the place where you are stuck is the little model over the top. While you are figuring out how to make that you can use three test submodels (like I described). That way you get quicker test cycles and can show us all the components if you get stuck. – PolyGeo Sep 8 '16 at 9:21
2

This can be done but requires a small bit of coding and you setting names, labels and aliases, none of which can be ignored.

Step 1 - Create a master model

Create the master model that will be the drop down list. Add a string variable and make it a parameter then set the value list to user friendly terms as shown below:

Setting value list

Step 2 - Create your 3 models that you want to execute independently

Use a standard Name and set the Label to be the text that was in the drop down, as shown below:

Setting model properties

Step 3 - Add a calculate value tool to master model

Note that the code imports the toolbox then calls the individual model by its Name (so not label),underscore then the toolbox alias (which I had set to myToolBox).

Code

The full python code is as:

import arcpy
def run(mod):
  try:
    arcpy.ImportToolbox(r"F:\Scratch\Toolbox.tbx")
    if mod == "model 1":
      arcpy.mod1_myToolBox1()
    elif mod == "my model 2":
      arcpy.mod2_myToolBox()
    else:
      arcpy.mod3_myToolBox()
    return True
  except arcpy.ExecuteError:
    arcpy.AddError(arcpy.GetMessages(2))
    return False
  • thanks for a detailed instruction! I made it all the way you show but I've got an error like Error running expression: run("Obj_checker_local") Traceback (most recent call last): File "<expression>", line 1, in <module> File "<string>", line 4, in run IOError: The toolbox file F:\Scratch\Toolbox.tbx was not found. Obj_checker is a label of one of my models – Pavel Pereverzev Sep 8 '16 at 15:10
  • F:\Scratch\Toolbox.tbx is my toolbox, I do not know where yours is or named, so you need to edit that line of code. I had created a toolbox with the master model and the 3 to be run all within a single toolbox. Also if you look very carefully I left in a deliberate error arcpy.mod1_myToolBox1(). My toolbox alias is myToolBox not myToolBox1. – Hornbydd Sep 8 '16 at 15:49
  • okay, I will try to fix that, thank you one more time! – Pavel Pereverzev Sep 8 '16 at 18:14

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.