Select to view content in your preferred language

Model Builder Tool (Merge) to process even if "input is not current"

2266
6
Jump to solution
01-31-2022 12:30 PM
paulaasmith
Emerging Contributor

(Using ArcMap 10.8) Hi, a very similar question was asked here (https://community.esri.com/t5/geoprocessing-questions/how-to-get-a-model-to-continue-when-all-the-in...) but never fully answered. I am using 3 buffer tools on 3 different Feature Layers (distance is specified by the user for each). I'd like to make 2 of them optional but because that is not an option (required parameter), I have a Boolean variable precondition that if unchecked, prevents the buffer from running. My problem is that they are then Merged into one feature layer at the end of my model and added to display. However, I am getting the "inputs are not current" and my Merge tool is not running if one of the buffers is not ran (Boolean variable unchecked). My question is, how do I get get the Merge tool to process given one or more of the inputs might not exist. I assume I need to use the 'Calculate Value' tool but can't quite figure out the expression or its use. An example would be helpful. Don't need to worry about the intermediate steps between buffer and merge (as I believe that is working fine).

For more context, I am trying to create specified buffers (temporary and permanent impacts) based on input (infrastructure type), then cut one buffer out of the other one (Erase tool alternative since I only have a basic license), then Merge all temporary buffers). 

Thanks for your time,

Paul

0 Kudos
1 Solution

Accepted Solutions
KimGarbade
Frequent Contributor

I just ran a quick test this morning.  I created a very simple "Main" model and a sub-model whose only purpose is to Iterate through the database the results of the "Main" model are written to and collect their paths (if they exist).  I defined the output of the "Collect Values" tool (in the sub-model) as a parameter and saved the sub-model.  Then I just dragged the sub-model into the "Main" model just like any other tool.  Since the sub-model doesn't require any inputs (other than knowing that the feature classes to be used as inputs into the merge have been created) I just set the feature classes that were the results of my Select statements to Preconditions that have to be met before the sub-model will run.  Since I defined the output of the Collect Values tool in the sub-model to be a parameter it is shown as the output for the sub-model when it is dragged into the "Main" model.  Then I just used that value as input into the merge. 

It worked for my very simple test, but your situation is a little more complex, but is should at least let your see how it works in one instance.  Hope this helps.

P.S. you might have to clean up for it between runs.  For example if the first time your run it you have three inputs into the merge and it works as expected it might not work correctly the next time when you only expect 2 inputs into the merge, because the third input might still be existing in your database because you never cleared it out after the first run...Hope that makes sense.

KimGarbade_0-1643899187789.png

KimGarbade_2-1643899704708.png

 

 

View solution in original post

6 Replies
KimGarbade
Frequent Contributor

Have you tried If Data Exists (Model Builder)

If Data Exists (ModelBuilder)—ArcGIS Pro | Documentation

0 Kudos
paulaasmith
Emerging Contributor

I appreciate your reply, but as stated in my question I am running ArcMap 10.8, not ArcGIS Pro. Is doesn't seem like "If Data Exists" is in ArcMap, is there a direct substitute?

0 Kudos
KimGarbade
Frequent Contributor

Sorry didn't notice the ArcMap 10.8 part....  If the three inputs into the Merge are all written to a file GDB or a single directory, and they are the only contents in that GDB or directory, you could create a submodel that used an iterator to step through each file in that GDB or directory and then use "Collect Values" to generate the input into your Merge.

0 Kudos
paulaasmith
Emerging Contributor

@KimGarbade no problem, thanks for your suggestion. Would you be able to provide a bit more detail if possible. I used the 'Feature Class to Feature Class' tool for all three inputs (to save them in the same GDB). I created another model using the 'Iterate Feature Classes' tool that looks at the the files in GDB. How do I connect/create the submodel for the main model and do I use the 'Collect Values' tool in the submodel or the main model? Thank you for your patience.

0 Kudos
KimGarbade
Frequent Contributor

I just ran a quick test this morning.  I created a very simple "Main" model and a sub-model whose only purpose is to Iterate through the database the results of the "Main" model are written to and collect their paths (if they exist).  I defined the output of the "Collect Values" tool (in the sub-model) as a parameter and saved the sub-model.  Then I just dragged the sub-model into the "Main" model just like any other tool.  Since the sub-model doesn't require any inputs (other than knowing that the feature classes to be used as inputs into the merge have been created) I just set the feature classes that were the results of my Select statements to Preconditions that have to be met before the sub-model will run.  Since I defined the output of the Collect Values tool in the sub-model to be a parameter it is shown as the output for the sub-model when it is dragged into the "Main" model.  Then I just used that value as input into the merge. 

It worked for my very simple test, but your situation is a little more complex, but is should at least let your see how it works in one instance.  Hope this helps.

P.S. you might have to clean up for it between runs.  For example if the first time your run it you have three inputs into the merge and it works as expected it might not work correctly the next time when you only expect 2 inputs into the merge, because the third input might still be existing in your database because you never cleared it out after the first run...Hope that makes sense.

KimGarbade_0-1643899187789.png

KimGarbade_2-1643899704708.png

 

 

paulaasmith
Emerging Contributor

@KimGarbade Thank you for your informative answer/s. You were correct that the GDB needs to be cleared before the next run. My model is getting quite complicated (for me anyway), and I have actually started to break it out into smaller operations. Here's a few screenshots of the model and submodel (there's two but they are the same, just writes to a different GDB) for reference. Thanks again!

0 Kudos