I am using ModelBuilder to iterate Closest Facility analysis for every building at an archaeological site (OD Cost Matrix is not what I need--I need the geometry output, not just a cost matrix table). My draft model is below. One question: at the end of the model, it takes the routes generated from the Closest Facility analysis and copies it to a new feature class. However, the Copy Features tool seems to require a specific name for the output. When I iterate to the next facility, it will either overwrite or break the model.

So the question is simple: how do I configure Copy Features tool to output the name from the corresponding iteration (taken form the ObjectID field from the Iterate Feature Selection)?

Current model

1 Answer 1


In line variable substitution is what your looking for. You can use the 'Value' output from the iterate feature selection to uniquely label the output. In the Output Feature class in the Copy Features, use the %Value% to assign a different name for each iteration.

For example, set the output to [your output location]\%Value%'

See ESRI's help page for more info on how this works. Example 2 is what you want

  • Thanks, that's what I thought re: in line variable. But where do I actually place "%Value%"? The examples they give don't say where one actually places the in line variable in the tool. At least, I don't see it. I tried to do it by double clicking the output of Copy Features (the green oval on far right above) and replacing "New_test_03_" with "%Value%". It failed to write the feature class to the geodatabase. Apr 8, 2015 at 16:04
  • Got it. I opened the output from copy features, and instead of only putting %Vale% as the output name, I put some leading text before %Value%. In this case, I used "Route_" (w/o quotes). Thus, "Route_%Value%" outputs Route_1 (iteration 1, ObjectID=1), Route_2 (iteration 2, ObjectID=2), Route 3 (iteration 3, ObjectID=3), etc.Thank you. Apr 8, 2015 at 16:11
  • Actually, no. I get Error 000210 (Cannot create output) and Error 000354: The name contains invalid characters. Frustrating. Apr 8, 2015 at 16:44

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

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