I am trying to get the Feature Class name (from Iterate Feature Classes) into a new field. I have been following the models described in the following two threads.

Using Value from Iterate Feature Selection to Calculate Field in ArcMap 10.1 ModelBuilder


this one

However, whenever I run the model I get the following error message

ERROR 000539: Error running expression: CF0140r01 Traceback (most recent call last): File "", line 1, in NameError: name 'CF0140r01' is not defined Failed to execute (Calculate Field)

I have tried it using Parse Path using %Value% in the expression field (here is my model) enter image description here(https://i.sstatic.net/6N5fl.jpg) and I have tried it with the Parse Path tool removed , entering %Name% in the Expression box for Calculate Field

I get the same error message either way

Here are two screen shots of the Feature folder
enter image description here

and the Calculate Field enter image description here

I have tried to simplify this model (not even sure why I need the Feature Class to Feature Class tool, I just have it there because an earlier thread I was using to build this had that in it). Here is the updated, and simplified model, with the Error Message I am getting. FYI: the Expression in the Calculate Field tool is %Name%

enter image description here

  • Name into a field? Which step of the model are you using the name as a field. Can you show us this menu? Provide a screenshot of your feature folder as well (the inputs). Commented Oct 22, 2014 at 19:45
  • Not quite sure which menu you want to see, but each feature class has a unique name (ie. CF0139r01). Part of that name (the 3rd-5th characters) are the Image number (this data is all extracted from imagery). I have 181 different images, and each one has between 10-30 different derived feature classes. I have many different features associated with each image, and I want to bring them all together into a single Feature Class so that there is only 1 feature class per image (in the end there will be 181 feature classes). Commented Oct 22, 2014 at 20:47
  • (continued) I have added a new field to the feature class called "Image", this is the "Add Field" portion of the model. I then want to populate the field <Image> with the value of the name of the file it came from (ie. CF0139r01). I have tried using "Calculate Field" with %Name% as the expression , and I get the error message described above. I have also tried using the "Parse Path" tool to store the Value (Name of the feature class), and then use %Value% in the expression. I still get the message above. Commented Oct 22, 2014 at 20:51
  • Here are two screen shots !(imgur.com/TYm1ogK&UOTMIjT#0) Commented Oct 22, 2014 at 21:26
  • It looks like it could be worth using the edit button to revise your question because I just moved additional information that you had supplied as an "answer" into it. Also you refer to two "threads" but then had the same question linked twice. When linking questions from GIS SE within your questions and answers, the best way is to simply paste in the URL, and then wait a moment to see it look up and insert the question's title.
    – PolyGeo
    Commented Oct 22, 2014 at 22:15

2 Answers 2


The ultimate in stupidity.

All I was missing (in any of the ways I approached it) was "QUOTATION MARKS" around the expression.

ie. Expression = "%Value%" if using Parse Path, or "%Name%" if not using Parse Path

  • Ha! I too have fallen foul to this in the past. Embedding the variable within quotes is not an obvious approach. There is definitely a steep learning curve with the quirky parts of model builder.
    – Hornbydd
    Commented Oct 23, 2014 at 8:12

I would imagine the problem is with the fact you named the output of FeatureClass to FeatureClass tool using the inline substitution syntax which makes no sense. Rename that to something like "output" (do not include the quotes!). Then your field calculate tool expression stays as %Name% which is the inline substitution coming from the variable Name which is one of the outputs of the iterator.

  • I have updated it as you suggested (Changed FCtoFC tool output to "output"), and I still get the same error message telling me that the Name is not defined. Commented Oct 22, 2014 at 23:24

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.