If I run Make Feature Layer as a tool, the new layer is added to my map. If I put the tool in a model and run the model ('Add to Display' is selected), The layer never appears.
If I open the model and run it, the layer is added to the map, but they are in an awkward group called 'ModelBuilder' and have a prefix I don't want them to have.
I would like to run the model as a tool and when I do that, nothing gets added to the map.
Is there something I can do to make the created layers visible?
Thank you,
Randy McGregor
Solved! Go to Solution.
I believe it is by design, that a geoprocessing tool will not "add to display" when the multiple outputs are expected for a single variable. Split by Attributes GP tool is an example.
You could add a "Save to Layer File", save the layers inside a predefined workspace. Then Add the layers using Add Data option.
Please set the output as a Model Parameter as well.
As per Run a model
Note:
After the model tool runs successfully, only model outputs set as model parameters are added to the map.
Excellent advice. I appreciate it. I have found it works maddeningly inconsistently, though. The model has an iterator, and I think that may introduce a wrinkle.
I want to create a selection layer for each value in a field. Once, the first value appeared then disappeared when the model was done. Another time, only the final value appeared, but it did stay.
I fear the iterator may introduce complications to this?
Good to know. Could you also try using inline substitution for the output layer name?
Like this?
Doesn't work :(. I did remove the iterator and the one output layer was added, so I think I've hit a snag with the iterator. Thank you very much for your help here!
Randy McGregor
I added a 'Save to Layer File' tool and that does create a *.lyrx file for each unique value. The model will not add those into the map either, but it does create something I can see and work with after the model has run.
Loading feature layers created within a model or a script into the TOC has always been difficult. I have an old python script that does it and it's got a LOT of steps.
Don't rename the Value. Rename the output layer in Make Feature Layer tool.
I appreciate your willingness to work through this. This is pretty much what I have been doing. I can get them to add to the TOC from within model in a 'ModelBuilder' group like you show here, when I open the model and run it, but not when run as a tool.
If I run the iterator first, so that it is 'stuck' on the final value it calculated and only processes that one, it will add the inputs to the map. If I reset the iterator so that it cycles through all the values, it will not add the layers to the map.
I believe it is by design, that a geoprocessing tool will not "add to display" when the multiple outputs are expected for a single variable. Split by Attributes GP tool is an example.
You could add a "Save to Layer File", save the layers inside a predefined workspace. Then Add the layers using Add Data option.