Select to view content in your preferred language

Use inline variable %Name% (iterate layers) in clip

69
4
yesterday
CharelvanDijk
Emerging Contributor
 

I want to use the inline variable in Iterate Layers to give the output layer of a clip the same name as the input layer. I created a model for this. In the output layer, I use %Name%. I connected the Name from Iterate Layers to the clip as a precondition. However, the %Name% in the clip output keeps causing errors. Any ideas?

0 Kudos
4 Replies
BobBooth1
Esri Contributor

Is it writing to the same location as the source feature classes? It may be trying to overwrite... maybe use %Name%_clip or something like that for the output.

0 Kudos
CharelvanDijk
Emerging Contributor

Thank you for the response.
I changed the workspace and the name, but it's still not working...

0 Kudos
BobBooth1
Esri Contributor

It looks as though the problem is that the feature class name you're producing contains spaces.

spaces_in_name.png

Try sanitizing them with ValidateTableName.

https://pro.arcgis.com/en/pro-app/latest/arcpy/get-started/working-with-geodatabases.htm

This post shows how you can use Calculate Value to do that:

https://community.esri.com/t5/geoprocessing-questions/arcgis-10-1-modelbuilder-validatetablename/m-p...

 

0 Kudos
CharelvanDijk
Emerging Contributor

That was exactly the problem... and the solution! Thank you so much for your help.
I wrote a guide for this issue, but it's only in Dutch (my English isn't that good).